Skip to content

compwright/split-human-name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

split-human-name

Build Status Dependency Status Download Status Sponsor on GitHub

Split a person's name into first name and last name fields

Features

  • Splits a name into exactly two fields { firstName, lastName }
  • Fixes UPPERCASE, lowercase, iNVERSE CASE, and otherwise FUnkY cAse
  • Handles couples ("John and Jane Doe")
  • Gracefully degrades to put the entire string in firstName if there are multiple last names

Based on the awesome humanparser and namecase packages

Online demo: http://compwright.com/demos/split-human-name

Requirements

  • Node.js 10+

Installation

$ npm install --save split-human-name

Usage Examples

Browser

<script src="https://unpkg.com/split-human-name@latest/dist/split-human-name.min.js"></script>
<script>
  console.log(window.splitHumanName('John and Jane Doe'));
</script>

Node

const splitName = require('split-human-name');
const { firstName, lastName } = splitName('John and Jane Doe');
assert.strictEquals(firstName, 'John and Jane');
assert.strictEquals(lastName, 'Doe');

License

MIT

About

Split a person's name into firstName and lastName fields

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors 3

  •  
  •  
  •