Abreviate names

Usage no npm install needed!

<script type="module">
  import abbreviateName from '';


Abbreviate the lastnames, except the last:

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


npm i abbreviate-lastnames


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'


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'