Skip to content

Commit

Permalink
Merge 20edeab into 6badfc4
Browse files Browse the repository at this point in the history
  • Loading branch information
Clafter committed Jan 25, 2024
2 parents 6badfc4 + 20edeab commit cb8dc5a
Show file tree
Hide file tree
Showing 4 changed files with 2,327 additions and 14 deletions.
5 changes: 4 additions & 1 deletion index.d.ts
@@ -1,3 +1,6 @@
declare module "gender-detection-from-name" {
export function getGender(name: string, lang?: 'en' | 'it' | 'es'| 'fr'): string;
export function getGender(
name: string,
lang?: "en" | "it" | "es" | "fr" | "de"
): string;
}
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -2,6 +2,7 @@ const enMap = require('./names/en');
const itMap = require('./names/it');
const esMap = require('./names/es');
const frMap = require('./names/fr');
const deMap = require('./names/de');

/**
* Gender detection from first name and optional language
Expand All @@ -21,7 +22,8 @@ function getGender(name, lang = 'all') {
it: itMap,
es: esMap,
fr: frMap,
all: new Map([...itMap, ...enMap, ...esMap, ...frMap]),
de: deMap,
all: new Map([...itMap, ...enMap, ...esMap, ...frMap, ...deMap]),
};
// Use the Map of input language, or use all
const mapToUse = maps[lang] || maps.all;
Expand Down

0 comments on commit cb8dc5a

Please sign in to comment.