MCPcopy Index your code
hub / github.com/RandomAPI/Randomuser.me-Node / getPersonId

Function getPersonId

api/1.4/data/NO/inject.js:33–56  ·  view source on GitHub ↗
(birthDate, year, gender)

Source from the content-addressed store, hash-verified

31 };
32
33 const getPersonId = (birthDate, year, gender) => {
34 let no;
35 let isMale = (gender === 'male');
36
37 if (year >= 2000) {
38 no = 999 - range(0, (999 - 500));
39 } else if (year <= 1899) {
40 no = 749 - range(0, (749 - 500));
41 } else if (year >= 1900 && year <= 1999) {
42 no = 499 - range(0, 499);
43 }
44 if ( ((no & 1) && !isMale) || (!(no & 1) && isMale) ) {
45 no--;
46 }
47 no = pad(String(no), 3);
48
49 const fNr = birthDate + no;
50 const fNr11 = fNr + calculateCheckDigits(fNr);
51
52 if (fNr11.length !== 11 || fNr11.substr(-1) === '0') {
53 return getPersonId(birthDate, year, gender);
54 }
55 return fNr11;
56 };
57
58 contents.id = {
59 name: 'FN',

Callers 1

inject.jsFile · 0.70

Calls 3

padFunction · 0.85
calculateCheckDigitsFunction · 0.70
rangeFunction · 0.50

Tested by

no test coverage detected