11/*
2- • Use native js dates instead of moment for ~60% increase in dates calculation
3- • Email addresses are now transliterated
4- • More street/city names for NL dataset
5- • Add country name to location block
6- • Capitalized proper nouns
7- • Split street into number and name properties
8- • Fixed Norwegian id generation bug
9- • Fixed Switzerland phone number format
10- • Fixed Danish CPR number calculation
2+ • Fix US Social Security Number Generation
3+ • Add India Data
4+ • Add Mexico Data
5+ • Add Serbia Data
6+ • Add Ukraine Data
7+ • Update Turkish Data lists
8+ • Add CPF as Brazil's id
9+ • Add SIN as Canada's id
10+ • Add SVNR as Germany's id
11+ • Change serial# to SN for LEGO id
12+ • Fix French INSEE generation
13+ • Fix DOB/Registered age calculation
1114*/
1215
1316const fs = require ( 'fs' ) ;
@@ -20,10 +23,11 @@ const YAML = require('yamljs');
2023const js2xmlparser = require ( 'js2xmlparser' ) ;
2124const converter = require ( 'json-2-csv' ) ;
2225const faker = require ( 'faker' ) ;
23- const tr = require ( "transliteration" ) ;
26+ const tr = require ( 'transliteration' ) ;
27+ const dayjs = require ( 'dayjs' )
2428const util = require ( '../../util' ) ;
2529const settings = require ( '../../settings' ) ;
26- const version = '1.3 ' ;
30+ const version = '1.4 ' ;
2731
2832class Generator {
2933 constructor ( ) {
@@ -32,7 +36,7 @@ class Generator {
3236 'login' , 'registered' , 'dob' , 'phone' ,
3337 'cell' , 'id' , 'picture' , 'nat'
3438 ] ;
35- this . constantTime = 1569449450 ;
39+ this . constantTime = 1653344189 ;
3640 this . version = version ;
3741
3842 this . datasets = null ;
@@ -189,13 +193,13 @@ class Generator {
189193
190194 this . current . dob = {
191195 date : dobDate . toISOString ( ) ,
192- age : new Date ( ) . getFullYear ( ) - dobDate . getFullYear ( )
196+ age : dayjs ( ) . diff ( dayjs ( dobDate ) , 'years' ) ,
193197 } ;
194198 let reg = range ( 1016688461000 , this . constantTime * 1000 ) ;
195199 let regDate = new Date ( reg ) ;
196200 this . include ( 'registered' , {
197201 date : regDate . toISOString ( ) ,
198- age : new Date ( ) . getFullYear ( ) - regDate . getFullYear ( )
202+ age : dayjs ( ) . diff ( dayjs ( regDate ) , 'years' ) ,
199203 } ) ;
200204
201205 let id , genderText ;
@@ -380,7 +384,7 @@ class Generator {
380384 }
381385
382386 fullNatName ( nat ) {
383- let mapping = {
387+ const mapping = {
384388 AU : "Australia" ,
385389 BR : "Brazil" ,
386390 CA : "Canada" ,
@@ -392,13 +396,16 @@ class Generator {
392396 FR : "France" ,
393397 GB : "United Kingdom" ,
394398 IE : "Ireland" ,
399+ IN : "India" ,
395400 IR : "Iran" ,
401+ MX : "Mexico" ,
396402 NL : "Netherlands" ,
403+ NO : "Norway" ,
397404 NZ : "New Zealand" ,
398405 RS : "Serbia" ,
399406 TR : "Turkey" ,
407+ UA : "Ukraine" ,
400408 US : "United States" ,
401- UA : "Ukrainian" ,
402409 } ;
403410 return mapping [ nat ] ;
404411 }
@@ -418,6 +425,8 @@ function random(mode, length) {
418425 chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
419426 } else if ( mode == 5 ) {
420427 chars = '23456789' ;
428+ } else if ( mode == 6 ) {
429+ chars = 'abcdefghijklmnopqrstuvwxyz' ;
421430 }
422431 for ( let i = 0 ; i < length ; i ++ ) {
423432 result += chars [ range ( 0 , chars . length - 1 ) ] ;
@@ -430,7 +439,7 @@ function randomItem(arr) {
430439 return arr [ range ( 0 , arr . length - 1 ) ] ;
431440}
432441
433- function range ( min , max ) {
442+ function range ( min , max ) {
434443 return min + mersenne . rand ( max - min + 1 ) ;
435444}
436445
0 commit comments