mimic-data 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +566 -348
- package/dist/index.d.mts +163 -42
- package/dist/index.d.ts +163 -42
- package/dist/index.js +18711 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18710 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +54 -54
package/dist/index.d.mts
CHANGED
|
@@ -45,64 +45,116 @@ interface LocaleDefinition extends LocaleData {
|
|
|
45
45
|
formatFullName(firstName: string, lastName: string): string;
|
|
46
46
|
formatAddress(street: string, city: string, state: string, zipCode: string): string;
|
|
47
47
|
generateZipCode(): string;
|
|
48
|
+
phoneFormats?: string[];
|
|
49
|
+
emailDomains?: string[];
|
|
50
|
+
companyNames?: string[];
|
|
51
|
+
industries?: string[];
|
|
52
|
+
catchPhrases?: string[];
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
declare class Mimic {
|
|
51
56
|
private locale;
|
|
57
|
+
private identityCache;
|
|
58
|
+
private locationCache;
|
|
59
|
+
private physicalCache;
|
|
60
|
+
private workCache;
|
|
52
61
|
constructor(locale: LocaleDefinition);
|
|
53
62
|
/**
|
|
54
|
-
* Update the locale
|
|
63
|
+
* Update the locale and clear caches
|
|
55
64
|
*/
|
|
56
65
|
setLocale(locale: LocaleDefinition): void;
|
|
57
66
|
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
* Clear all cached generators
|
|
68
|
+
*/
|
|
69
|
+
private clearCaches;
|
|
70
|
+
/**
|
|
71
|
+
* Create identity generator (cached)
|
|
72
|
+
*/
|
|
73
|
+
private createIdentity;
|
|
74
|
+
/**
|
|
75
|
+
* Identity generator (cached accessor)
|
|
76
|
+
*/
|
|
77
|
+
get identity(): ReturnType<typeof this.createIdentity>;
|
|
78
|
+
/**
|
|
79
|
+
* Create location generator (cached)
|
|
80
|
+
*/
|
|
81
|
+
private createLocation;
|
|
82
|
+
/**
|
|
83
|
+
* Location generator (cached accessor)
|
|
84
|
+
*/
|
|
85
|
+
get location(): ReturnType<typeof this.createLocation>;
|
|
86
|
+
/**
|
|
87
|
+
* Create physical data generator (cached)
|
|
88
|
+
*/
|
|
89
|
+
private createPhysical;
|
|
90
|
+
/**
|
|
91
|
+
* Physical data generator (cached accessor)
|
|
92
|
+
*/
|
|
93
|
+
get physical(): ReturnType<typeof this.createPhysical>;
|
|
94
|
+
/**
|
|
95
|
+
* Create work data generator (cached)
|
|
96
|
+
*/
|
|
97
|
+
private createWork;
|
|
98
|
+
/**
|
|
99
|
+
* Work data generator (cached accessor)
|
|
100
|
+
*/
|
|
101
|
+
get work(): ReturnType<typeof this.createWork>;
|
|
102
|
+
/**
|
|
103
|
+
* Create contact generator (cached)
|
|
104
|
+
*/
|
|
105
|
+
private createContact;
|
|
106
|
+
/**
|
|
107
|
+
* Contact generator (cached accessor)
|
|
108
|
+
*/
|
|
109
|
+
get contact(): ReturnType<typeof this.createContact>;
|
|
110
|
+
/**
|
|
111
|
+
* Create company generator (cached)
|
|
112
|
+
*/
|
|
113
|
+
private createCompany;
|
|
114
|
+
/**
|
|
115
|
+
* Company generator (cached accessor)
|
|
116
|
+
*/
|
|
117
|
+
get company(): ReturnType<typeof this.createCompany>;
|
|
118
|
+
/**
|
|
119
|
+
* Format phone number from pattern
|
|
120
|
+
*/
|
|
121
|
+
private formatPhoneNumber;
|
|
122
|
+
/**
|
|
123
|
+
* Generate complete mock data for multiple entities
|
|
124
|
+
*/
|
|
125
|
+
generateMockEntities(count: number, options?: {
|
|
126
|
+
gender?: Gender;
|
|
127
|
+
ageRange?: AgeRange;
|
|
128
|
+
}): Array<PersonData & AddressData & PhysicalData & WorkData>;
|
|
129
|
+
/**
|
|
130
|
+
* Generate unique mock entities (no duplicate full names)
|
|
131
|
+
*/
|
|
132
|
+
generateUniqueMockEntities(count: number, options?: {
|
|
133
|
+
gender?: Gender;
|
|
134
|
+
ageRange?: AgeRange;
|
|
135
|
+
}): Array<PersonData & AddressData & PhysicalData & WorkData>;
|
|
96
136
|
}
|
|
97
137
|
|
|
98
138
|
/**
|
|
99
|
-
*
|
|
139
|
+
* Seeded random number generator using Mulberry32 algorithm
|
|
140
|
+
* Provides reproducible random sequences for testing
|
|
100
141
|
*/
|
|
101
142
|
declare class Random {
|
|
143
|
+
private static seedValue;
|
|
102
144
|
/**
|
|
103
|
-
*
|
|
145
|
+
* Initialize seeded random with a specific seed
|
|
146
|
+
* Call this to reproduce the same random sequence
|
|
147
|
+
* @param seed - Number seed for reproducible randomness
|
|
104
148
|
*/
|
|
105
|
-
static
|
|
149
|
+
static seed(seed: number): void;
|
|
150
|
+
/**
|
|
151
|
+
* Reset to native Math.random() (non-deterministic)
|
|
152
|
+
*/
|
|
153
|
+
static unseed(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get random number (seeded or native)
|
|
156
|
+
*/
|
|
157
|
+
private static random;
|
|
106
158
|
/**
|
|
107
159
|
* Get random integer between min and max (inclusive)
|
|
108
160
|
*/
|
|
@@ -115,10 +167,22 @@ declare class Random {
|
|
|
115
167
|
* Get random boolean
|
|
116
168
|
*/
|
|
117
169
|
static boolean(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get random element from array
|
|
172
|
+
*/
|
|
173
|
+
static pick<T>(array: T[]): T;
|
|
118
174
|
/**
|
|
119
175
|
* Shuffle array (Fisher-Yates algorithm)
|
|
120
176
|
*/
|
|
121
177
|
static shuffle<T>(array: T[]): T[];
|
|
178
|
+
/**
|
|
179
|
+
* Generate multiple random values at once
|
|
180
|
+
*/
|
|
181
|
+
static multiple<T>(generator: () => T, count: number): T[];
|
|
182
|
+
/**
|
|
183
|
+
* Generate unique random values (no duplicates)
|
|
184
|
+
*/
|
|
185
|
+
static unique<T>(generator: () => T, count: number, maxAttempts?: number): T[];
|
|
122
186
|
}
|
|
123
187
|
|
|
124
188
|
/**
|
|
@@ -220,6 +284,63 @@ declare const locales: {
|
|
|
220
284
|
ar_SA: LocaleDefinition;
|
|
221
285
|
ar_EG: LocaleDefinition;
|
|
222
286
|
he_IL: LocaleDefinition;
|
|
287
|
+
uk_UA: LocaleDefinition;
|
|
288
|
+
sk_SK: LocaleDefinition;
|
|
289
|
+
hr_HR: LocaleDefinition;
|
|
290
|
+
rs_RS: LocaleDefinition;
|
|
291
|
+
lt_LT: LocaleDefinition;
|
|
292
|
+
lv_LV: LocaleDefinition;
|
|
293
|
+
et_EE: LocaleDefinition;
|
|
294
|
+
bg_BG: LocaleDefinition;
|
|
295
|
+
is_IS: LocaleDefinition;
|
|
296
|
+
en_NG: LocaleDefinition;
|
|
297
|
+
en_KE: LocaleDefinition;
|
|
298
|
+
en_PK: LocaleDefinition;
|
|
299
|
+
bn_BD: LocaleDefinition;
|
|
300
|
+
fa_IR: LocaleDefinition;
|
|
301
|
+
ar_MA: LocaleDefinition;
|
|
302
|
+
es_CO: LocaleDefinition;
|
|
303
|
+
es_PE: LocaleDefinition;
|
|
304
|
+
es_VE: LocaleDefinition;
|
|
305
|
+
es_GT: LocaleDefinition;
|
|
306
|
+
es_CR: LocaleDefinition;
|
|
307
|
+
zh_TW: LocaleDefinition;
|
|
308
|
+
ar_IQ: LocaleDefinition;
|
|
309
|
+
ar_KW: LocaleDefinition;
|
|
310
|
+
ar_QA: LocaleDefinition;
|
|
311
|
+
ar_BH: LocaleDefinition;
|
|
312
|
+
ar_DZ: LocaleDefinition;
|
|
313
|
+
ar_JO: LocaleDefinition;
|
|
314
|
+
ar_LB: LocaleDefinition;
|
|
315
|
+
ar_LY: LocaleDefinition;
|
|
316
|
+
ar_OM: LocaleDefinition;
|
|
317
|
+
ar_SD: LocaleDefinition;
|
|
318
|
+
ar_SY: LocaleDefinition;
|
|
319
|
+
ar_TN: LocaleDefinition;
|
|
320
|
+
ar_YE: LocaleDefinition;
|
|
321
|
+
en_IE: LocaleDefinition;
|
|
322
|
+
fr_BE: LocaleDefinition;
|
|
323
|
+
fr_CH: LocaleDefinition;
|
|
324
|
+
de_LI: LocaleDefinition;
|
|
325
|
+
de_LU: LocaleDefinition;
|
|
326
|
+
it_CH: LocaleDefinition;
|
|
327
|
+
ca_ES: LocaleDefinition;
|
|
328
|
+
fr_LU: LocaleDefinition;
|
|
329
|
+
fr_CA: LocaleDefinition;
|
|
330
|
+
es_EC: LocaleDefinition;
|
|
331
|
+
es_BO: LocaleDefinition;
|
|
332
|
+
es_PY: LocaleDefinition;
|
|
333
|
+
es_US: LocaleDefinition;
|
|
334
|
+
es_DO: LocaleDefinition;
|
|
335
|
+
zh_HK: LocaleDefinition;
|
|
336
|
+
hi_IN: LocaleDefinition;
|
|
337
|
+
ne_NP: LocaleDefinition;
|
|
338
|
+
ur_PK: LocaleDefinition;
|
|
339
|
+
bn_IN: LocaleDefinition;
|
|
340
|
+
sw_KE: LocaleDefinition;
|
|
341
|
+
sw_TZ: LocaleDefinition;
|
|
342
|
+
af_ZA: LocaleDefinition;
|
|
343
|
+
pt_MZ: LocaleDefinition;
|
|
223
344
|
};
|
|
224
345
|
|
|
225
346
|
export { type AddressData, type AgeRange, type Gender, type LocaleData, type LocaleDefinition, type MetricSystem, Mimic, type PersonData, type PhysicalData, Random, type WorkData, createMimic, createMimic as default, getAllLocaleCodes, getAvailableLocales, localeRegistry, locales };
|
package/dist/index.d.ts
CHANGED
|
@@ -45,64 +45,116 @@ interface LocaleDefinition extends LocaleData {
|
|
|
45
45
|
formatFullName(firstName: string, lastName: string): string;
|
|
46
46
|
formatAddress(street: string, city: string, state: string, zipCode: string): string;
|
|
47
47
|
generateZipCode(): string;
|
|
48
|
+
phoneFormats?: string[];
|
|
49
|
+
emailDomains?: string[];
|
|
50
|
+
companyNames?: string[];
|
|
51
|
+
industries?: string[];
|
|
52
|
+
catchPhrases?: string[];
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
declare class Mimic {
|
|
51
56
|
private locale;
|
|
57
|
+
private identityCache;
|
|
58
|
+
private locationCache;
|
|
59
|
+
private physicalCache;
|
|
60
|
+
private workCache;
|
|
52
61
|
constructor(locale: LocaleDefinition);
|
|
53
62
|
/**
|
|
54
|
-
* Update the locale
|
|
63
|
+
* Update the locale and clear caches
|
|
55
64
|
*/
|
|
56
65
|
setLocale(locale: LocaleDefinition): void;
|
|
57
66
|
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
* Clear all cached generators
|
|
68
|
+
*/
|
|
69
|
+
private clearCaches;
|
|
70
|
+
/**
|
|
71
|
+
* Create identity generator (cached)
|
|
72
|
+
*/
|
|
73
|
+
private createIdentity;
|
|
74
|
+
/**
|
|
75
|
+
* Identity generator (cached accessor)
|
|
76
|
+
*/
|
|
77
|
+
get identity(): ReturnType<typeof this.createIdentity>;
|
|
78
|
+
/**
|
|
79
|
+
* Create location generator (cached)
|
|
80
|
+
*/
|
|
81
|
+
private createLocation;
|
|
82
|
+
/**
|
|
83
|
+
* Location generator (cached accessor)
|
|
84
|
+
*/
|
|
85
|
+
get location(): ReturnType<typeof this.createLocation>;
|
|
86
|
+
/**
|
|
87
|
+
* Create physical data generator (cached)
|
|
88
|
+
*/
|
|
89
|
+
private createPhysical;
|
|
90
|
+
/**
|
|
91
|
+
* Physical data generator (cached accessor)
|
|
92
|
+
*/
|
|
93
|
+
get physical(): ReturnType<typeof this.createPhysical>;
|
|
94
|
+
/**
|
|
95
|
+
* Create work data generator (cached)
|
|
96
|
+
*/
|
|
97
|
+
private createWork;
|
|
98
|
+
/**
|
|
99
|
+
* Work data generator (cached accessor)
|
|
100
|
+
*/
|
|
101
|
+
get work(): ReturnType<typeof this.createWork>;
|
|
102
|
+
/**
|
|
103
|
+
* Create contact generator (cached)
|
|
104
|
+
*/
|
|
105
|
+
private createContact;
|
|
106
|
+
/**
|
|
107
|
+
* Contact generator (cached accessor)
|
|
108
|
+
*/
|
|
109
|
+
get contact(): ReturnType<typeof this.createContact>;
|
|
110
|
+
/**
|
|
111
|
+
* Create company generator (cached)
|
|
112
|
+
*/
|
|
113
|
+
private createCompany;
|
|
114
|
+
/**
|
|
115
|
+
* Company generator (cached accessor)
|
|
116
|
+
*/
|
|
117
|
+
get company(): ReturnType<typeof this.createCompany>;
|
|
118
|
+
/**
|
|
119
|
+
* Format phone number from pattern
|
|
120
|
+
*/
|
|
121
|
+
private formatPhoneNumber;
|
|
122
|
+
/**
|
|
123
|
+
* Generate complete mock data for multiple entities
|
|
124
|
+
*/
|
|
125
|
+
generateMockEntities(count: number, options?: {
|
|
126
|
+
gender?: Gender;
|
|
127
|
+
ageRange?: AgeRange;
|
|
128
|
+
}): Array<PersonData & AddressData & PhysicalData & WorkData>;
|
|
129
|
+
/**
|
|
130
|
+
* Generate unique mock entities (no duplicate full names)
|
|
131
|
+
*/
|
|
132
|
+
generateUniqueMockEntities(count: number, options?: {
|
|
133
|
+
gender?: Gender;
|
|
134
|
+
ageRange?: AgeRange;
|
|
135
|
+
}): Array<PersonData & AddressData & PhysicalData & WorkData>;
|
|
96
136
|
}
|
|
97
137
|
|
|
98
138
|
/**
|
|
99
|
-
*
|
|
139
|
+
* Seeded random number generator using Mulberry32 algorithm
|
|
140
|
+
* Provides reproducible random sequences for testing
|
|
100
141
|
*/
|
|
101
142
|
declare class Random {
|
|
143
|
+
private static seedValue;
|
|
102
144
|
/**
|
|
103
|
-
*
|
|
145
|
+
* Initialize seeded random with a specific seed
|
|
146
|
+
* Call this to reproduce the same random sequence
|
|
147
|
+
* @param seed - Number seed for reproducible randomness
|
|
104
148
|
*/
|
|
105
|
-
static
|
|
149
|
+
static seed(seed: number): void;
|
|
150
|
+
/**
|
|
151
|
+
* Reset to native Math.random() (non-deterministic)
|
|
152
|
+
*/
|
|
153
|
+
static unseed(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Get random number (seeded or native)
|
|
156
|
+
*/
|
|
157
|
+
private static random;
|
|
106
158
|
/**
|
|
107
159
|
* Get random integer between min and max (inclusive)
|
|
108
160
|
*/
|
|
@@ -115,10 +167,22 @@ declare class Random {
|
|
|
115
167
|
* Get random boolean
|
|
116
168
|
*/
|
|
117
169
|
static boolean(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get random element from array
|
|
172
|
+
*/
|
|
173
|
+
static pick<T>(array: T[]): T;
|
|
118
174
|
/**
|
|
119
175
|
* Shuffle array (Fisher-Yates algorithm)
|
|
120
176
|
*/
|
|
121
177
|
static shuffle<T>(array: T[]): T[];
|
|
178
|
+
/**
|
|
179
|
+
* Generate multiple random values at once
|
|
180
|
+
*/
|
|
181
|
+
static multiple<T>(generator: () => T, count: number): T[];
|
|
182
|
+
/**
|
|
183
|
+
* Generate unique random values (no duplicates)
|
|
184
|
+
*/
|
|
185
|
+
static unique<T>(generator: () => T, count: number, maxAttempts?: number): T[];
|
|
122
186
|
}
|
|
123
187
|
|
|
124
188
|
/**
|
|
@@ -220,6 +284,63 @@ declare const locales: {
|
|
|
220
284
|
ar_SA: LocaleDefinition;
|
|
221
285
|
ar_EG: LocaleDefinition;
|
|
222
286
|
he_IL: LocaleDefinition;
|
|
287
|
+
uk_UA: LocaleDefinition;
|
|
288
|
+
sk_SK: LocaleDefinition;
|
|
289
|
+
hr_HR: LocaleDefinition;
|
|
290
|
+
rs_RS: LocaleDefinition;
|
|
291
|
+
lt_LT: LocaleDefinition;
|
|
292
|
+
lv_LV: LocaleDefinition;
|
|
293
|
+
et_EE: LocaleDefinition;
|
|
294
|
+
bg_BG: LocaleDefinition;
|
|
295
|
+
is_IS: LocaleDefinition;
|
|
296
|
+
en_NG: LocaleDefinition;
|
|
297
|
+
en_KE: LocaleDefinition;
|
|
298
|
+
en_PK: LocaleDefinition;
|
|
299
|
+
bn_BD: LocaleDefinition;
|
|
300
|
+
fa_IR: LocaleDefinition;
|
|
301
|
+
ar_MA: LocaleDefinition;
|
|
302
|
+
es_CO: LocaleDefinition;
|
|
303
|
+
es_PE: LocaleDefinition;
|
|
304
|
+
es_VE: LocaleDefinition;
|
|
305
|
+
es_GT: LocaleDefinition;
|
|
306
|
+
es_CR: LocaleDefinition;
|
|
307
|
+
zh_TW: LocaleDefinition;
|
|
308
|
+
ar_IQ: LocaleDefinition;
|
|
309
|
+
ar_KW: LocaleDefinition;
|
|
310
|
+
ar_QA: LocaleDefinition;
|
|
311
|
+
ar_BH: LocaleDefinition;
|
|
312
|
+
ar_DZ: LocaleDefinition;
|
|
313
|
+
ar_JO: LocaleDefinition;
|
|
314
|
+
ar_LB: LocaleDefinition;
|
|
315
|
+
ar_LY: LocaleDefinition;
|
|
316
|
+
ar_OM: LocaleDefinition;
|
|
317
|
+
ar_SD: LocaleDefinition;
|
|
318
|
+
ar_SY: LocaleDefinition;
|
|
319
|
+
ar_TN: LocaleDefinition;
|
|
320
|
+
ar_YE: LocaleDefinition;
|
|
321
|
+
en_IE: LocaleDefinition;
|
|
322
|
+
fr_BE: LocaleDefinition;
|
|
323
|
+
fr_CH: LocaleDefinition;
|
|
324
|
+
de_LI: LocaleDefinition;
|
|
325
|
+
de_LU: LocaleDefinition;
|
|
326
|
+
it_CH: LocaleDefinition;
|
|
327
|
+
ca_ES: LocaleDefinition;
|
|
328
|
+
fr_LU: LocaleDefinition;
|
|
329
|
+
fr_CA: LocaleDefinition;
|
|
330
|
+
es_EC: LocaleDefinition;
|
|
331
|
+
es_BO: LocaleDefinition;
|
|
332
|
+
es_PY: LocaleDefinition;
|
|
333
|
+
es_US: LocaleDefinition;
|
|
334
|
+
es_DO: LocaleDefinition;
|
|
335
|
+
zh_HK: LocaleDefinition;
|
|
336
|
+
hi_IN: LocaleDefinition;
|
|
337
|
+
ne_NP: LocaleDefinition;
|
|
338
|
+
ur_PK: LocaleDefinition;
|
|
339
|
+
bn_IN: LocaleDefinition;
|
|
340
|
+
sw_KE: LocaleDefinition;
|
|
341
|
+
sw_TZ: LocaleDefinition;
|
|
342
|
+
af_ZA: LocaleDefinition;
|
|
343
|
+
pt_MZ: LocaleDefinition;
|
|
223
344
|
};
|
|
224
345
|
|
|
225
346
|
export { type AddressData, type AgeRange, type Gender, type LocaleData, type LocaleDefinition, type MetricSystem, Mimic, type PersonData, type PhysicalData, Random, type WorkData, createMimic, createMimic as default, getAllLocaleCodes, getAvailableLocales, localeRegistry, locales };
|