infer-gender
Advanced tools
Comparing version 1.2.2 to 1.3.0
34
index.js
@@ -14,13 +14,22 @@ const fs = require('fs') | ||
const names = {} | ||
for (const name of load(MALE)) { | ||
names[name] = MALE | ||
} | ||
let names | ||
for (const name of load(FEMALE)) { | ||
names[name] = name in names ? UNISEX : FEMALE | ||
exports.initialize = () => { | ||
names = {} | ||
for (const name of load(MALE)) { | ||
names[name] = MALE | ||
} | ||
for (const name of load(FEMALE)) { | ||
names[name] = name in names ? UNISEX : FEMALE | ||
} | ||
} | ||
exports.extractName = (fullName, onlyFirst = false) => ( | ||
removeDiacritics(fullName) | ||
exports.extractName = (fullName, onlyFirst = false) => { | ||
if (!names) { | ||
// If not manually initialized, load in-demand | ||
exports.initialize() | ||
} | ||
return removeDiacritics(fullName) | ||
.toLowerCase() | ||
@@ -31,6 +40,7 @@ .replace(/[^a-z-абвгдезиклмнопрстэюяабвгдеийклмнопрстуфхчьяё ]+/g, '') | ||
.find(name => name in names || onlyFirst) | ||
) | ||
} | ||
exports.infer = (fullName, onlyFirst = false) => ( | ||
names[exports.extractName(fullName, onlyFirst)] || UNKNOWN | ||
) | ||
exports.infer = (fullName, onlyFirst = false) => { | ||
const name = exports.extractName(fullName, onlyFirst) | ||
return names[name] || UNKNOWN | ||
} |
{ | ||
"name": "infer-gender", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Infer the gender of a name based on a large list of names, case insensitive and removes diacritics", | ||
@@ -9,6 +9,14 @@ "scripts": { | ||
"test": "mocha", | ||
"precommit": "npm run lint && npm run test" | ||
"precommit": "npm run lint && npm run test", | ||
"cli": "./bin/cli.js" | ||
}, | ||
"bin": { | ||
"infer-gender": "./bin/cli.js" | ||
}, | ||
"main": "./index.js", | ||
"author": "Ariel Flesler <aflesler@gmail.com>", | ||
"author": { | ||
"name": "Ariel Flesler", | ||
"email": "aflesler@gmail.com", | ||
"url": "https://github.com/flesler" | ||
}, | ||
"dependencies": { | ||
@@ -22,8 +30,15 @@ "diacritics": "^1.3.0" | ||
"husky": "^0.14.3", | ||
"mocha": "^5.2.0", | ||
"nodemon": "^1.18.7" | ||
"mocha": "^8.1.3", | ||
"nodemon": "^2.0.4" | ||
}, | ||
"engines": { | ||
"node": "^8.0.0" | ||
} | ||
"node": ">=8.0.0" | ||
}, | ||
"homepage": "https://github.com/flesler/infer-gender", | ||
"bugs": "https://github.com/flesler/infer-gender/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/flesler/infer-gender.git" | ||
}, | ||
"license": "SEE LICENSE IN LICENSE.md" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
439289
8
82
0
1