Initials. Because JD is shorter than John Doe
extracts initials from and adds initials to names
Installation
Install using npm for node.js:
npm install --save initials
Usage
initials('John Doe')
initials(['John Doe', 'Robert Roe'])
initials.find('John Doe')
initials.parse('John Doe')
initials.addTo('John Doe')
initials(['John Doe', 'Jane Dane'], {
existing: { 'John Doe': 'JD' }
})
Notes
Preffered initials can be passed in (JD)
, e.g.
console.log( initials('John Doe (JoDo)') );
If a name contains an email, it gets ignored when calculating initials
console.log( initials('John Doe joe@example.com') );
If a name is an email, the domain part gets ignored
console.log( initials('joe@example.com') );
When passing an Array of names, duplicates of initials are avoided
console.log( initials(['John Doe', 'Jane Dane']) );
Test
npm test
Fine Print
initials have been authored by Gregor Martynus,
proud member of the Hoodie Community.
License: MIT