Skip to content

Parse a human name string into salutation, first name, middle name, last name, suffix.

License

Notifications You must be signed in to change notification settings

remind101/humanparser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

humanparser JavaScript Bug Squash

humanparser is a third-party library we previously used at ParentSquare to parse a human name string into salutation, first name, middle name, last name, and suffix.

Requirements

  • Node version >= v11.15.0

If you have nvm installed you can run nvm use instead

Installation

You can use your preferred package manager for the installation

Install using yarn:

yarn install

Install using npm:

npm install

Your Goal

Your goal is to find the root cause of the bug described below, then fix it if you have time!

The Bug

When parseName is called for a salutation and last name only, it is returning the last name as the first name:

const human = require("humanparser")
const attrs = human.parseName("Ms. Smith")
console.log(attrs);

actual:

{ 
    salutation: 'Ms.',
    firstName: 'Smith',
    lastName: '',
    fullName: 'Ms. Smith'
}

expected:

{ 
    salutation: 'Ms.',
    firstName: '',
    lastName: 'Smith',
    fullName: 'Ms. Smith'
}

Usage

There are two scripts on the package.json file

Changelog

The mocha test suite has been left untouched for legacy compatibility.

For new tests it's strongly suggested to use the jest test suite

About

Parse a human name string into salutation, first name, middle name, last name, suffix.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%