mimic-data 1.2.0 → 1.3.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 +450 -412
- package/dist/index.d.mts +134 -11
- package/dist/index.d.ts +134 -11
- package/dist/index.js +31421 -2441
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31421 -2441
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,454 +1,412 @@
|
|
|
1
1
|
# mimic-data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/mimic-data)
|
|
4
|
+
[](https://www.npmjs.com/package/mimic-data)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
A lightweight TypeScript library with zero runtime dependencies for generating realistic, locale-aware dummy data. Inspired by Faker.js, but smaller and focused on accurate localization.
|
|
6
9
|
|
|
7
|
-
|
|
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
|
|
10
|
+
## Features
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
- 🌍 **212 Locales** covering 150+ countries and territories across 6 continents
|
|
13
|
+
- 🪶 **Lightweight** — zero runtime dependencies (~650KB bundled with all locales)
|
|
14
|
+
- 📦 **Tree-shakeable** — import only what you need
|
|
15
|
+
- 🔧 **TypeScript Native** — full type safety with generics
|
|
16
|
+
- 🎯 **Locale-First** — each locale has native-language data, proper address formats, and region-specific phone/zip patterns
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
14
19
|
|
|
15
20
|
```bash
|
|
16
21
|
npm install mimic-data
|
|
17
|
-
#
|
|
22
|
+
# or
|
|
18
23
|
yarn add mimic-data
|
|
19
|
-
#
|
|
24
|
+
# or
|
|
20
25
|
pnpm add mimic-data
|
|
21
26
|
```
|
|
22
27
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
### Metode 1: Factory Function (Rekomendasi)
|
|
28
|
+
## Quick Start
|
|
26
29
|
|
|
27
30
|
```typescript
|
|
28
31
|
import { createMimic } from 'mimic-data';
|
|
29
32
|
|
|
30
|
-
// Buat instance dengan locale tertentu
|
|
31
33
|
const mimic = createMimic('id_ID');
|
|
32
34
|
|
|
33
|
-
// Generate data
|
|
34
35
|
console.log(mimic.identity.fullName());
|
|
35
|
-
//
|
|
36
|
+
// "Budi Santoso"
|
|
36
37
|
|
|
37
38
|
console.log(mimic.location.fullAddress());
|
|
38
|
-
//
|
|
39
|
+
// "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
|
|
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"
|
|
42
|
+
## API Overview
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
// Output: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
53
|
-
```
|
|
44
|
+
### `createMimic(locale?: string): Mimic`
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Americas 🌎 (17)
|
|
58
|
-
- `en_US` / `en` / `us` / `usa` - 🇺🇸 USA (imperial)
|
|
59
|
-
- `es_US` / `es-us` - 🇺🇸 USA (Spanish)
|
|
60
|
-
- `en_CA` / `ca` / `canada` - 🇨🇦 Canada (metric)
|
|
61
|
-
- `fr_CA` / `fr-ca` - 🇨🇦 Canada (French)
|
|
62
|
-
- `es_MX` / `mx` / `mexico` - 🇲🇽 Mexico (metric)
|
|
63
|
-
- `pt_BR` / `pt` / `br` / `brazil` - 🇧🇷 Brazil (metric)
|
|
64
|
-
- `es_AR` / `ar` / `argentina` - 🇦🇷 Argentina (metric)
|
|
65
|
-
- `es_CL` / `cl` / `chile` - 🇨🇱 Chile (metric)
|
|
66
|
-
- `es_CO` / `co` / `colombia` - 🇨🇴 Colombia (metric)
|
|
67
|
-
- `es_PE` / `pe` / `peru` - 🇵🇪 Peru (metric)
|
|
68
|
-
- `es_VE` / `ve` / `venezuela` - 🇻🇪 Venezuela (metric)
|
|
69
|
-
- `es_EC` / `ec` / `ecuador` - 🇪🇨 Ecuador (metric)
|
|
70
|
-
- `es_BO` / `bo` / `bolivia` - 🇧🇴 Bolivia (metric)
|
|
71
|
-
- `es_PY` / `py` / `paraguay` - 🇵🇾 Paraguay (metric)
|
|
72
|
-
- `es_GT` / `gt` / `guatemala` - 🇬🇹 Guatemala (metric)
|
|
73
|
-
- `es_CR` / `cr` / `costa-rica` - 🇨🇷 Costa Rica (metric)
|
|
74
|
-
- `es_DO` / `do` / `dominican-republic` - 🇩🇴 Dominican Republic (metric)
|
|
75
|
-
|
|
76
|
-
### Europe 🌍 (38)
|
|
77
|
-
- `en_GB` / `gb` / `uk` - 🇬🇧 UK (metric)
|
|
78
|
-
- `en_IE` / `ie` / `ireland` - 🇮🇪 Ireland (metric)
|
|
79
|
-
- `de_DE` / `de` / `germany` - 🇩🇪 Germany (metric)
|
|
80
|
-
- `de_AT` / `at` / `austria` - 🇦🇹 Austria (metric)
|
|
81
|
-
- `de_CH` / `ch` / `switzerland` - 🇨🇭 Switzerland (German)
|
|
82
|
-
- `fr_CH` / `fr-ch` - 🇨🇭 Switzerland (French)
|
|
83
|
-
- `it_CH` / `it-ch` - 🇨🇭 Switzerland (Italian)
|
|
84
|
-
- `fr_FR` / `fr` / `france` - 🇫🇷 France (metric)
|
|
85
|
-
- `fr_BE` / `fr-be` - 🇧🇪 Belgium (French)
|
|
86
|
-
- `nl_BE` / `be` / `belgium` - 🇧🇪 Belgium (Dutch)
|
|
87
|
-
- `it_IT` / `it` / `italy` - 🇮🇹 Italy (metric)
|
|
88
|
-
- `es_ES` / `es` / `spain` - 🇪🇸 Spain (metric)
|
|
89
|
-
- `ca_ES` / `ca` / `catalonia` - 🇪🇸 Spain (Catalan)
|
|
90
|
-
- `pt_PT` / `portugal` - 🇵🇹 Portugal (metric)
|
|
91
|
-
- `nl_NL` / `nl` / `netherlands` - 🇳🇱 Netherlands (metric)
|
|
92
|
-
- `de_LU` / `de-lu` - 🇱🇺 Luxembourg (German)
|
|
93
|
-
- `fr_LU` / `fr-lu` - 🇱🇺 Luxembourg (French)
|
|
94
|
-
- `de_LI` / `li` / `liechtenstein` - 🇱🇮 Liechtenstein (metric)
|
|
95
|
-
- `ru_RU` / `ru` / `russia` - 🇷🇺 Russia (metric)
|
|
96
|
-
- `pl_PL` / `pl` / `poland` - 🇵🇱 Poland (metric)
|
|
97
|
-
- `tr_TR` / `tr` / `turkey` - 🇹🇷 Turkey (metric)
|
|
98
|
-
- `sv_SE` / `sv` / `se` / `sweden` - 🇸🇪 Sweden (metric)
|
|
99
|
-
- `nb_NO` / `no` / `norway` - 🇳🇴 Norway (metric)
|
|
100
|
-
- `da_DK` / `da` / `dk` / `denmark` - 🇩🇰 Denmark (metric)
|
|
101
|
-
- `fi_FI` / `fi` / `finland` - 🇫🇮 Finland (metric)
|
|
102
|
-
- `el_GR` / `el` / `gr` / `greece` - 🇬🇷 Greece (metric)
|
|
103
|
-
- `cs_CZ` / `cs` / `cz` / `czech` - 🇨🇿 Czech Republic (metric)
|
|
104
|
-
- `hu_HU` / `hu` / `hungary` - 🇭🇺 Hungary (metric)
|
|
105
|
-
- `ro_RO` / `ro` / `romania` - 🇷🇴 Romania (metric)
|
|
106
|
-
- `uk_UA` / `ua` / `ukraine` - 🇺🇦 Ukraine (metric)
|
|
107
|
-
- `sk_SK` / `sk` / `slovakia` - 🇸🇰 Slovakia (metric)
|
|
108
|
-
- `hr_HR` / `hr` / `croatia` - 🇭🇷 Croatia (metric)
|
|
109
|
-
- `rs_RS` / `rs` / `serbia` - 🇷🇸 Serbia (metric)
|
|
110
|
-
- `lt_LT` / `lt` / `lithuania` - 🇱🇹 Lithuania (metric)
|
|
111
|
-
- `lv_LV` / `lv` / `latvia` - 🇱🇻 Latvia (metric)
|
|
112
|
-
- `et_EE` / `ee` / `estonia` - 🇪🇪 Estonia (metric)
|
|
113
|
-
- `bg_BG` / `bg` / `bulgaria` - 🇧🇬 Bulgaria (metric)
|
|
114
|
-
- `is_IS` / `is` / `iceland` - 🇮🇸 Iceland (metric)
|
|
115
|
-
|
|
116
|
-
### Asia-Pacific 🌏 (20)
|
|
117
|
-
- `zh_CN` / `zh` / `cn` / `china` - 🇨🇳 China (metric)
|
|
118
|
-
- `zh_TW` / `tw` / `taiwan` - 🇹🇼 Taiwan (metric)
|
|
119
|
-
- `zh_HK` / `hk` / `hongkong` - 🇭🇰 Hong Kong (metric)
|
|
120
|
-
- `ja_JP` / `ja` / `jp` / `japan` - 🇯🇵 Japan (metric)
|
|
121
|
-
- `ko_KR` / `ko` / `kr` / `korea` - 🇰🇷 South Korea (metric)
|
|
122
|
-
- `id_ID` / `id` / `indonesia` - 🇮🇩 Indonesia (metric)
|
|
123
|
-
- `ms_MY` / `ms` / `my` / `malaysia` - 🇲🇾 Malaysia (metric)
|
|
124
|
-
- `th_TH` / `th` / `thailand` - 🇹🇭 Thailand (metric)
|
|
125
|
-
- `vi_VN` / `vi` / `vn` / `vietnam` - 🇻🇳 Vietnam (metric)
|
|
126
|
-
- `en_SG` / `sg` / `singapore` - 🇸🇬 Singapore (metric)
|
|
127
|
-
- `en_PH` / `ph` / `philippines` - 🇵🇭 Philippines (metric)
|
|
128
|
-
- `en_AU` / `au` / `australia` - 🇦🇺 Australia (metric)
|
|
129
|
-
- `en_NZ` / `nz` / `new-zealand` - 🇳🇿 New Zealand (metric)
|
|
130
|
-
- `en_IN` / `in` / `india` - 🇮🇳 India (English)
|
|
131
|
-
- `hi_IN` / `hi` / `hindi` - 🇮🇳 India (Hindi)
|
|
132
|
-
- `bn_IN` / `bn-in` - 🇮🇳 India (Bengali)
|
|
133
|
-
- `bn_BD` / `bd` / `bangladesh` - 🇧🇩 Bangladesh (metric)
|
|
134
|
-
- `ne_NP` / `np` / `nepal` - 🇳🇵 Nepal (metric)
|
|
135
|
-
- `ur_PK` / `ur` / `urdu` - 🇵🇰 Pakistan (Urdu)
|
|
136
|
-
- `en_PK` / `pk` / `pakistan` - 🇵🇰 Pakistan (English)
|
|
137
|
-
|
|
138
|
-
### Middle East & Africa 🌍 (26)
|
|
139
|
-
- `ar_SA` / `sa` / `saudi` - 🇸🇦 Saudi Arabia (metric)
|
|
140
|
-
- `ar_AE` / `ae` / `uae` - 🇦🇪 UAE (metric)
|
|
141
|
-
- `ar_EG` / `eg` / `egypt` - 🇪🇬 Egypt (metric)
|
|
142
|
-
- `ar_MA` / `ma` / `morocco` - 🇲🇦 Morocco (metric)
|
|
143
|
-
- `ar_IQ` / `iq` / `iraq` - 🇮🇶 Iraq (metric)
|
|
144
|
-
- `ar_KW` / `kw` / `kuwait` - 🇰🇼 Kuwait (metric)
|
|
145
|
-
- `ar_QA` / `qa` / `qatar` - 🇶🇦 Qatar (metric)
|
|
146
|
-
- `ar_BH` / `bh` / `bahrain` - 🇧🇭 Bahrain (metric)
|
|
147
|
-
- `ar_DZ` / `dz` / `algeria` - 🇩🇿 Algeria (metric)
|
|
148
|
-
- `ar_JO` / `jo` / `jordan` - 🇯🇴 Jordan (metric)
|
|
149
|
-
- `ar_LB` / `lb` / `lebanon` - 🇱🇧 Lebanon (metric)
|
|
150
|
-
- `ar_LY` / `ly` / `libya` - 🇱🇾 Libya (metric)
|
|
151
|
-
- `ar_OM` / `om` / `oman` - 🇴🇲 Oman (metric)
|
|
152
|
-
- `ar_SD` / `sd` / `sudan` - 🇸🇩 Sudan (metric)
|
|
153
|
-
- `ar_SY` / `sy` / `syria` - 🇸🇾 Syria (metric)
|
|
154
|
-
- `ar_TN` / `tn` / `tunisia` - 🇹🇳 Tunisia (metric)
|
|
155
|
-
- `ar_YE` / `ye` / `yemen` - 🇾🇪 Yemen (metric)
|
|
156
|
-
- `he_IL` / `he` / `il` / `israel` - 🇮🇱 Israel (metric)
|
|
157
|
-
- `fa_IR` / `fa` / `iran` - 🇮🇷 Iran (metric)
|
|
158
|
-
- `en_ZA` / `za` / `south-africa` - 🇿🇦 South Africa (English)
|
|
159
|
-
- `af_ZA` / `af` / `afrikaans` - 🇿🇦 South Africa (Afrikaans)
|
|
160
|
-
- `en_NG` / `ng` / `nigeria` - 🇳🇬 Nigeria (metric)
|
|
161
|
-
- `en_KE` / `ke` / `kenya` - 🇰🇪 Kenya (English)
|
|
162
|
-
- `sw_KE` / `sw-ke` - 🇰🇪 Kenya (Swahili)
|
|
163
|
-
- `sw_TZ` / `sw-tz` - 🇹🇿 Tanzania (Swahili)
|
|
164
|
-
- `pt_MZ` / `mz` / `mozambique` - 🇲🇿 Mozambique (metric)
|
|
165
|
-
|
|
166
|
-
**Total: 101 Locale dengan 250+ Aliases!**
|
|
167
|
-
|
|
168
|
-
## 📚 API Reference
|
|
169
|
-
|
|
170
|
-
### Identity (Identitas)
|
|
46
|
+
Creates a Mimic instance for the specified locale. Defaults to `en_US` when omitted.
|
|
171
47
|
|
|
172
48
|
```typescript
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
mimic.identity.firstName('female'); // "Yuki"
|
|
176
|
-
mimic.identity.firstName(); // Random gender
|
|
177
|
-
|
|
178
|
-
// Nama belakang
|
|
179
|
-
mimic.identity.lastName(); // "Tanaka"
|
|
180
|
-
|
|
181
|
-
// Nama lengkap (format sesuai budaya)
|
|
182
|
-
mimic.identity.fullName('male'); // Japan: "Tanaka Takashi"
|
|
183
|
-
// US: "John Smith"
|
|
184
|
-
// ID: "Budi Santoso"
|
|
185
|
-
|
|
186
|
-
// Gender
|
|
187
|
-
mimic.identity.gender(); // "male" | "female"
|
|
188
|
-
|
|
189
|
-
// Umur dengan range
|
|
190
|
-
mimic.identity.age(); // 18-65 (default)
|
|
191
|
-
mimic.identity.age({ min: 25, max: 40 }); // Custom range
|
|
192
|
-
|
|
193
|
-
// Tanggal lahir
|
|
194
|
-
mimic.identity.dateOfBirth();
|
|
195
|
-
mimic.identity.dateOfBirth({ min: 30, max: 50 });
|
|
196
|
-
|
|
197
|
-
// Generate semua data person sekaligus
|
|
198
|
-
const person = mimic.identity.person('female', { min: 25, max: 35 });
|
|
199
|
-
// {
|
|
200
|
-
// firstName: "Yuki",
|
|
201
|
-
// lastName: "Tanaka",
|
|
202
|
-
// fullName: "Tanaka Yuki",
|
|
203
|
-
// gender: "female",
|
|
204
|
-
// age: 28,
|
|
205
|
-
// dateOfBirth: Date
|
|
206
|
-
// }
|
|
207
|
-
|
|
208
|
-
// 🚀 NEW: Generate multiple persons at once
|
|
209
|
-
const persons = mimic.identity.persons(10); // Array of 10 persons
|
|
210
|
-
|
|
211
|
-
// 🚀 NEW: Generate unique persons (no duplicate full names)
|
|
212
|
-
const uniquePersons = mimic.identity.uniquePersons(5);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Location (Lokasi)
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
// Komponen alamat individual
|
|
219
|
-
mimic.location.street(); // "Chuo-dori"
|
|
220
|
-
mimic.location.city(); // "Tokyo"
|
|
221
|
-
mimic.location.state(); // "Kanagawa"
|
|
222
|
-
mimic.location.zipCode(); // "123-4567" (Japan format)
|
|
223
|
-
|
|
224
|
-
// Alamat lengkap (format sesuai negara)
|
|
225
|
-
mimic.location.fullAddress();
|
|
226
|
-
// Japan: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
227
|
-
// US: "1234 Main Street, New York, California 12345"
|
|
228
|
-
// ID: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
|
|
229
|
-
|
|
230
|
-
// Generate semua data address sekaligus
|
|
231
|
-
const address = mimic.location.address();
|
|
232
|
-
// {
|
|
233
|
-
// street: "Chuo-dori",
|
|
234
|
-
// city: "Tokyo",
|
|
235
|
-
// state: "Kanagawa",
|
|
236
|
-
// zipCode: "123-4567",
|
|
237
|
-
// fullAddress: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
238
|
-
// }
|
|
239
|
-
|
|
240
|
-
// 🚀 NEW: Generate multiple addresses at once
|
|
241
|
-
const addresses = mimic.location.addresses(10); // Array of 10 addresses
|
|
242
|
-
|
|
243
|
-
// 🚀 NEW: Generate unique addresses (no duplicate full addresses)
|
|
244
|
-
const uniqueAddresses = mimic.location.uniqueAddresses(5);
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Physical (Data Fisik)
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
// Tinggi (unit sesuai locale)
|
|
251
|
-
mimic.physical.height();
|
|
252
|
-
// Metric: { height: 175, weight: 0, heightUnit: 'cm', weightUnit: 'kg' }
|
|
253
|
-
// Imperial: { height: 5.9, weight: 0, heightUnit: 'ft', weightUnit: 'lb' }
|
|
254
|
-
|
|
255
|
-
// Berat (unit sesuai locale)
|
|
256
|
-
mimic.physical.weight();
|
|
257
|
-
// Metric: { height: 0, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
|
|
258
|
-
// Imperial: { height: 0, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
|
|
259
|
-
|
|
260
|
-
// Generate semua data physical sekaligus
|
|
261
|
-
const physical = mimic.physical.data();
|
|
262
|
-
// Metric: { height: 175, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
|
|
263
|
-
// Imperial: { height: 5.9, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
|
|
264
|
-
|
|
265
|
-
// 🚀 NEW: Generate multiple physical data at once
|
|
266
|
-
const physicals = mimic.physical.datas(10); // Array of 10 physical data
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Work (Data Pekerjaan)
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
mimic.work.jobTitle(); // "Software Engineer"
|
|
273
|
-
mimic.work.department(); // "Engineering"
|
|
274
|
-
|
|
275
|
-
// Generate semua data work sekaligus
|
|
276
|
-
const work = mimic.work.data();
|
|
277
|
-
// {
|
|
278
|
-
// jobTitle: "Software Engineer",
|
|
279
|
-
// department: "Engineering"
|
|
280
|
-
// }
|
|
281
|
-
|
|
282
|
-
// 🚀 NEW: Generate multiple work data at once
|
|
283
|
-
const works = mimic.work.datas(10); // Array of 10 work data
|
|
284
|
-
|
|
285
|
-
// 🚀 NEW: Generate unique job titles
|
|
286
|
-
const uniqueJobTitles = mimic.work.uniqueJobTitles(5);
|
|
287
|
-
|
|
288
|
-
// 🚀 NEW: Generate unique departments
|
|
289
|
-
const uniqueDepartments = mimic.work.uniqueDepartments(3);
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Contact (Kontak) - NEW! 📧
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
// Generate email
|
|
296
|
-
mimic.contact.email('John', 'Doe'); // "john.doe123@gmail.com"
|
|
297
|
-
mimic.contact.email('Jane'); // "jane456@yahoo.com"
|
|
298
|
-
mimic.contact.email(); // "random789@outlook.com"
|
|
299
|
-
|
|
300
|
-
// Generate phone number (locale-specific format)
|
|
301
|
-
mimic.contact.phone(); // US: "+1 (555) 123-4567"
|
|
302
|
-
// ID: "+62 812-3456-7890"
|
|
303
|
-
|
|
304
|
-
// Generate website
|
|
305
|
-
mimic.contact.website(); // "www.acme-corp.com"
|
|
306
|
-
mimic.contact.website('Google');// "www.google.com"
|
|
307
|
-
|
|
308
|
-
// Generate complete contact data
|
|
309
|
-
const contact = mimic.contact.data('John', 'Doe');
|
|
310
|
-
// {
|
|
311
|
-
// email: "john.doe123@gmail.com",
|
|
312
|
-
// phone: "+1 (555) 123-4567",
|
|
313
|
-
// website: "www.john-doe.com"
|
|
314
|
-
// }
|
|
315
|
-
|
|
316
|
-
// 🚀 Generate multiple contact data
|
|
317
|
-
const contacts = mimic.contact.datas(10);
|
|
49
|
+
const mimic = createMimic('ja_JP');
|
|
50
|
+
const mimicDefault = createMimic(); // uses en_US
|
|
318
51
|
```
|
|
319
52
|
|
|
320
|
-
###
|
|
53
|
+
### Module Exports
|
|
54
|
+
|
|
55
|
+
| Export | Description |
|
|
56
|
+
| ----------------------- | -------------------------------------- |
|
|
57
|
+
| `createMimic` | Factory function to create Mimic |
|
|
58
|
+
| `Mimic` | Main data generation class |
|
|
59
|
+
| `locales` | Object with all locale definitions |
|
|
60
|
+
| `Random` | Random number utility class |
|
|
61
|
+
| `localeRegistry` | Locale registry for advanced usage |
|
|
62
|
+
| `getAvailableLocales()` | Returns canonical locale codes |
|
|
63
|
+
| `getAllLocaleCodes()` | Returns locale codes + aliases |
|
|
64
|
+
|
|
65
|
+
### Mimic Methods
|
|
66
|
+
|
|
67
|
+
| Module | Method | Description |
|
|
68
|
+
| ---------- | --------------------------------------------- | -------------------------------------- |
|
|
69
|
+
| `identity` | `firstName(gender?)` | Random first name (male/female/random) |
|
|
70
|
+
| | `lastName()` | Random last name |
|
|
71
|
+
| | `fullName(gender?)` | Full name in locale format |
|
|
72
|
+
| | `gender()` | Random gender |
|
|
73
|
+
| | `age(range?)` | Age (default 18-65) |
|
|
74
|
+
| | `dateOfBirth(range?)` | Date of birth as Date object |
|
|
75
|
+
| | `person(gender?, range?)` | Complete person data |
|
|
76
|
+
| | `persons(count, gender?, range?)` | Multiple persons |
|
|
77
|
+
| | `uniquePersons(count, gender?, range?)` | Unique persons (by full name) |
|
|
78
|
+
| `location` | `street()` | Random street name |
|
|
79
|
+
| | `city()` | Random city |
|
|
80
|
+
| | `state()` | Random state/province |
|
|
81
|
+
| | `zipCode()` | Random zip/postal code |
|
|
82
|
+
| | `fullAddress()` | Formatted full address |
|
|
83
|
+
| | `address()` | Complete address data |
|
|
84
|
+
| | `addresses(count)` | Multiple addresses |
|
|
85
|
+
| | `uniqueAddresses(count)` | Unique addresses |
|
|
86
|
+
| `physical` | `height()` | Height + weight (metric or imperial) |
|
|
87
|
+
| | `weight()` | Weight + height (metric or imperial) |
|
|
88
|
+
| | `data()` | Complete physical data |
|
|
89
|
+
| | `datas(count)` | Multiple physical data |
|
|
90
|
+
| `work` | `jobTitle()` | Random job title |
|
|
91
|
+
| | `department()` | Random department |
|
|
92
|
+
| | `data()` | Complete work data |
|
|
93
|
+
| | `datas(count)` | Multiple work data |
|
|
94
|
+
| | `uniqueJobTitles(count)` | Unique job titles |
|
|
95
|
+
| | `uniqueDepartments(count)` | Unique departments |
|
|
96
|
+
| `contact` | `email(firstName?, lastName?)` | Email address |
|
|
97
|
+
| | `phone()` | Phone number (region-appropriate) |
|
|
98
|
+
| | `website(name?)` | Website URL from company name |
|
|
99
|
+
| | `data(firstName?, lastName?)` | Complete contact data |
|
|
100
|
+
| | `datas(count)` | Multiple contact data |
|
|
101
|
+
| `company` | `name()` | Company name |
|
|
102
|
+
| | `industry()` | Industry |
|
|
103
|
+
| | `catchPhrase()` | Company tagline |
|
|
104
|
+
| | `data()` | Complete company data |
|
|
105
|
+
| | `datas(count)` | Multiple company data |
|
|
106
|
+
| `Mimic` | `setLocale(locale)` | Switch locale |
|
|
107
|
+
| | `generateMockEntities(count, options?)` | Generate complete entities |
|
|
108
|
+
| | `generateUniqueMockEntities(count, options?)` | Unique complete entities |
|
|
109
|
+
|
|
110
|
+
## Available Locales (212 Total)
|
|
111
|
+
|
|
112
|
+
### Americas 🌎 (37) — unchanged
|
|
113
|
+
|
|
114
|
+
- `en_US` / `en` / `us` / `usa` — 🇺🇸 USA (imperial)
|
|
115
|
+
- `es_US` / `es-us` — 🇺🇸 USA (Spanish)
|
|
116
|
+
- `en_CA` / `en-ca` / `canada` — 🇨🇦 Canada (metric)
|
|
117
|
+
- `fr_CA` / `fr-ca` — 🇨🇦 Canada (French)
|
|
118
|
+
- `es_MX` / `mx` / `mexico` — 🇲🇽 Mexico
|
|
119
|
+
- `pt_BR` / `pt` / `br` / `brazil` — 🇧🇷 Brazil
|
|
120
|
+
- `es_AR` / `ar` / `argentina` — 🇦🇷 Argentina
|
|
121
|
+
- `es_CL` / `cl` / `chile` — 🇨🇱 Chile
|
|
122
|
+
- `es_CO` / `co` / `colombia` — 🇨🇴 Colombia
|
|
123
|
+
- `es_PE` / `pe` / `peru` — 🇵🇪 Peru
|
|
124
|
+
- `es_VE` / `ve` / `venezuela` — 🇻🇪 Venezuela
|
|
125
|
+
- `es_EC` / `ec` / `ecuador` — 🇪🇨 Ecuador
|
|
126
|
+
- `es_BO` / `bo` / `bolivia` — 🇧🇴 Bolivia
|
|
127
|
+
- `es_PY` / `py` / `paraguay` — 🇵🇾 Paraguay
|
|
128
|
+
- `es_GT` / `gt` / `guatemala` — 🇬🇹 Guatemala
|
|
129
|
+
- `es_CR` / `cr` / `costa-rica` — 🇨🇷 Costa Rica
|
|
130
|
+
- `es_DO` / `do` / `dominican-republic` — 🇩🇴 Dominican Republic
|
|
131
|
+
- `es_CU` / `cu` / `cuba` — 🇨🇺 Cuba
|
|
132
|
+
- `es_SV` / `es-sv` / `el-salvador` — 🇸🇻 El Salvador
|
|
133
|
+
- `es_HN` / `hn` / `honduras` — 🇭🇳 Honduras
|
|
134
|
+
- `es_NI` / `ni` / `nicaragua` — 🇳🇮 Nicaragua
|
|
135
|
+
- `es_PA` / `pa` / `panama` — 🇵🇦 Panama
|
|
136
|
+
- `es_UY` / `uy` / `uruguay` — 🇺🇾 Uruguay
|
|
137
|
+
- `en_JM` / `jm` / `jamaica` — 🇯🇲 Jamaica
|
|
138
|
+
- `en_TT` / `tt` / `trinidad-and-tobago` — 🇹🇹 Trinidad & Tobago
|
|
139
|
+
- `en_GY` / `gy` / `guyana` — 🇬🇾 Guyana
|
|
140
|
+
- `en_BZ` / `bz` / `belize` — 🇧🇿 Belize
|
|
141
|
+
- `en_BS` / `bs` / `bahamas` — 🇧🇸 Bahamas
|
|
142
|
+
- `en_BB` / `bb` / `barbados` — 🇧🇧 Barbados
|
|
143
|
+
- `en_AG` / `ag` / `antigua-and-barbuda` — 🇦🇬 Antigua & Barbuda
|
|
144
|
+
- `en_DM` / `dm` / `dominica` — 🇩🇲 Dominica
|
|
145
|
+
- `en_GD` / `gd` / `grenada` — 🇬🇩 Grenada
|
|
146
|
+
- `en_KN` / `kn` / `saint-kitts-and-nevis` — 🇰🇳 St. Kitts & Nevis
|
|
147
|
+
- `en_LC` / `lc` / `saint-lucia` — 🇱🇨 St. Lucia
|
|
148
|
+
- `en_VC` / `vc` / `saint-vincent` — 🇻🇨 St. Vincent & Grenadines
|
|
149
|
+
- `fr_HT` / `ht` / `haiti` — 🇭🇹 Haiti
|
|
150
|
+
- `nl_SR` / `sr` / `suriname` — 🇸🇷 Suriname
|
|
151
|
+
|
|
152
|
+
### Europe 🌍 (56)
|
|
153
|
+
|
|
154
|
+
- `en_GB` / `gb` / `uk` — 🇬🇧 UK
|
|
155
|
+
- `en_IE` / `ie` / `ireland` — 🇮🇪 Ireland (English)
|
|
156
|
+
- `ga_IE` / `ga` / `gaeilge` — 🇮🇪 Ireland (Irish Gaelic)
|
|
157
|
+
- `cy_GB` / `cy` / `wales` — 🏴 Wales (Welsh)
|
|
158
|
+
- `de_DE` / `de` / `germany` — 🇩🇪 Germany
|
|
159
|
+
- `de_AT` / `at` / `austria` — 🇦🇹 Austria
|
|
160
|
+
- `de_CH` / `ch` / `switzerland` — 🇨🇭 Switzerland (German)
|
|
161
|
+
- `fr_CH` / `fr-ch` — 🇨🇭 Switzerland (French)
|
|
162
|
+
- `it_CH` / `it-ch` — 🇨🇭 Switzerland (Italian)
|
|
163
|
+
- `fr_FR` / `fr` / `france` — 🇫🇷 France
|
|
164
|
+
- `fr_BE` / `fr-be` — 🇧🇪 Belgium (French)
|
|
165
|
+
- `nl_BE` / `be` / `belgium` — 🇧🇪 Belgium (Dutch)
|
|
166
|
+
- `it_IT` / `it` / `italy` — 🇮🇹 Italy
|
|
167
|
+
- `es_ES` / `es` / `spain` — 🇪🇸 Spain
|
|
168
|
+
- `ca_ES` / `catalonia` / `catalan` — 🇪🇸 Spain (Catalan)
|
|
169
|
+
- `pt_PT` / `portugal` — 🇵🇹 Portugal
|
|
170
|
+
- `nl_NL` / `nl` / `netherlands` — 🇳🇱 Netherlands
|
|
171
|
+
- `de_LU` / `de-lu` — 🇱🇺 Luxembourg (German)
|
|
172
|
+
- `fr_LU` / `fr-lu` — 🇱🇺 Luxembourg (French)
|
|
173
|
+
- `de_LI` / `li` / `liechtenstein` — 🇱🇮 Liechtenstein
|
|
174
|
+
- `ru_RU` / `ru` / `russia` — 🇷🇺 Russia
|
|
175
|
+
- `pl_PL` / `pl` / `poland` — 🇵🇱 Poland
|
|
176
|
+
- `tr_TR` / `tr` / `turkey` — 🇹🇷 Turkey
|
|
177
|
+
- `sv_SE` / `sv` / `se` / `sweden` — 🇸🇪 Sweden
|
|
178
|
+
- `nb_NO` / `no` / `norway` — 🇳🇴 Norway
|
|
179
|
+
- `da_DK` / `da` / `dk` / `denmark` — 🇩🇰 Denmark
|
|
180
|
+
- `fi_FI` / `fi` / `finland` — 🇫🇮 Finland
|
|
181
|
+
- `el_GR` / `el` / `gr` / `greece` — 🇬🇷 Greece
|
|
182
|
+
- `cs_CZ` / `cs` / `cz` / `czech` — 🇨🇿 Czech Republic
|
|
183
|
+
- `hu_HU` / `hu` / `hungary` — 🇭🇺 Hungary
|
|
184
|
+
- `ro_RO` / `ro` / `romania` — 🇷🇴 Romania
|
|
185
|
+
- `uk_UA` / `ua` / `ukraine` — 🇺🇦 Ukraine
|
|
186
|
+
- `sk_SK` / `sk` / `slovakia` — 🇸🇰 Slovakia
|
|
187
|
+
- `hr_HR` / `hr` / `croatia` — 🇭🇷 Croatia
|
|
188
|
+
- `rs_RS` / `rs` / `serbia` — 🇷🇸 Serbia
|
|
189
|
+
- `lt_LT` / `lt` / `lithuania` — 🇱🇹 Lithuania
|
|
190
|
+
- `lv_LV` / `lv` / `latvia` — 🇱🇻 Latvia
|
|
191
|
+
- `et_EE` / `ee` / `estonia` — 🇪🇪 Estonia
|
|
192
|
+
- `bg_BG` / `bg` / `bulgaria` — 🇧🇬 Bulgaria
|
|
193
|
+
- `is_IS` / `is` / `iceland` — 🇮🇸 Iceland
|
|
194
|
+
- `sq_AL` / `al` / `albania` — 🇦🇱 Albania
|
|
195
|
+
- `bs_BA` / `ba` / `bosnia-herzegovina` — 🇧🇦 Bosnia & Herzegovina
|
|
196
|
+
- `mk_MK` / `mk` / `north-macedonia` — 🇲🇰 North Macedonia
|
|
197
|
+
- `sl_SI` / `si` / `slovenia` — 🇸🇮 Slovenia
|
|
198
|
+
- `mt_MT` / `mt` / `malta` — 🇲🇹 Malta
|
|
199
|
+
- `be_BY` / `by` / `belarus` — 🇧🇾 Belarus
|
|
200
|
+
- `sr_ME` / `me` / `montenegro` — 🇲🇪 Montenegro
|
|
201
|
+
- `ro_MD` / `md` / `moldova` — 🇲🇩 Moldova
|
|
202
|
+
- `el_CY` / `el-cy` / `cyprus` — 🇨🇾 Cyprus (Greek)
|
|
203
|
+
- `tr_CY` / `tr-cy` — 🇨🇾 Cyprus (Turkish)
|
|
204
|
+
- `fo_FO` / `fo` / `faroe-islands` — 🇫🇴 Faroe Islands
|
|
205
|
+
- `ca_AD` / `ad` / `andorra` — 🇦🇩 Andorra
|
|
206
|
+
- `fr_MC` / `mc` / `monaco` — 🇲🇨 Monaco
|
|
207
|
+
- `it_SM` / `sm` / `san-marino` — 🇸🇲 San Marino
|
|
208
|
+
- `it_VA` / `va` / `vatican` — 🇻🇦 Vatican City
|
|
209
|
+
- `en_GI` / `gi` / `gibraltar` — 🇬🇮 Gibraltar
|
|
210
|
+
|
|
211
|
+
### Asia-Pacific 🌏 (44)
|
|
212
|
+
|
|
213
|
+
- `zh_CN` / `zh` / `cn` / `china` — 🇨🇳 China
|
|
214
|
+
- `zh_TW` / `tw` / `taiwan` — 🇹🇼 Taiwan
|
|
215
|
+
- `zh_HK` / `hk` / `hongkong` — 🇭🇰 Hong Kong
|
|
216
|
+
- `ja_JP` / `ja` / `jp` / `japan` — 🇯🇵 Japan
|
|
217
|
+
- `ko_KR` / `ko` / `kr` / `korea` — 🇰🇷 South Korea
|
|
218
|
+
- `id_ID` / `id` / `indonesia` — 🇮🇩 Indonesia
|
|
219
|
+
- `ms_MY` / `ms` / `my` / `malaysia` — 🇲🇾 Malaysia
|
|
220
|
+
- `th_TH` / `th` / `thailand` — 🇹🇭 Thailand
|
|
221
|
+
- `vi_VN` / `vi` / `vn` / `vietnam` — 🇻🇳 Vietnam
|
|
222
|
+
- `km_KH` / `kh` / `cambodia` — 🇰🇭 Cambodia
|
|
223
|
+
- `lo_LA` / `la` / `laos` — 🇱🇦 Laos
|
|
224
|
+
- `my_MM` / `mm` / `myanmar` — 🇲🇲 Myanmar
|
|
225
|
+
- `mn_MN` / `mn` / `mongolia` — 🇲🇳 Mongolia
|
|
226
|
+
- `en_SG` / `sg` / `singapore` — 🇸🇬 Singapore
|
|
227
|
+
- `en_PH` / `ph` / `philippines` — 🇵🇭 Philippines
|
|
228
|
+
- `en_AU` / `au` / `australia` — 🇦🇺 Australia
|
|
229
|
+
- `en_NZ` / `nz` / `new-zealand` — 🇳🇿 New Zealand
|
|
230
|
+
- `en_IN` / `in` / `india` — 🇮🇳 India (English)
|
|
231
|
+
- `hi_IN` / `hi` / `hindi` — 🇮🇳 India (Hindi)
|
|
232
|
+
- `bn_IN` / `bn-in` — 🇮🇳 India (Bengali)
|
|
233
|
+
- `si_LK` / `lk` / `sri-lanka` — 🇱🇰 Sri Lanka
|
|
234
|
+
- `bn_BD` / `bd` / `bangladesh` — 🇧🇩 Bangladesh
|
|
235
|
+
- `ne_NP` / `np` / `nepal` — 🇳🇵 Nepal
|
|
236
|
+
- `dz_BT` / `bt` / `bhutan` — 🇧🇹 Bhutan
|
|
237
|
+
- `dv_MV` / `mv` / `maldives` — 🇲🇻 Maldives
|
|
238
|
+
- `ur_PK` / `ur` / `urdu` — 🇵🇰 Pakistan (Urdu)
|
|
239
|
+
- `en_PK` / `pk` / `pakistan` — 🇵🇰 Pakistan (English)
|
|
240
|
+
- `ps_AF` / `af` / `afghanistan` — 🇦🇫 Afghanistan
|
|
241
|
+
- `kk_KZ` / `kz` / `kazakhstan` — 🇰🇿 Kazakhstan
|
|
242
|
+
- `ky_KG` / `kg` / `kyrgyzstan` — 🇰🇬 Kyrgyzstan
|
|
243
|
+
- `tg_TJ` / `tj` / `tajikistan` — 🇹🇯 Tajikistan
|
|
244
|
+
- `tk_TM` / `tm` / `turkmenistan` — 🇹🇲 Turkmenistan
|
|
245
|
+
- `uz_UZ` / `uz` / `uzbekistan` — 🇺🇿 Uzbekistan
|
|
246
|
+
- `ka_GE` / `ge` / `georgia` — 🇬🇪 Georgia
|
|
247
|
+
- `hy_AM` / `hy` / `armenia` — 🇦🇲 Armenia
|
|
248
|
+
- `az_AZ` / `az` / `azerbaijan` — 🇦🇿 Azerbaijan
|
|
249
|
+
- `ms_BN` / `bn` / `brunei` — 🇧🇳 Brunei
|
|
250
|
+
- `pt_TL` / `tl` / `timor-leste` — 🇹🇱 Timor-Leste
|
|
251
|
+
- `zh_MO` / `mo` / `macau` — 🇲🇴 Macau (Chinese)
|
|
252
|
+
- `pt_MO` / `pt-mo` / `macau-portuguese` — 🇲🇴 Macau (Portuguese)
|
|
253
|
+
|
|
254
|
+
### Middle East & Africa 🌍 (75)
|
|
255
|
+
|
|
256
|
+
**Middle East (19):**
|
|
257
|
+
- `ar_SA` / `sa` / `saudi` — 🇸🇦 Saudi Arabia
|
|
258
|
+
- `ar_AE` / `ae` / `uae` — 🇦🇪 UAE
|
|
259
|
+
- `ar_EG` / `eg` / `egypt` — 🇪🇬 Egypt
|
|
260
|
+
- `ar_MA` / `ma` / `morocco` — 🇲🇦 Morocco
|
|
261
|
+
- `ar_DZ` / `dz` / `algeria` — 🇩🇿 Algeria
|
|
262
|
+
- `ar_TN` / `tn` / `tunisia` — 🇹🇳 Tunisia
|
|
263
|
+
- `ar_LY` / `ly` / `libya` — 🇱🇾 Libya
|
|
264
|
+
- `ar_SD` / `sd` / `sudan` — 🇸🇩 Sudan
|
|
265
|
+
- `ar_IQ` / `iq` / `iraq` — 🇮🇶 Iraq
|
|
266
|
+
- `ar_KW` / `kw` / `kuwait` — 🇰🇼 Kuwait
|
|
267
|
+
- `ar_QA` / `qa` / `qatar` — 🇶🇦 Qatar
|
|
268
|
+
- `ar_BH` / `bh` / `bahrain` — 🇧🇭 Bahrain
|
|
269
|
+
- `ar_OM` / `om` / `oman` — 🇴🇲 Oman
|
|
270
|
+
- `ar_YE` / `ye` / `yemen` — 🇾🇪 Yemen
|
|
271
|
+
- `ar_JO` / `jo` / `jordan` — 🇯🇴 Jordan
|
|
272
|
+
- `ar_LB` / `lb` / `lebanon` — 🇱🇧 Lebanon
|
|
273
|
+
- `ar_SY` / `sy` / `syria` — 🇸🇾 Syria
|
|
274
|
+
- `he_IL` / `he` / `il` / `israel` — 🇮🇱 Israel
|
|
275
|
+
- `fa_IR` / `fa` / `iran` — 🇮🇷 Iran
|
|
276
|
+
- `ar_PS` / `ps` / `palestine` — 🇵🇸 Palestine
|
|
277
|
+
- `ar_MR` / `mr` / `mauritania` — 🇲🇷 Mauritania
|
|
278
|
+
|
|
279
|
+
**Sub-Saharan Africa (67):**
|
|
280
|
+
- `en_ZA` / `za` / `south-africa` — 🇿🇦 South Africa (English)
|
|
281
|
+
- `af_ZA` / `af` / `afrikaans` — 🇿🇦 South Africa (Afrikaans)
|
|
282
|
+
- `en_NA` / `na` / `namibia` — 🇳🇦 Namibia
|
|
283
|
+
- `en_BW` / `bw` / `botswana` — 🇧🇼 Botswana
|
|
284
|
+
- `en_ZW` / `zw` / `zimbabwe` — 🇿🇼 Zimbabwe
|
|
285
|
+
- `en_ZM` / `zm` / `zambia` — 🇿🇲 Zambia
|
|
286
|
+
- `en_LS` / `ls` / `lesotho` — 🇱🇸 Lesotho
|
|
287
|
+
- `en_SZ` / `sz` / `eswatini` — 🇸🇿 Eswatini
|
|
288
|
+
- `en_NG` / `ng` / `nigeria` — 🇳🇬 Nigeria
|
|
289
|
+
- `en_GH` / `gh` / `ghana` — 🇬🇭 Ghana
|
|
290
|
+
- `en_SL` / `sl` / `sierra-leone` — 🇸🇱 Sierra Leone
|
|
291
|
+
- `en_LR` / `lr` / `liberia` — 🇱🇷 Liberia
|
|
292
|
+
- `en_GM` / `gm` / `gambia` — 🇬🇲 Gambia
|
|
293
|
+
- `en_UG` / `ug` / `uganda` — 🇺🇬 Uganda
|
|
294
|
+
- `en_KE` / `ke` / `kenya` — 🇰🇪 Kenya (English)
|
|
295
|
+
- `sw_KE` / `sw-ke` — 🇰🇪 Kenya (Swahili)
|
|
296
|
+
- `sw_TZ` / `sw-tz` — 🇹🇿 Tanzania (Swahili)
|
|
297
|
+
- `rw_RW` / `rw` / `rwanda` — 🇷🇼 Rwanda
|
|
298
|
+
- `so_SO` / `so` / `somalia` — 🇸🇴 Somalia
|
|
299
|
+
- `am_ET` / `am` / `ethiopia` — 🇪🇹 Ethiopia
|
|
300
|
+
- `mg_MG` / `mg` / `madagascar` — 🇲🇬 Madagascar
|
|
301
|
+
- `fr_CM` / `cm` / `cameroon` — 🇨🇲 Cameroon
|
|
302
|
+
- `fr_CI` / `ci` / `cote-d-ivoire` — 🇨🇮 Côte d'Ivoire
|
|
303
|
+
- `fr_SN` / `sn` / `senegal` — 🇸🇳 Senegal
|
|
304
|
+
- `fr_ML` / `ml` / `mali` — 🇲🇱 Mali
|
|
305
|
+
- `fr_NE` / `ne` / `niger` — 🇳🇪 Niger
|
|
306
|
+
- `fr_BF` / `bf` / `burkina-faso` — 🇧🇫 Burkina Faso
|
|
307
|
+
- `fr_BJ` / `bj` / `benin` — 🇧🇯 Benin
|
|
308
|
+
- `fr_TG` / `tg` / `togo` — 🇹🇬 Togo
|
|
309
|
+
- `fr_GA` / `ga` / `gabon` — 🇬🇦 Gabon
|
|
310
|
+
- `pt_AO` / `ao` / `angola` — 🇦🇴 Angola
|
|
311
|
+
- `pt_MZ` / `mz` / `mozambique` — 🇲🇿 Mozambique
|
|
312
|
+
- `pt_CV` / `cv` / `cape-verde` — 🇨🇻 Cape Verde
|
|
313
|
+
- `pt_GW` / `gw` / `guinea-bissau` — 🇬🇼 Guinea-Bissau
|
|
314
|
+
- `pt_ST` / `st` / `sao-tome` — 🇸🇹 São Tomé & Príncipe
|
|
315
|
+
- `ar_PS` / `ps` / `palestine` — 🇵🇸 Palestine
|
|
316
|
+
- `ar_MR` / `mr` / `mauritania` — 🇲🇷 Mauritania
|
|
317
|
+
- `ar_KM` / `km` / `comoros` — 🇰🇲 Comoros
|
|
318
|
+
- `ar_DJ` / `dj` / `djibouti` — 🇩🇯 Djibouti
|
|
319
|
+
- `en_MU` / `mu` / `mauritius` — 🇲🇺 Mauritius
|
|
320
|
+
- `fr_SC` / `fr-sc` / `seychelles-french` — 🇸🇨 Seychelles (French)
|
|
321
|
+
- `en_SC` / `sc` / `seychelles` — 🇸🇨 Seychelles (English)
|
|
322
|
+
- `fr_GN` / `gn` / `guinea-conakry` — 🇬🇳 Guinea
|
|
323
|
+
- `es_GQ` / `gq` / `equatorial-guinea` — 🇬🇶 Equatorial Guinea
|
|
324
|
+
- `en_SS` / `ss` / `south-sudan` — 🇸🇸 South Sudan
|
|
325
|
+
- `ti_ER` / `er` / `eritrea` — 🇪🇷 Eritrea
|
|
326
|
+
- `ms_BN` / `bn` / `brunei` — 🇧🇳 Brunei
|
|
327
|
+
- `pt_TL` / `tl` / `timor-leste` — 🇹🇱 Timor-Leste
|
|
328
|
+
- `zh_MO` / `mo` / `macau` — 🇲🇴 Macau (Chinese)
|
|
329
|
+
- `pt_MO` / `pt-mo` / `macau-portuguese` — 🇲🇴 Macau (Portuguese)
|
|
330
|
+
- `ca_AD` / `ad` / `andorra` — 🇦🇩 Andorra
|
|
331
|
+
- `fr_MC` / `mc` / `monaco` — 🇲🇨 Monaco
|
|
332
|
+
- `it_SM` / `sm` / `san-marino` — 🇸🇲 San Marino
|
|
333
|
+
- `it_VA` / `va` / `vatican` — 🇻🇦 Vatican City
|
|
334
|
+
- `en_GI` / `gi` / `gibraltar` — 🇬🇮 Gibraltar
|
|
335
|
+
|
|
336
|
+
## Usage Examples
|
|
337
|
+
|
|
338
|
+
### Basic Usage
|
|
321
339
|
|
|
322
340
|
```typescript
|
|
323
|
-
|
|
324
|
-
mimic.company.name(); // "Techflow Solutions"
|
|
325
|
-
// "PT Telkom Indonesia" (id_ID)
|
|
326
|
-
|
|
327
|
-
// Generate industry
|
|
328
|
-
mimic.company.industry(); // "Technology"
|
|
329
|
-
// "Teknologi" (id_ID)
|
|
341
|
+
import { createMimic } from 'mimic-data';
|
|
330
342
|
|
|
331
|
-
|
|
332
|
-
mimic.company.catchPhrase(); // "Empower innovative solutions"
|
|
343
|
+
const mimic = createMimic('ja_JP');
|
|
333
344
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// {
|
|
337
|
-
// name: "Quantumspark Labs",
|
|
338
|
-
// industry: "Technology",
|
|
339
|
-
// catchPhrase: "Transform cutting-edge experiences"
|
|
340
|
-
// }
|
|
345
|
+
console.log(mimic.identity.fullName());
|
|
346
|
+
// "Tanaka Kenji"
|
|
341
347
|
|
|
342
|
-
|
|
343
|
-
|
|
348
|
+
console.log(mimic.location.fullAddress());
|
|
349
|
+
// "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
|
|
344
350
|
```
|
|
345
351
|
|
|
346
|
-
###
|
|
352
|
+
### Using the Mimic Class Directly
|
|
347
353
|
|
|
348
354
|
```typescript
|
|
349
|
-
|
|
350
|
-
console.log(mimic.identity.fullName()); // "John Smith"
|
|
355
|
+
import { Mimic, locales } from 'mimic-data';
|
|
351
356
|
|
|
352
|
-
mimic
|
|
353
|
-
console.log(mimic.identity.fullName());
|
|
357
|
+
const mimic = new Mimic(locales.de_DE);
|
|
358
|
+
console.log(mimic.identity.fullName('female'));
|
|
359
|
+
// "Maria Müller"
|
|
354
360
|
```
|
|
355
361
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
### 🔁 Seeded Random (Reproducible Data)
|
|
359
|
-
|
|
360
|
-
Generate data yang sama secara konsisten untuk testing:
|
|
362
|
+
### Seeded Random (Reproducible Data)
|
|
361
363
|
|
|
362
364
|
```typescript
|
|
363
365
|
import { createMimic, Random } from 'mimic-data';
|
|
364
366
|
|
|
365
|
-
// Set seed untuk reproducible randomness
|
|
366
367
|
Random.seed(12345);
|
|
367
368
|
|
|
368
369
|
const mimic = createMimic('en_US');
|
|
369
370
|
const person1 = mimic.identity.person('male', { min: 25, max: 35 });
|
|
370
371
|
|
|
371
|
-
// Reset seed yang sama
|
|
372
372
|
Random.seed(12345);
|
|
373
373
|
const person2 = mimic.identity.person('male', { min: 25, max: 35 });
|
|
374
374
|
|
|
375
|
-
// person1 dan person2 akan IDENTIK!
|
|
376
375
|
console.log(person1.fullName === person2.fullName); // true
|
|
377
|
-
console.log(person1.age === person2.age); // true
|
|
378
376
|
|
|
379
|
-
// Reset ke random non-deterministik
|
|
380
377
|
Random.unseed();
|
|
381
378
|
```
|
|
382
379
|
|
|
383
|
-
###
|
|
384
|
-
|
|
385
|
-
Generate banyak data sekaligus dengan performa optimal:
|
|
380
|
+
### Bulk Generation
|
|
386
381
|
|
|
387
382
|
```typescript
|
|
388
383
|
import { createMimic } from 'mimic-data';
|
|
389
384
|
|
|
390
385
|
const mimic = createMimic('id_ID');
|
|
391
386
|
|
|
392
|
-
// Generate 100 persons sekaligus
|
|
393
387
|
const persons = mimic.identity.persons(100);
|
|
394
|
-
|
|
395
|
-
// Generate 50 unique addresses (no duplicates)
|
|
396
388
|
const addresses = mimic.location.uniqueAddresses(50);
|
|
397
389
|
|
|
398
|
-
|
|
399
|
-
const entities = mimic.generateMockEntities(200, {
|
|
390
|
+
const employees = mimic.generateMockEntities(200, {
|
|
400
391
|
gender: 'female',
|
|
401
392
|
ageRange: { min: 20, max: 40 }
|
|
402
393
|
});
|
|
403
|
-
|
|
404
|
-
// Generate unique mock entities
|
|
405
|
-
const uniqueEntities = mimic.generateUniqueMockEntities(100);
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### 🎯 Random Utilities
|
|
409
|
-
|
|
410
|
-
```typescript
|
|
411
|
-
import { Random } from 'mimic-data';
|
|
412
|
-
|
|
413
|
-
// Generate multiple values
|
|
414
|
-
const numbers = Random.multiple(() => Random.int(1, 100), 10);
|
|
415
|
-
|
|
416
|
-
// Generate unique values (no duplicates)
|
|
417
|
-
const uniqueNumbers = Random.unique(() => Random.int(1, 1000), 20);
|
|
418
|
-
|
|
419
|
-
// Shuffle array
|
|
420
|
-
const shuffled = Random.shuffle([1, 2, 3, 4, 5]);
|
|
421
|
-
|
|
422
|
-
// Pick random element
|
|
423
|
-
const randomItem = Random.pick(['apple', 'banana', 'cherry']);
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
### ⚡ Performance Improvements
|
|
427
|
-
|
|
428
|
-
- **Caching**: Generator methods di-cache untuk performa lebih cepat
|
|
429
|
-
- **Bulk Operations**: Generate banyak data dalam satu panggilan
|
|
430
|
-
- **Optimized Getters**: Tidak ada recreation pada setiap akses
|
|
431
|
-
|
|
432
|
-
```typescript
|
|
433
|
-
// Getter methods sekarang di-cache (lebih cepat)
|
|
434
|
-
const identity1 = mimic.identity;
|
|
435
|
-
const identity2 = mimic.identity;
|
|
436
|
-
console.log(identity1 === identity2); // true (same cached instance)
|
|
437
394
|
```
|
|
438
395
|
|
|
439
|
-
|
|
396
|
+
### Complete Employee Record
|
|
440
397
|
|
|
441
398
|
```typescript
|
|
442
399
|
import { createMimic } from 'mimic-data';
|
|
443
400
|
|
|
444
|
-
// Generate data karyawan Indonesia
|
|
445
401
|
const mimic = createMimic('id_ID');
|
|
446
402
|
|
|
447
403
|
const employee = {
|
|
448
404
|
...mimic.identity.person('male', { min: 25, max: 40 }),
|
|
449
405
|
...mimic.location.address(),
|
|
450
406
|
...mimic.physical.data(),
|
|
451
|
-
...mimic.work.data()
|
|
407
|
+
...mimic.work.data(),
|
|
408
|
+
...mimic.contact.data(),
|
|
409
|
+
...mimic.company.data()
|
|
452
410
|
};
|
|
453
411
|
|
|
454
412
|
console.log(employee);
|
|
@@ -469,11 +427,110 @@ console.log(employee);
|
|
|
469
427
|
// heightUnit: "cm",
|
|
470
428
|
// weightUnit: "kg",
|
|
471
429
|
// jobTitle: "Software Engineer",
|
|
472
|
-
// department: "Engineering"
|
|
430
|
+
// department: "Engineering",
|
|
431
|
+
// email: "budi.santoso123@gmail.com",
|
|
432
|
+
// phone: "+62 812-3456-7890",
|
|
433
|
+
// website: "www.budi-santoso.com",
|
|
434
|
+
// name: "Techflow Solutions",
|
|
435
|
+
// industry: "Technology",
|
|
436
|
+
// catchPhrase: "Empower innovative solutions"
|
|
473
437
|
// }
|
|
474
438
|
```
|
|
475
439
|
|
|
476
|
-
##
|
|
440
|
+
## TypeScript Types
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
import {
|
|
444
|
+
Gender,
|
|
445
|
+
MetricSystem,
|
|
446
|
+
PersonData,
|
|
447
|
+
AddressData,
|
|
448
|
+
PhysicalData,
|
|
449
|
+
WorkData,
|
|
450
|
+
ContactData,
|
|
451
|
+
CompanyData,
|
|
452
|
+
AgeRange,
|
|
453
|
+
LocaleDefinition
|
|
454
|
+
} from 'mimic-data';
|
|
455
|
+
|
|
456
|
+
const person: PersonData = mimic.identity.person('female', { min: 25, max: 35 });
|
|
457
|
+
const address: AddressData = mimic.location.address();
|
|
458
|
+
const physical: PhysicalData = mimic.physical.data();
|
|
459
|
+
const work: WorkData = mimic.work.data();
|
|
460
|
+
const contact: ContactData = mimic.contact.data();
|
|
461
|
+
const company: CompanyData = mimic.company.data();
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Type Definitions
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
type Gender = 'male' | 'female';
|
|
468
|
+
type MetricSystem = 'metric' | 'imperial';
|
|
469
|
+
|
|
470
|
+
interface PersonData {
|
|
471
|
+
firstName: string;
|
|
472
|
+
lastName: string;
|
|
473
|
+
fullName: string;
|
|
474
|
+
gender: Gender;
|
|
475
|
+
age: number;
|
|
476
|
+
dateOfBirth: Date;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
interface AddressData {
|
|
480
|
+
street: string;
|
|
481
|
+
city: string;
|
|
482
|
+
state: string;
|
|
483
|
+
zipCode: string;
|
|
484
|
+
fullAddress: string;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
interface PhysicalData {
|
|
488
|
+
height: number;
|
|
489
|
+
weight: number;
|
|
490
|
+
heightUnit: 'cm' | 'ft';
|
|
491
|
+
weightUnit: 'kg' | 'lb';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface WorkData {
|
|
495
|
+
jobTitle: string;
|
|
496
|
+
department: string;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
interface ContactData {
|
|
500
|
+
email: string;
|
|
501
|
+
phone: string;
|
|
502
|
+
website: string;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
interface CompanyData {
|
|
506
|
+
name: string;
|
|
507
|
+
industry: string;
|
|
508
|
+
catchPhrase: string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
interface AgeRange {
|
|
512
|
+
min?: number;
|
|
513
|
+
max?: number;
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## Random Utilities
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
import { Random } from 'mimic-data';
|
|
521
|
+
|
|
522
|
+
Random.seed(12345);
|
|
523
|
+
|
|
524
|
+
Random.int(1, 100);
|
|
525
|
+
Random.float(1.5, 10.5, 2);
|
|
526
|
+
Random.boolean();
|
|
527
|
+
Random.pick(['a', 'b', 'c']);
|
|
528
|
+
Random.shuffle([1, 2, 3, 4, 5]);
|
|
529
|
+
Random.multiple(() => Random.int(1, 100), 10);
|
|
530
|
+
Random.unique(() => Random.int(1, 1000), 20);
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## Development
|
|
477
534
|
|
|
478
535
|
```bash
|
|
479
536
|
# Install dependencies
|
|
@@ -492,76 +549,57 @@ npm test
|
|
|
492
549
|
npm run type-check
|
|
493
550
|
```
|
|
494
551
|
|
|
495
|
-
##
|
|
552
|
+
## License
|
|
496
553
|
|
|
497
554
|
MIT
|
|
498
555
|
|
|
499
|
-
##
|
|
500
|
-
|
|
501
|
-
Kontribusi sangat diterima! Silakan buka issue atau pull request.
|
|
556
|
+
## Contributing
|
|
502
557
|
|
|
503
|
-
|
|
558
|
+
Contributions are welcome! Please open an issue or pull request on [GitHub](https://github.com/fazelnotgg/mimic-data).
|
|
504
559
|
|
|
505
|
-
|
|
560
|
+
### Adding a New Locale
|
|
506
561
|
|
|
507
|
-
1. **
|
|
508
|
-
2. **Implement
|
|
509
|
-
3. **Import
|
|
510
|
-
|
|
511
|
-
**Contoh: Menambahkan locale Spanyol**
|
|
562
|
+
1. **Create a locale file** at `src/locales/xx_XX.ts`
|
|
563
|
+
2. **Implement the `LocaleDefinition`** interface
|
|
564
|
+
3. **Import and register** in `src/index.ts`
|
|
512
565
|
|
|
513
566
|
```typescript
|
|
514
|
-
// 1.
|
|
567
|
+
// 1. Create file: src/locales/es_ES.ts
|
|
515
568
|
import { LocaleDefinition } from '../types';
|
|
516
569
|
import { Random } from '../core/random';
|
|
517
570
|
|
|
518
571
|
export const es_ES: LocaleDefinition = {
|
|
519
|
-
firstNamesMale: ['Carlos', 'José', 'Antonio'
|
|
520
|
-
firstNamesFemale: ['María', 'Carmen', 'Ana'
|
|
521
|
-
lastNames: ['García', 'Fernández', 'López'
|
|
522
|
-
streets: ['Calle Mayor', 'Avenida Castellana'
|
|
523
|
-
cities: ['Madrid', 'Barcelona', 'Valencia'
|
|
524
|
-
states: ['Madrid', 'Cataluña', 'Andalucía'
|
|
572
|
+
firstNamesMale: ['Carlos', 'José', 'Antonio'],
|
|
573
|
+
firstNamesFemale: ['María', 'Carmen', 'Ana'],
|
|
574
|
+
lastNames: ['García', 'Fernández', 'López'],
|
|
575
|
+
streets: ['Calle Mayor', 'Avenida Castellana'],
|
|
576
|
+
cities: ['Madrid', 'Barcelona', 'Valencia'],
|
|
577
|
+
states: ['Madrid', 'Cataluña', 'Andalucía'],
|
|
525
578
|
zipCodePattern: '#####',
|
|
526
|
-
jobTitles: ['Ingeniero de Software'
|
|
527
|
-
departments: ['Ingeniería', 'Marketing'
|
|
579
|
+
jobTitles: ['Ingeniero de Software'],
|
|
580
|
+
departments: ['Ingeniería', 'Marketing'],
|
|
528
581
|
metricSystem: 'metric',
|
|
529
|
-
|
|
530
582
|
formatFullName(firstName, lastName) {
|
|
531
583
|
return `${firstName} ${lastName}`;
|
|
532
584
|
},
|
|
533
|
-
|
|
534
585
|
formatAddress(street, city, state, zipCode) {
|
|
535
586
|
return `${street} ${Random.int(1, 200)}, ${zipCode} ${city}`;
|
|
536
587
|
},
|
|
537
|
-
|
|
538
588
|
generateZipCode() {
|
|
539
589
|
return String(Random.int(10000, 99999));
|
|
540
590
|
}
|
|
541
591
|
};
|
|
542
592
|
|
|
543
|
-
// 2. Register
|
|
593
|
+
// 2. Register in src/index.ts
|
|
544
594
|
import { es_ES } from './locales/es_ES';
|
|
545
595
|
localeRegistry.register('es_ES', es_ES, ['es', 'spain', 'españa']);
|
|
546
|
-
|
|
547
|
-
// 3. Export (opsional, untuk advanced usage)
|
|
548
|
-
export const locales = {
|
|
549
|
-
// ... existing locales
|
|
550
|
-
es_ES
|
|
551
|
-
};
|
|
552
596
|
```
|
|
553
597
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
```typescript
|
|
557
|
-
const mimic = createMimic('es'); // atau 'es_ES' atau 'spain'
|
|
558
|
-
console.log(mimic.identity.fullName()); // "Carlos García"
|
|
559
|
-
```
|
|
598
|
+
## Acknowledgments
|
|
560
599
|
|
|
561
|
-
|
|
600
|
+
Inspired by libraries like Faker.js, with a focus on:
|
|
562
601
|
|
|
563
|
-
Terinspirasi oleh library seperti Faker.js, namun dengan fokus pada:
|
|
564
602
|
- Zero runtime dependencies
|
|
565
|
-
-
|
|
566
|
-
-
|
|
567
|
-
- TypeScript-first
|
|
603
|
+
- Accurate localization for each region
|
|
604
|
+
- Smaller bundle size through tree-shaking
|
|
605
|
+
- TypeScript-first design with full type safety
|