abbreviate-name

Abreviate names

Usage no npm install needed!

<script type="module">
  import abbreviateName from 'https://cdn.skypack.dev/abbreviate-name';
</script>

README

Abbreviate the lastnames, except the last:

'George Raymond Richard Martin' => 'George R. R. Martin'

Install

npm i abbreviate-lastnames

Usage

Just import the module, and use their like a function

import abbreviate from 'abbreviate-lastnames'

abbreviate('George Raymond Richard Martin')// => 'George R. R. Martin'

If you want set the numbers of lastnames to keep, pass a number in second argument

// will keep the two lastnames
abbreviate('George Raymond Richard Martin', 2) ==> 'George R. Richard Martin'

Prepositions

In portuguese, or spañol languages, the names commonly have prepositions, like de, dos, or el. This module know that, and by default, keep these, without abbreviate it. E.g.

abbreviate('Darlan Mendonça de Oliveira Almeida') ==> 'Darlan M. de O. Almeida'