Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 1.59 KB

README.md

File metadata and controls

74 lines (50 loc) · 1.59 KB

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