GithubHelp home page GithubHelp logo

jb1905 / initials Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gr2m/initials

1.0 0.0 0.0 1.72 MB

extract initials from and add initials to names

Home Page: https://gr2m.github.io/initials

License: MIT License

JavaScript 100.00%

initials's Introduction

Initials. Because JD is shorter than John Doe

extracts initials from and adds initials to names

Build Status Coverage Status Greenkeeper badge

Installation

Install using npm for node.js:

npm install --save initials

Usage

initials('John Doe')
// 'JD'

initials(['John Doe', 'Robert Roe'])
// ['JD', 'RR']

// alias for initials('John Doe')
initials.find('John Doe')

// parse name(s)
initials.parse('John Doe')
// {name: 'John Doe', initials: 'JD'}

// add initials to name(s)
initials.addTo('John Doe')
// 'John Doe (JD)'

// pass existing initials for names
initials(['John Doe', 'Jane Dane'], {
  existing: { 'John Doe': 'JD' }
})
// ['JD', 'JDa']

Notes

Preffered initials can be passed in (JD), e.g.

console.log( initials('John Doe (JoDo)') );
// 'JoDo'

If a name contains an email, it gets ignored when calculating initials

console.log( initials('John Doe [email protected]') );
// 'JD'

If a name is an email, the domain part gets ignored

console.log( initials('[email protected]') );
// 'jo'

When passing an Array of names, duplicates of initials are avoided

console.log( initials(['John Doe', 'Jane Dane']) );
// ['JDo', 'JDa']

Test

npm test

LICENSE

MIT

initials's People

Contributors

boennemann avatar devinschulz avatar fleuv avatar gr2m avatar greenkeeper[bot] avatar greenkeeperio-bot avatar javimolla avatar s-panferov avatar sofiarivas avatar zoepage avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.