gender-detection-from-name
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -22,4 +22,4 @@ const enMap = require('./names/en') | ||
} | ||
// Use the Map of input language | ||
const mapToUse = maps[lang] | ||
// Use the Map of input language, or use all | ||
const mapToUse = maps[lang] || maps.all | ||
// Get the gender from the input language Map, or try with all, otherwise is unknown | ||
@@ -26,0 +26,0 @@ const result = mapToUse.get(name) || maps.all.get(name) || 'unknown' |
{ | ||
"name": "gender-detection-from-name", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Gender detection from first name", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,2 +29,14 @@ const assert = require('assert') | ||
}) | ||
it('should return male for some names with wrong language', () => { | ||
const names = ['Dave', 'John', 'Giacomo', 'George', 'Luca'] | ||
for (let name of names) { | ||
assert.strictEqual(getGender(name, 'de'), 'male') | ||
} | ||
}) | ||
it('should return female for some names with wrong language', () => { | ||
const names = ['Anna', 'Jennifer', 'Lisa', 'Marta', 'Catherine'] | ||
for (let name of names) { | ||
assert.strictEqual(getGender(name, 'de'), 'female') | ||
} | ||
}) | ||
it('should return male for some names with no language', () => { | ||
@@ -31,0 +43,0 @@ const names = ['Dave', 'John', 'Giacomo', 'George', 'Luca'] |
863959
33814