1.0.3 • Published 6 years ago

name-counter v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

name-counter

Simple library to extract and count names from a supplied piece of text.

Usage

Exports a single function countNames, with the following signature:

countNames(text: string, titles: string[], firstNames: string[], lastNames: string[]): Array<{ name: string, timesFound: number }>
ParamTypeDescription
textstringThe text to be searched through
titlesstring[]Array of allowable titles (e.g. Mr, Mrs, Ms)
firstNamesstring[]Array of allowable first names (also used for middle names)
lastNamesstring[]Array of allowable last names

Example

countNames('My name is Mr. Daniel Young and I like to code', ['Mr', 'Mrs'], ['Daniel', 'Danielle'], ['Young', 'Old']) // returns [{ name 'Mr Daniel Young', timesFound: 1}]

Limitations

Does not support double-barreled last names.