mimic-data 1.0.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/README.md +349 -0
- package/dist/index.d.mts +225 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +10473 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10462 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# mimic-data
|
|
2
|
+
|
|
3
|
+
Library TypeScript ringan tanpa dependency eksternal untuk menghasilkan data dummy yang realistis dengan dukungan lokalisasi yang kuat.
|
|
4
|
+
|
|
5
|
+
## โจ Fitur
|
|
6
|
+
|
|
7
|
+
- ๐ **44 Locale** - Coverage global yang sangat luas
|
|
8
|
+
- ๐ชถ **Ringan** - Zero runtime dependencies
|
|
9
|
+
- ๐ฆ **Tree-shakeable** - Hanya bundle yang Anda gunakan
|
|
10
|
+
- ๐ง **TypeScript Native** - Full type safety
|
|
11
|
+
- ๐ฏ **Mudah Digunakan** - API yang sederhana dan intuitif
|
|
12
|
+
|
|
13
|
+
## ๐ฆ Instalasi
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install mimic-data
|
|
17
|
+
# atau
|
|
18
|
+
yarn add mimic-data
|
|
19
|
+
# atau
|
|
20
|
+
pnpm add mimic-data
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ๐ Penggunaan Dasar
|
|
24
|
+
|
|
25
|
+
### Metode 1: Factory Function (Rekomendasi)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createMimic } from 'mimic-data';
|
|
29
|
+
|
|
30
|
+
// Buat instance dengan locale tertentu
|
|
31
|
+
const mimic = createMimic('id_ID');
|
|
32
|
+
|
|
33
|
+
// Generate data
|
|
34
|
+
console.log(mimic.identity.fullName());
|
|
35
|
+
// Output: "Budi Santoso"
|
|
36
|
+
|
|
37
|
+
console.log(mimic.location.fullAddress());
|
|
38
|
+
// Output: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Metode 2: Class Langsung
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Mimic, locales } from 'mimic-data';
|
|
45
|
+
|
|
46
|
+
const mimic = new Mimic(locales.ja_JP);
|
|
47
|
+
|
|
48
|
+
console.log(mimic.identity.fullName());
|
|
49
|
+
// Output: "Tanaka Kenji"
|
|
50
|
+
|
|
51
|
+
console.log(mimic.location.fullAddress());
|
|
52
|
+
// Output: "ใ123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## ๐ Locale yang Tersedia (44 Negara!)
|
|
56
|
+
|
|
57
|
+
### Americas ๐ (6)
|
|
58
|
+
- `en_US` / `en` / `us` / `usa` - ๐บ๐ธ USA (imperial)
|
|
59
|
+
- `en_CA` / `ca` / `canada` - ๐จ๐ฆ Canada (metric)
|
|
60
|
+
- `es_MX` / `mx` / `mexico` - ๐ฒ๐ฝ Mexico (metric)
|
|
61
|
+
- `pt_BR` / `pt` / `br` / `brazil` - ๐ง๐ท Brazil (metric)
|
|
62
|
+
- `es_AR` / `ar` / `argentina` - ๐ฆ๐ท Argentina (metric)
|
|
63
|
+
- `es_CL` / `cl` / `chile` - ๐จ๐ฑ Chile (metric)
|
|
64
|
+
|
|
65
|
+
### Europe ๐ (19)
|
|
66
|
+
- `en_GB` / `gb` / `uk` / `britain` - ๐ฌ๐ง UK (metric)
|
|
67
|
+
- `de_DE` / `de` / `germany` / `deutsch` - ๐ฉ๐ช Germany (metric)
|
|
68
|
+
- `de_AT` / `at` / `austria` - ๐ฆ๐น Austria (metric)
|
|
69
|
+
- `de_CH` / `ch` / `switzerland` - ๐จ๐ญ Switzerland (metric)
|
|
70
|
+
- `fr_FR` / `fr` / `france` - ๐ซ๐ท France (metric)
|
|
71
|
+
- `it_IT` / `it` / `italy` / `italia` - ๐ฎ๐น Italy (metric)
|
|
72
|
+
- `es_ES` / `es` / `spain` / `espaรฑa` - ๐ช๐ธ Spain (metric)
|
|
73
|
+
- `pt_PT` / `portugal` - ๐ต๐น Portugal (metric)
|
|
74
|
+
- `nl_NL` / `nl` / `netherlands` / `holland` - ๐ณ๐ฑ Netherlands (metric)
|
|
75
|
+
- `nl_BE` / `be` / `belgium` - ๐ง๐ช Belgium (metric)
|
|
76
|
+
- `ru_RU` / `ru` / `russia` - ๐ท๐บ Russia (metric)
|
|
77
|
+
- `pl_PL` / `pl` / `poland` / `polska` - ๐ต๐ฑ Poland (metric)
|
|
78
|
+
- `tr_TR` / `tr` / `turkey` / `turkiye` - ๐น๐ท Turkey (metric)
|
|
79
|
+
- `sv_SE` / `sv` / `se` / `sweden` / `sverige` - ๐ธ๐ช Sweden (metric)
|
|
80
|
+
- `nb_NO` / `no` / `norway` / `norge` - ๐ณ๐ด Norway (metric)
|
|
81
|
+
- `da_DK` / `da` / `dk` / `denmark` / `danmark` - ๐ฉ๐ฐ Denmark (metric)
|
|
82
|
+
- `fi_FI` / `fi` / `finland` / `suomi` - ๐ซ๐ฎ Finland (metric)
|
|
83
|
+
- `el_GR` / `el` / `gr` / `greece` - ๐ฌ๐ท Greece (metric)
|
|
84
|
+
- `cs_CZ` / `cs` / `cz` / `czech` - ๐จ๐ฟ Czech Republic (metric)
|
|
85
|
+
- `hu_HU` / `hu` / `hungary` - ๐ญ๐บ Hungary (metric)
|
|
86
|
+
- `ro_RO` / `ro` / `romania` - ๐ท๐ด Romania (metric)
|
|
87
|
+
|
|
88
|
+
### Asia-Pacific ๐ (13)
|
|
89
|
+
- `zh_CN` / `zh` / `cn` / `china` - ๐จ๐ณ China (metric)
|
|
90
|
+
- `ja_JP` / `ja` / `jp` / `japan` - ๐ฏ๐ต Japan (metric)
|
|
91
|
+
- `ko_KR` / `ko` / `kr` / `korea` - ๐ฐ๐ท South Korea (metric)
|
|
92
|
+
- `en_IN` / `in` / `india` - ๐ฎ๐ณ India (metric)
|
|
93
|
+
- `id_ID` / `id` / `indonesia` - ๐ฎ๐ฉ Indonesia (metric)
|
|
94
|
+
- `th_TH` / `th` / `thailand` - ๐น๐ญ Thailand (metric)
|
|
95
|
+
- `vi_VN` / `vi` / `vn` / `vietnam` - ๐ป๐ณ Vietnam (metric)
|
|
96
|
+
- `ms_MY` / `ms` / `my` / `malaysia` - ๐ฒ๐พ Malaysia (metric)
|
|
97
|
+
- `en_SG` / `sg` / `singapore` - ๐ธ๐ฌ Singapore (metric)
|
|
98
|
+
- `en_PH` / `ph` / `philippines` - ๐ต๐ญ Philippines (metric)
|
|
99
|
+
- `en_AU` / `au` / `aus` / `australia` - ๐ฆ๐บ Australia (metric)
|
|
100
|
+
- `en_NZ` / `nz` / `new-zealand` - ๐ณ๐ฟ New Zealand (metric)
|
|
101
|
+
- `he_IL` / `he` / `il` / `israel` - ๐ฎ๐ฑ Israel (metric)
|
|
102
|
+
|
|
103
|
+
### Middle East & Africa ๐ (6)
|
|
104
|
+
- `ar_AE` / `ae` / `uae` / `emirates` - ๐ฆ๐ช UAE (metric)
|
|
105
|
+
- `ar_SA` / `sa` / `saudi` / `saudi-arabia` - ๐ธ๐ฆ Saudi Arabia (metric)
|
|
106
|
+
- `ar_EG` / `eg` / `egypt` - ๐ช๐ฌ Egypt (metric)
|
|
107
|
+
- `en_ZA` / `za` / `south-africa` - ๐ฟ๐ฆ South Africa (metric)
|
|
108
|
+
|
|
109
|
+
**Total: 44 Locales dengan 120+ Aliases!**
|
|
110
|
+
|
|
111
|
+
## ๐ API Reference
|
|
112
|
+
|
|
113
|
+
### Identity (Identitas)
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// Nama depan berdasarkan gender
|
|
117
|
+
mimic.identity.firstName('male'); // "Takashi"
|
|
118
|
+
mimic.identity.firstName('female'); // "Yuki"
|
|
119
|
+
mimic.identity.firstName(); // Random gender
|
|
120
|
+
|
|
121
|
+
// Nama belakang
|
|
122
|
+
mimic.identity.lastName(); // "Tanaka"
|
|
123
|
+
|
|
124
|
+
// Nama lengkap (format sesuai budaya)
|
|
125
|
+
mimic.identity.fullName('male'); // Japan: "Tanaka Takashi"
|
|
126
|
+
// US: "John Smith"
|
|
127
|
+
// ID: "Budi Santoso"
|
|
128
|
+
|
|
129
|
+
// Gender
|
|
130
|
+
mimic.identity.gender(); // "male" | "female"
|
|
131
|
+
|
|
132
|
+
// Umur dengan range
|
|
133
|
+
mimic.identity.age(); // 18-65 (default)
|
|
134
|
+
mimic.identity.age({ min: 25, max: 40 }); // Custom range
|
|
135
|
+
|
|
136
|
+
// Tanggal lahir
|
|
137
|
+
mimic.identity.dateOfBirth();
|
|
138
|
+
mimic.identity.dateOfBirth({ min: 30, max: 50 });
|
|
139
|
+
|
|
140
|
+
// Generate semua data person sekaligus
|
|
141
|
+
const person = mimic.identity.person('female', { min: 25, max: 35 });
|
|
142
|
+
// {
|
|
143
|
+
// firstName: "Yuki",
|
|
144
|
+
// lastName: "Tanaka",
|
|
145
|
+
// fullName: "Tanaka Yuki",
|
|
146
|
+
// gender: "female",
|
|
147
|
+
// age: 28,
|
|
148
|
+
// dateOfBirth: Date
|
|
149
|
+
// }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Location (Lokasi)
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// Komponen alamat individual
|
|
156
|
+
mimic.location.street(); // "Chuo-dori"
|
|
157
|
+
mimic.location.city(); // "Tokyo"
|
|
158
|
+
mimic.location.state(); // "Kanagawa"
|
|
159
|
+
mimic.location.zipCode(); // "123-4567" (Japan format)
|
|
160
|
+
|
|
161
|
+
// Alamat lengkap (format sesuai negara)
|
|
162
|
+
mimic.location.fullAddress();
|
|
163
|
+
// Japan: "ใ123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
164
|
+
// US: "1234 Main Street, New York, California 12345"
|
|
165
|
+
// ID: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
|
|
166
|
+
|
|
167
|
+
// Generate semua data address sekaligus
|
|
168
|
+
const address = mimic.location.address();
|
|
169
|
+
// {
|
|
170
|
+
// street: "Chuo-dori",
|
|
171
|
+
// city: "Tokyo",
|
|
172
|
+
// state: "Kanagawa",
|
|
173
|
+
// zipCode: "123-4567",
|
|
174
|
+
// fullAddress: "ใ123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
175
|
+
// }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Physical (Data Fisik)
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// Tinggi (unit sesuai locale)
|
|
182
|
+
mimic.physical.height();
|
|
183
|
+
// Metric: { height: 175, weight: 0, heightUnit: 'cm', weightUnit: 'kg' }
|
|
184
|
+
// Imperial: { height: 5.9, weight: 0, heightUnit: 'ft', weightUnit: 'lb' }
|
|
185
|
+
|
|
186
|
+
// Berat (unit sesuai locale)
|
|
187
|
+
mimic.physical.weight();
|
|
188
|
+
// Metric: { height: 0, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
|
|
189
|
+
// Imperial: { height: 0, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
|
|
190
|
+
|
|
191
|
+
// Generate semua data physical sekaligus
|
|
192
|
+
const physical = mimic.physical.data();
|
|
193
|
+
// Metric: { height: 175, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
|
|
194
|
+
// Imperial: { height: 5.9, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Work (Data Pekerjaan)
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
mimic.work.jobTitle(); // "Software Engineer"
|
|
201
|
+
mimic.work.department(); // "Engineering"
|
|
202
|
+
|
|
203
|
+
// Generate semua data work sekaligus
|
|
204
|
+
const work = mimic.work.data();
|
|
205
|
+
// {
|
|
206
|
+
// jobTitle: "Software Engineer",
|
|
207
|
+
// department: "Engineering"
|
|
208
|
+
// }
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Mengganti Locale
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
const mimic = createMimic('en_US');
|
|
215
|
+
console.log(mimic.identity.fullName()); // "John Smith"
|
|
216
|
+
|
|
217
|
+
mimic.setLocale(locales.ja_JP);
|
|
218
|
+
console.log(mimic.identity.fullName()); // "Tanaka Kenji"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## ๐ฏ Contoh Lengkap
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { createMimic } from 'mimic-real-data';
|
|
225
|
+
|
|
226
|
+
// Generate data karyawan Indonesia
|
|
227
|
+
const mimic = createMimic('id_ID');
|
|
228
|
+
|
|
229
|
+
const employee = {
|
|
230
|
+
...mimic.identity.person('male', { min: 25, max: 40 }),
|
|
231
|
+
...mimic.location.address(),
|
|
232
|
+
...mimic.physical.data(),
|
|
233
|
+
...mimic.work.data()
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
console.log(employee);
|
|
237
|
+
// {
|
|
238
|
+
// firstName: "Budi",
|
|
239
|
+
// lastName: "Santoso",
|
|
240
|
+
// fullName: "Budi Santoso",
|
|
241
|
+
// gender: "male",
|
|
242
|
+
// age: 32,
|
|
243
|
+
// dateOfBirth: 1992-05-15T00:00:00.000Z,
|
|
244
|
+
// street: "Jl. Merdeka",
|
|
245
|
+
// city: "Jakarta",
|
|
246
|
+
// state: "DKI Jakarta",
|
|
247
|
+
// zipCode: "12345",
|
|
248
|
+
// fullAddress: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345",
|
|
249
|
+
// height: 175,
|
|
250
|
+
// weight: 70,
|
|
251
|
+
// heightUnit: "cm",
|
|
252
|
+
// weightUnit: "kg",
|
|
253
|
+
// jobTitle: "Software Engineer",
|
|
254
|
+
// department: "Engineering"
|
|
255
|
+
// }
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## ๐ ๏ธ Development
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Install dependencies
|
|
262
|
+
npm install
|
|
263
|
+
|
|
264
|
+
# Build
|
|
265
|
+
npm run build
|
|
266
|
+
|
|
267
|
+
# Development mode (watch)
|
|
268
|
+
npm run dev
|
|
269
|
+
|
|
270
|
+
# Run tests
|
|
271
|
+
npm test
|
|
272
|
+
|
|
273
|
+
# Type check
|
|
274
|
+
npm run type-check
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## ๐ Lisensi
|
|
278
|
+
|
|
279
|
+
MIT
|
|
280
|
+
|
|
281
|
+
## ๐ค Kontribusi
|
|
282
|
+
|
|
283
|
+
Kontribusi sangat diterima! Silakan buka issue atau pull request.
|
|
284
|
+
|
|
285
|
+
### Menambahkan Locale Baru (Sangat Mudah!)
|
|
286
|
+
|
|
287
|
+
Dengan **Registry System**, menambah locale baru sangat mudah:
|
|
288
|
+
|
|
289
|
+
1. **Buat file locale** di `src/locales/xx_XX.ts`
|
|
290
|
+
2. **Implement interface** `LocaleDefinition`
|
|
291
|
+
3. **Import dan register** di `src/index.ts`
|
|
292
|
+
|
|
293
|
+
**Contoh: Menambahkan locale Spanyol**
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// 1. Buat file: src/locales/es_ES.ts
|
|
297
|
+
import { LocaleDefinition } from '../types';
|
|
298
|
+
import { Random } from '../core/random';
|
|
299
|
+
|
|
300
|
+
export const es_ES: LocaleDefinition = {
|
|
301
|
+
firstNamesMale: ['Carlos', 'Josรฉ', 'Antonio', ...],
|
|
302
|
+
firstNamesFemale: ['Marรญa', 'Carmen', 'Ana', ...],
|
|
303
|
+
lastNames: ['Garcรญa', 'Fernรกndez', 'Lรณpez', ...],
|
|
304
|
+
streets: ['Calle Mayor', 'Avenida Castellana', ...],
|
|
305
|
+
cities: ['Madrid', 'Barcelona', 'Valencia', ...],
|
|
306
|
+
states: ['Madrid', 'Cataluรฑa', 'Andalucรญa', ...],
|
|
307
|
+
zipCodePattern: '#####',
|
|
308
|
+
jobTitles: ['Ingeniero de Software', ...],
|
|
309
|
+
departments: ['Ingenierรญa', 'Marketing', ...],
|
|
310
|
+
metricSystem: 'metric',
|
|
311
|
+
|
|
312
|
+
formatFullName(firstName, lastName) {
|
|
313
|
+
return `${firstName} ${lastName}`;
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
formatAddress(street, city, state, zipCode) {
|
|
317
|
+
return `${street} ${Random.int(1, 200)}, ${zipCode} ${city}`;
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
generateZipCode() {
|
|
321
|
+
return String(Random.int(10000, 99999));
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// 2. Register di src/index.ts
|
|
326
|
+
import { es_ES } from './locales/es_ES';
|
|
327
|
+
localeRegistry.register('es_ES', es_ES, ['es', 'spain', 'espaรฑa']);
|
|
328
|
+
|
|
329
|
+
// 3. Export (opsional, untuk advanced usage)
|
|
330
|
+
export const locales = {
|
|
331
|
+
// ... existing locales
|
|
332
|
+
es_ES
|
|
333
|
+
};
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Selesai!** Locale baru Anda langsung tersedia:
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
const mimic = createMimic('es'); // atau 'es_ES' atau 'spain'
|
|
340
|
+
console.log(mimic.identity.fullName()); // "Carlos Garcรญa"
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## ๐ Acknowledgments
|
|
344
|
+
|
|
345
|
+
Terinspirasi oleh library seperti Faker.js, namun dengan fokus pada:
|
|
346
|
+
- Zero runtime dependencies
|
|
347
|
+
- Lokalisasi yang lebih akurat
|
|
348
|
+
- Bundle size yang lebih kecil
|
|
349
|
+
- TypeScript-first approach
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
type Gender = 'male' | 'female';
|
|
2
|
+
type MetricSystem = 'metric' | 'imperial';
|
|
3
|
+
interface PersonData {
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
fullName: string;
|
|
7
|
+
gender: Gender;
|
|
8
|
+
age: number;
|
|
9
|
+
dateOfBirth: Date;
|
|
10
|
+
}
|
|
11
|
+
interface AddressData {
|
|
12
|
+
street: string;
|
|
13
|
+
city: string;
|
|
14
|
+
state: string;
|
|
15
|
+
zipCode: string;
|
|
16
|
+
fullAddress: string;
|
|
17
|
+
}
|
|
18
|
+
interface PhysicalData {
|
|
19
|
+
height: number;
|
|
20
|
+
weight: number;
|
|
21
|
+
heightUnit: 'cm' | 'ft';
|
|
22
|
+
weightUnit: 'kg' | 'lb';
|
|
23
|
+
}
|
|
24
|
+
interface WorkData {
|
|
25
|
+
jobTitle: string;
|
|
26
|
+
department: string;
|
|
27
|
+
}
|
|
28
|
+
interface AgeRange {
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
}
|
|
32
|
+
interface LocaleData {
|
|
33
|
+
firstNamesMale: string[];
|
|
34
|
+
firstNamesFemale: string[];
|
|
35
|
+
lastNames: string[];
|
|
36
|
+
streets: string[];
|
|
37
|
+
cities: string[];
|
|
38
|
+
states: string[];
|
|
39
|
+
zipCodePattern: string;
|
|
40
|
+
jobTitles: string[];
|
|
41
|
+
departments: string[];
|
|
42
|
+
metricSystem: MetricSystem;
|
|
43
|
+
}
|
|
44
|
+
interface LocaleDefinition extends LocaleData {
|
|
45
|
+
formatFullName(firstName: string, lastName: string): string;
|
|
46
|
+
formatAddress(street: string, city: string, state: string, zipCode: string): string;
|
|
47
|
+
generateZipCode(): string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare class Mimic {
|
|
51
|
+
private locale;
|
|
52
|
+
constructor(locale: LocaleDefinition);
|
|
53
|
+
/**
|
|
54
|
+
* Update the locale
|
|
55
|
+
*/
|
|
56
|
+
setLocale(locale: LocaleDefinition): void;
|
|
57
|
+
/**
|
|
58
|
+
* Identity generator
|
|
59
|
+
*/
|
|
60
|
+
get identity(): {
|
|
61
|
+
firstName: (gender?: Gender) => string;
|
|
62
|
+
lastName: () => string;
|
|
63
|
+
fullName: (gender?: Gender) => string;
|
|
64
|
+
gender: () => Gender;
|
|
65
|
+
age: (range?: AgeRange) => number;
|
|
66
|
+
dateOfBirth: (range?: AgeRange) => Date;
|
|
67
|
+
person: (gender?: Gender, ageRange?: AgeRange) => PersonData;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Location generator
|
|
71
|
+
*/
|
|
72
|
+
get location(): {
|
|
73
|
+
street: () => string;
|
|
74
|
+
city: () => string;
|
|
75
|
+
state: () => string;
|
|
76
|
+
zipCode: () => string;
|
|
77
|
+
fullAddress: () => string;
|
|
78
|
+
address: () => AddressData;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Physical data generator
|
|
82
|
+
*/
|
|
83
|
+
get physical(): {
|
|
84
|
+
height: () => PhysicalData;
|
|
85
|
+
weight: () => PhysicalData;
|
|
86
|
+
data: () => PhysicalData;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Work data generator
|
|
90
|
+
*/
|
|
91
|
+
get work(): {
|
|
92
|
+
jobTitle: () => string;
|
|
93
|
+
department: () => string;
|
|
94
|
+
data: () => WorkData;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Random utility functions using native Math.random()
|
|
100
|
+
*/
|
|
101
|
+
declare class Random {
|
|
102
|
+
/**
|
|
103
|
+
* Get random element from array
|
|
104
|
+
*/
|
|
105
|
+
static pick<T>(array: T[]): T;
|
|
106
|
+
/**
|
|
107
|
+
* Get random integer between min and max (inclusive)
|
|
108
|
+
*/
|
|
109
|
+
static int(min: number, max: number): number;
|
|
110
|
+
/**
|
|
111
|
+
* Get random float between min and max
|
|
112
|
+
*/
|
|
113
|
+
static float(min: number, max: number, decimals?: number): number;
|
|
114
|
+
/**
|
|
115
|
+
* Get random boolean
|
|
116
|
+
*/
|
|
117
|
+
static boolean(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Shuffle array (Fisher-Yates algorithm)
|
|
120
|
+
*/
|
|
121
|
+
static shuffle<T>(array: T[]): T[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Locale Registry untuk manajemen locale yang efisien
|
|
126
|
+
* Mendukung lazy loading dan auto-registration
|
|
127
|
+
*/
|
|
128
|
+
declare class LocaleRegistry {
|
|
129
|
+
private locales;
|
|
130
|
+
private aliases;
|
|
131
|
+
/**
|
|
132
|
+
* Register locale baru
|
|
133
|
+
* @param code - Kode locale utama (contoh: 'en_US')
|
|
134
|
+
* @param definition - Definisi locale
|
|
135
|
+
* @param aliasesArray - Array alias untuk locale ini (contoh: ['en', 'us'])
|
|
136
|
+
*/
|
|
137
|
+
register(code: string, definition: LocaleDefinition, aliasesArray?: string[]): void;
|
|
138
|
+
/**
|
|
139
|
+
* Get locale definition
|
|
140
|
+
* @param code - Kode locale atau alias
|
|
141
|
+
* @returns LocaleDefinition atau undefined
|
|
142
|
+
*/
|
|
143
|
+
get(code: string): LocaleDefinition | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Check apakah locale tersedia
|
|
146
|
+
*/
|
|
147
|
+
has(code: string): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Get semua locale yang tersedia
|
|
150
|
+
*/
|
|
151
|
+
getAvailableLocales(): string[];
|
|
152
|
+
/**
|
|
153
|
+
* Get semua aliases yang tersedia
|
|
154
|
+
*/
|
|
155
|
+
getAvailableAliases(): string[];
|
|
156
|
+
/**
|
|
157
|
+
* Get semua kode (locale + aliases)
|
|
158
|
+
*/
|
|
159
|
+
getAllCodes(): string[];
|
|
160
|
+
}
|
|
161
|
+
declare const localeRegistry: LocaleRegistry;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Factory function to create Mimic instance with specified locale
|
|
165
|
+
*/
|
|
166
|
+
declare function createMimic(locale?: string): Mimic;
|
|
167
|
+
/**
|
|
168
|
+
* Get available main locale codes
|
|
169
|
+
*/
|
|
170
|
+
declare function getAvailableLocales(): string[];
|
|
171
|
+
/**
|
|
172
|
+
* Get all codes (locales + aliases)
|
|
173
|
+
*/
|
|
174
|
+
declare function getAllLocaleCodes(): string[];
|
|
175
|
+
/**
|
|
176
|
+
* Export all locale definitions for advanced usage
|
|
177
|
+
*/
|
|
178
|
+
declare const locales: {
|
|
179
|
+
en_US: LocaleDefinition;
|
|
180
|
+
ja_JP: LocaleDefinition;
|
|
181
|
+
id_ID: LocaleDefinition;
|
|
182
|
+
de_DE: LocaleDefinition;
|
|
183
|
+
fr_FR: LocaleDefinition;
|
|
184
|
+
pt_BR: LocaleDefinition;
|
|
185
|
+
ko_KR: LocaleDefinition;
|
|
186
|
+
en_AU: LocaleDefinition;
|
|
187
|
+
zh_CN: LocaleDefinition;
|
|
188
|
+
en_IN: LocaleDefinition;
|
|
189
|
+
es_MX: LocaleDefinition;
|
|
190
|
+
it_IT: LocaleDefinition;
|
|
191
|
+
es_ES: LocaleDefinition;
|
|
192
|
+
nl_NL: LocaleDefinition;
|
|
193
|
+
en_CA: LocaleDefinition;
|
|
194
|
+
en_GB: LocaleDefinition;
|
|
195
|
+
ru_RU: LocaleDefinition;
|
|
196
|
+
pl_PL: LocaleDefinition;
|
|
197
|
+
tr_TR: LocaleDefinition;
|
|
198
|
+
sv_SE: LocaleDefinition;
|
|
199
|
+
nb_NO: LocaleDefinition;
|
|
200
|
+
da_DK: LocaleDefinition;
|
|
201
|
+
fi_FI: LocaleDefinition;
|
|
202
|
+
es_AR: LocaleDefinition;
|
|
203
|
+
es_CL: LocaleDefinition;
|
|
204
|
+
th_TH: LocaleDefinition;
|
|
205
|
+
vi_VN: LocaleDefinition;
|
|
206
|
+
ms_MY: LocaleDefinition;
|
|
207
|
+
en_SG: LocaleDefinition;
|
|
208
|
+
en_PH: LocaleDefinition;
|
|
209
|
+
en_NZ: LocaleDefinition;
|
|
210
|
+
en_ZA: LocaleDefinition;
|
|
211
|
+
pt_PT: LocaleDefinition;
|
|
212
|
+
el_GR: LocaleDefinition;
|
|
213
|
+
cs_CZ: LocaleDefinition;
|
|
214
|
+
de_AT: LocaleDefinition;
|
|
215
|
+
de_CH: LocaleDefinition;
|
|
216
|
+
nl_BE: LocaleDefinition;
|
|
217
|
+
hu_HU: LocaleDefinition;
|
|
218
|
+
ro_RO: LocaleDefinition;
|
|
219
|
+
ar_AE: LocaleDefinition;
|
|
220
|
+
ar_SA: LocaleDefinition;
|
|
221
|
+
ar_EG: LocaleDefinition;
|
|
222
|
+
he_IL: LocaleDefinition;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
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 };
|