pmaoui / saymyname

Parse human name, split them and fix letter-case. It came in full JS (ES6) with 0 dependency !

Home Page:https://www.npmjs.com/package/saymyname

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

SayMyName is a small library that do its best to let you split human name (into firstname and name) and aims to return the correct letter case.

Installation

With npm

npm install saymyname

In a browser

<script type="text/javascript" src="saymyname.js"></script>

Demo

You can play with the library here.

Usage

// full name constructor
const myName = new SayMyName("jean de la fontaine");

console.log(myName.humanize()); // return "Jean de La Fontaine"
console.log(myName.firstname);  // return "Jean"
console.log(myName.name);      // return "de La Fontaine"

// firstname + name constructor
const myName = new SayMyName("JEAN BAPTISTE","POQUELIN");

console.log(myName.humanize()); // return "Jean-Baptiste Poquelin"
console.log(myName.firstname);  // return "Jean-Baptise"
console.log(myName.name);      // return "Poquelin"

Limitations

I tried to catch as many case as possible (specially with nobiliary particle) but human naming is not (read: not at all) a science. Many thanks to you, Wikipedia.

Contributions

Feel free to contribute

About

Parse human name, split them and fix letter-case. It came in full JS (ES6) with 0 dependency !

https://www.npmjs.com/package/saymyname


Languages

Language:JavaScript 100.0%