Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.99 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.99 KB

name-suffixes NPM version Build Status Dependency Status Coverage percentage

Greenkeeper badge

Identify name suffixes

For the most part, this is just the code version of the Wikipedia page on name suffixes. Each suffix has three parts: a list of variants, which is a list of all of the versions of the same suffix that differ in more than punctation, whitespace, or capitalization; a canonical version, which is a standard way of identifying a single suffix, and a type, which is one of: generational, academic, professional or religious.

Installation

$ npm install --save name-suffixes

Usage

var nameSuffixes = require('name-suffixes').suffixes;

nameSuffixes.forEach(suffix => {
  console.log(suffix.variants); // ['Jr', 'II', 'Junior']
  console.log(suffix.canonical); // 'Jr'
  console.log(suffix.type); // generational
});

var isSuffix = require('nameSuffixes').isSuffix;

console.log(isSuffix('Sr')); // true
console.log(isSuffix('Wade')); // false

var canonize = require('nameSuffixes').canonize;

console.log(canonize('II')); // { variants: ['Jr', 'II', 'Junior'], canonical: 'jr', type: 'generational' }
console.log(canonize('Wade')); // undefined

License

MIT © Doug Wade