mimic-data 1.1.0 → 1.2.1

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 CHANGED
@@ -1,11 +1,16 @@
1
1
  # mimic-data
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/mimic-data.svg)](https://www.npmjs.com/package/mimic-data)
4
+ [![npm downloads](https://img.shields.io/npm/dt/mimic-data.svg)](https://www.npmjs.com/package/mimic-data)
5
+ [![License](https://img.shields.io/npm/l/m)](https://opensourceimic-data.svg.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.3+-3178c6.svg)](https://www.typescriptlang.org/)
7
+
3
8
  Library TypeScript ringan tanpa dependency eksternal untuk menghasilkan data dummy yang realistis dengan dukungan lokalisasi yang kuat.
4
9
 
5
10
  ## ✨ Fitur
6
11
 
7
- - 🌍 **44 Locale** - Coverage global yang sangat luas
8
- - 🪶 **Ringan** - Zero runtime dependencies
12
+ - 🌍 **101 Locale** - Coverage global yang sangat luas
13
+ - 🪶 **Ringan** - Zero runtime dependencies (~15KB minified)
9
14
  - 📦 **Tree-shakeable** - Hanya bundle yang Anda gunakan
10
15
  - 🔧 **TypeScript Native** - Full type safety
11
16
  - 🎯 **Mudah Digunakan** - API yang sederhana dan intuitif
@@ -20,9 +25,7 @@ yarn add mimic-data
20
25
  pnpm add mimic-data
21
26
  ```
22
27
 
23
- ## 🚀 Penggunaan Dasar
24
-
25
- ### Metode 1: Factory Function (Rekomendasi)
28
+ ## 🚀 Quick Start
26
29
 
27
30
  ```typescript
28
31
  import { createMimic } from 'mimic-data';
@@ -38,81 +41,124 @@ console.log(mimic.location.fullAddress());
38
41
  // Output: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
39
42
  ```
40
43
 
41
- ### Metode 2: Class Langsung
42
-
43
- ```typescript
44
- import { Mimic, locales } from 'mimic-data';
44
+ ## 📚 API Overview
45
45
 
46
- const mimic = new Mimic(locales.ja_JP);
46
+ ### `createMimic(locale?: string): Mimic`
47
+ Buat instance Mimic dengan locale tertentu. Default: `en_US`
47
48
 
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"
49
+ ```typescript
50
+ const mimic = createMimic('ja_JP');
51
+ const mimicDefault = createMimic(); // menggunakan en_US
53
52
  ```
54
53
 
55
- ## 🌏 Locale yang Tersedia (44 Negara!)
56
-
57
- ### Americas 🌎 (6)
54
+ ### Module Exports
55
+
56
+ | Export | Deskripsi |
57
+ |--------|-----------|
58
+ | `createMimic` | Factory function untuk membuat instance Mimic |
59
+ | `Mimic` | Class utama untuk generate data |
60
+ | `locales` | Object semua locale definitions |
61
+ | `Random` | Utility untuk random generation |
62
+ | `localeRegistry` | Registry untuk manage locales |
63
+ | `getAvailableLocales()` | Get semua locale codes utama |
64
+ | `getAllLocaleCodes()` | Get semua locale codes + aliases |
65
+
66
+ ### Mimic Methods
67
+
68
+ | Module | Method | Deskripsi |
69
+ |--------|--------|-----------|
70
+ | `identity` | `firstName(gender?)` | Nama depan (male/female/random) |
71
+ | | `lastName()` | Nama belakang |
72
+ | | `fullName(gender?)` | Nama lengkap (format budaya) |
73
+ | | `gender()` | Gender (male/female) |
74
+ | | `age(range?)` | Umur (default 18-65) |
75
+ | | `dateOfBirth(range?)` | Tanggal lahir |
76
+ | | `person(gender?, range?)` | Semua data person |
77
+ | | `persons(count, gender?, range?)` | Generate multiple persons |
78
+ | | `uniquePersons(count, gender?, range?)` | Generate unique persons |
79
+ | `location` | `street()` | Nama jalan |
80
+ | | `city()` | Kota |
81
+ | | `state()` | Provinsi/State |
82
+ | | `zipCode()` | Kode pos |
83
+ | | `fullAddress()` | Alamat lengkap |
84
+ | | `address()` | Semua data address |
85
+ | | `addresses(count)` | Generate multiple addresses |
86
+ | | `uniqueAddresses(count)` | Generate unique addresses |
87
+ | `physical` | `height()` | Tinggi badan |
88
+ | | `weight()` | Berat badan |
89
+ | | `data()` | Semua data fisik |
90
+ | | `datas(count)` | Generate multiple physical data |
91
+ | `work` | `jobTitle()` | Judul pekerjaan |
92
+ | | `department()` | Departemen |
93
+ | | `data()` | Semua data pekerjaan |
94
+ | | `datas(count)` | Generate multiple work data |
95
+ | | `uniqueJobTitles(count)` | Unique job titles |
96
+ | | `uniqueDepartments(count)` | Unique departments |
97
+ | `contact` | `email(firstName?, lastName?)` | Email address |
98
+ | | `phone()` | Nomor telepon |
99
+ | | `website(name?)` | Website URL |
100
+ | | `data(firstName?, lastName?)` | Semua data kontak |
101
+ | | `datas(count)` | Generate multiple contact data |
102
+ | `company` | `name()` | Nama perusahaan |
103
+ | | `industry()` | Industri |
104
+ | | `catchPhrase()` | Tagline perusahaan |
105
+ | | `data()` | Semua data perusahaan |
106
+ | | `datas(count)` | Generate multiple company data |
107
+ | `Mimic` | `setLocale(locale)` | Ganti locale |
108
+ | | `generateMockEntities(count, options?)` | Generate complete entities |
109
+ | | `generateUniqueMockEntities(count, options?)` | Generate unique entities |
110
+
111
+ ## 🌏 Locale yang Tersedia (101 Locale!)
112
+
113
+ ### Americas 🌎 (17)
58
114
  - `en_US` / `en` / `us` / `usa` - 🇺🇸 USA (imperial)
115
+ - `es_US` / `es-us` - 🇺🇸 USA (Spanish)
59
116
  - `en_CA` / `ca` / `canada` - 🇨🇦 Canada (metric)
117
+ - `fr_CA` / `fr-ca` - 🇨🇦 Canada (French)
60
118
  - `es_MX` / `mx` / `mexico` - 🇲🇽 Mexico (metric)
61
119
  - `pt_BR` / `pt` / `br` / `brazil` - 🇧🇷 Brazil (metric)
62
120
  - `es_AR` / `ar` / `argentina` - 🇦🇷 Argentina (metric)
63
121
  - `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)
122
+ - `es_CO` / `co` / `colombia` - 🇨🇴 Colombia (metric)
123
+ - `es_PE` / `pe` / `peru` - 🇵🇪 Peru (metric)
124
+ - `es_VE` / `ve` / `venezuela` - 🇻🇪 Venezuela (metric)
125
+ - `es_EC` / `ec` / `ecuador` - 🇪🇨 Ecuador (metric)
126
+ - `es_BO` / `bo` / `bolivia` - 🇧🇴 Bolivia (metric)
127
+ - `es_PY` / `py` / `paraguay` - 🇵🇾 Paraguay (metric)
128
+ - `es_GT` / `gt` / `guatemala` - 🇬🇹 Guatemala (metric)
129
+ - `es_CR` / `cr` / `costa-rica` - 🇨🇷 Costa Rica (metric)
130
+ - `es_DO` / `do` / `dominican-republic` - 🇩🇴 Dominican Republic (metric)
131
+
132
+ ### Europe 🌍 (38)
133
+ - `en_GB` / `gb` / `uk` - 🇬🇧 UK (metric)
134
+ - `en_IE` / `ie` / `ireland` - 🇮🇪 Ireland (metric)
135
+ - `de_DE` / `de` / `germany` - 🇩🇪 Germany (metric)
68
136
  - `de_AT` / `at` / `austria` - 🇦🇹 Austria (metric)
69
- - `de_CH` / `ch` / `switzerland` - 🇨🇭 Switzerland (metric)
137
+ - `de_CH` / `ch` / `switzerland` - 🇨🇭 Switzerland (German)
138
+ - `fr_CH` / `fr-ch` - 🇨🇭 Switzerland (French)
139
+ - `it_CH` / `it-ch` - 🇨🇭 Switzerland (Italian)
70
140
  - `fr_FR` / `fr` / `france` - 🇫🇷 France (metric)
71
- - `it_IT` / `it` / `italy` / `italia` - 🇮🇹 Italy (metric)
72
- - `es_ES` / `es` / `spain` / `españa` - 🇪🇸 Spain (metric)
141
+ - `fr_BE` / `fr-be` - 🇧🇪 Belgium (French)
142
+ - `nl_BE` / `be` / `belgium` - 🇧🇪 Belgium (Dutch)
143
+ - `it_IT` / `it` / `italy` - 🇮🇹 Italy (metric)
144
+ - `es_ES` / `es` / `spain` - 🇪🇸 Spain (metric)
145
+ - `ca_ES` / `ca` / `catalonia` - 🇪🇸 Spain (Catalan)
73
146
  - `pt_PT` / `portugal` - 🇵🇹 Portugal (metric)
74
- - `nl_NL` / `nl` / `netherlands` / `holland` - 🇳🇱 Netherlands (metric)
75
- - `nl_BE` / `be` / `belgium` - 🇧🇪 Belgium (metric)
147
+ - `nl_NL` / `nl` / `netherlands` - 🇳🇱 Netherlands (metric)
148
+ - `de_LU` / `de-lu` - 🇱🇺 Luxembourg (German)
149
+ - `fr_LU` / `fr-lu` - 🇱🇺 Luxembourg (French)
150
+ - `de_LI` / `li` / `liechtenstein` - 🇱🇮 Liechtenstein (metric)
76
151
  - `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)
152
+ - `pl_PL` / `pl` / `poland` - 🇵🇱 Poland (metric)
153
+ - `tr_TR` / `tr` / `turkey` - 🇹🇷 Turkey (metric)
154
+ - `sv_SE` / `sv` / `se` / `sweden` - 🇸🇪 Sweden (metric)
155
+ - `nb_NO` / `no` / `norway` - 🇳🇴 Norway (metric)
156
+ - `da_DK` / `da` / `dk` / `denmark` - 🇩🇰 Denmark (metric)
157
+ - `fi_FI` / `fi` / `finland` - 🇫🇮 Finland (metric)
83
158
  - `el_GR` / `el` / `gr` / `greece` - 🇬🇷 Greece (metric)
84
159
  - `cs_CZ` / `cs` / `cz` / `czech` - 🇨🇿 Czech Republic (metric)
85
160
  - `hu_HU` / `hu` / `hungary` - 🇭🇺 Hungary (metric)
86
161
  - `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 🌍 (10)
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
- - `ng_NG` / `ng` / `nigeria` - 🇳🇬 Nigeria (metric)
109
- - `ke_KE` / `ke` / `kenya` - 🇰🇪 Kenya (metric)
110
- - `pk_PK` / `pk` / `pakistan` - 🇵🇰 Pakistan (metric)
111
- - `bd_BD` / `bd` / `bangladesh` - 🇧🇩 Bangladesh (metric)
112
- - `ir_IR` / `ir` / `iran` - 🇮🇷 Iran (metric)
113
- - `ma_MA` / `ma` / `morocco` - 🇲🇦 Morocco (metric)
114
-
115
- ### Eastern Europe 🌍 (9)
116
162
  - `uk_UA` / `ua` / `ukraine` - 🇺🇦 Ukraine (metric)
117
163
  - `sk_SK` / `sk` / `slovakia` - 🇸🇰 Slovakia (metric)
118
164
  - `hr_HR` / `hr` / `croatia` - 🇭🇷 Croatia (metric)
@@ -123,321 +169,132 @@ console.log(mimic.location.fullAddress());
123
169
  - `bg_BG` / `bg` / `bulgaria` - 🇧🇬 Bulgaria (metric)
124
170
  - `is_IS` / `is` / `iceland` - 🇮🇸 Iceland (metric)
125
171
 
126
- ### Americas 🌎 (11)
127
- - `en_US` / `en` / `us` / `usa` - 🇺🇸 USA (imperial)
128
- - `en_CA` / `ca` / `canada` - 🇨🇦 Canada (metric)
129
- - `es_MX` / `mx` / `mexico` - 🇲🇽 Mexico (metric)
130
- - `pt_BR` / `pt` / `br` / `brazil` - 🇧🇷 Brazil (metric)
131
- - `es_AR` / `ar` / `argentina` - 🇦🇷 Argentina (metric)
132
- - `es_CL` / `cl` / `chile` - 🇨🇱 Chile (metric)
133
- - `co_CO` / `co` / `colombia` - 🇨🇴 Colombia (metric)
134
- - `pe_PE` / `pe` / `peru` - 🇵🇪 Peru (metric)
135
- - `ve_VE` / `ve` / `venezuela` - 🇻🇪 Venezuela (metric)
136
- - `gt_GT` / `gt` / `guatemala` - 🇬🇹 Guatemala (metric)
137
- - `cr_CR` / `cr` / `costa-rica` - 🇨🇷 Costa Rica (metric)
138
-
139
- ### Asia-Pacific 🌏 (14)
172
+ ### Asia-Pacific 🌏 (20)
140
173
  - `zh_CN` / `zh` / `cn` / `china` - 🇨🇳 China (metric)
174
+ - `zh_TW` / `tw` / `taiwan` - 🇹🇼 Taiwan (metric)
175
+ - `zh_HK` / `hk` / `hongkong` - 🇭🇰 Hong Kong (metric)
141
176
  - `ja_JP` / `ja` / `jp` / `japan` - 🇯🇵 Japan (metric)
142
177
  - `ko_KR` / `ko` / `kr` / `korea` - 🇰🇷 South Korea (metric)
143
- - `en_IN` / `in` / `india` - 🇮🇳 India (metric)
144
178
  - `id_ID` / `id` / `indonesia` - 🇮🇩 Indonesia (metric)
179
+ - `ms_MY` / `ms` / `my` / `malaysia` - 🇲🇾 Malaysia (metric)
145
180
  - `th_TH` / `th` / `thailand` - 🇹🇭 Thailand (metric)
146
181
  - `vi_VN` / `vi` / `vn` / `vietnam` - 🇻🇳 Vietnam (metric)
147
- - `ms_MY` / `ms` / `my` / `malaysia` - 🇲🇾 Malaysia (metric)
148
182
  - `en_SG` / `sg` / `singapore` - 🇸🇬 Singapore (metric)
149
183
  - `en_PH` / `ph` / `philippines` - 🇵🇭 Philippines (metric)
150
- - `en_AU` / `au` / `aus` / `australia` - 🇦🇺 Australia (metric)
184
+ - `en_AU` / `au` / `australia` - 🇦🇺 Australia (metric)
151
185
  - `en_NZ` / `nz` / `new-zealand` - 🇳🇿 New Zealand (metric)
186
+ - `en_IN` / `in` / `india` - 🇮🇳 India (English)
187
+ - `hi_IN` / `hi` / `hindi` - 🇮🇳 India (Hindi)
188
+ - `bn_IN` / `bn-in` - 🇮🇳 India (Bengali)
189
+ - `bn_BD` / `bd` / `bangladesh` - 🇧🇩 Bangladesh (metric)
190
+ - `ne_NP` / `np` / `nepal` - 🇳🇵 Nepal (metric)
191
+ - `ur_PK` / `ur` / `urdu` - 🇵🇰 Pakistan (Urdu)
192
+ - `en_PK` / `pk` / `pakistan` - 🇵🇰 Pakistan (English)
193
+
194
+ ### Middle East & Africa 🌍 (26)
195
+ - `ar_SA` / `sa` / `saudi` - 🇸🇦 Saudi Arabia (metric)
196
+ - `ar_AE` / `ae` / `uae` - 🇦🇪 UAE (metric)
197
+ - `ar_EG` / `eg` / `egypt` - 🇪🇬 Egypt (metric)
198
+ - `ar_MA` / `ma` / `morocco` - 🇲🇦 Morocco (metric)
199
+ - `ar_IQ` / `iq` / `iraq` - 🇮🇶 Iraq (metric)
200
+ - `ar_KW` / `kw` / `kuwait` - 🇰🇼 Kuwait (metric)
201
+ - `ar_QA` / `qa` / `qatar` - 🇶🇦 Qatar (metric)
202
+ - `ar_BH` / `bh` / `bahrain` - 🇧🇭 Bahrain (metric)
203
+ - `ar_DZ` / `dz` / `algeria` - 🇩🇿 Algeria (metric)
204
+ - `ar_JO` / `jo` / `jordan` - 🇯🇴 Jordan (metric)
205
+ - `ar_LB` / `lb` / `lebanon` - 🇱🇧 Lebanon (metric)
206
+ - `ar_LY` / `ly` / `libya` - 🇱🇾 Libya (metric)
207
+ - `ar_OM` / `om` / `oman` - 🇴🇲 Oman (metric)
208
+ - `ar_SD` / `sd` / `sudan` - 🇸🇩 Sudan (metric)
209
+ - `ar_SY` / `sy` / `syria` - 🇸🇾 Syria (metric)
210
+ - `ar_TN` / `tn` / `tunisia` - 🇹🇳 Tunisia (metric)
211
+ - `ar_YE` / `ye` / `yemen` - 🇾🇪 Yemen (metric)
152
212
  - `he_IL` / `he` / `il` / `israel` - 🇮🇱 Israel (metric)
153
- - `tw_TW` / `tw` / `taiwan` - 🇹🇼 Taiwan (metric)
154
-
155
- **Total: 65 Locales dengan 180+ Aliases!**
156
-
157
- ## 📚 API Reference
158
-
159
- ### Identity (Identitas)
160
-
161
- ```typescript
162
- // Nama depan berdasarkan gender
163
- mimic.identity.firstName('male'); // "Takashi"
164
- mimic.identity.firstName('female'); // "Yuki"
165
- mimic.identity.firstName(); // Random gender
166
-
167
- // Nama belakang
168
- mimic.identity.lastName(); // "Tanaka"
169
-
170
- // Nama lengkap (format sesuai budaya)
171
- mimic.identity.fullName('male'); // Japan: "Tanaka Takashi"
172
- // US: "John Smith"
173
- // ID: "Budi Santoso"
174
-
175
- // Gender
176
- mimic.identity.gender(); // "male" | "female"
177
-
178
- // Umur dengan range
179
- mimic.identity.age(); // 18-65 (default)
180
- mimic.identity.age({ min: 25, max: 40 }); // Custom range
181
-
182
- // Tanggal lahir
183
- mimic.identity.dateOfBirth();
184
- mimic.identity.dateOfBirth({ min: 30, max: 50 });
185
-
186
- // Generate semua data person sekaligus
187
- const person = mimic.identity.person('female', { min: 25, max: 35 });
188
- // {
189
- // firstName: "Yuki",
190
- // lastName: "Tanaka",
191
- // fullName: "Tanaka Yuki",
192
- // gender: "female",
193
- // age: 28,
194
- // dateOfBirth: Date
195
- // }
196
-
197
- // 🚀 NEW: Generate multiple persons at once
198
- const persons = mimic.identity.persons(10); // Array of 10 persons
199
-
200
- // 🚀 NEW: Generate unique persons (no duplicate full names)
201
- const uniquePersons = mimic.identity.uniquePersons(5);
202
- ```
203
-
204
- ### Location (Lokasi)
205
-
206
- ```typescript
207
- // Komponen alamat individual
208
- mimic.location.street(); // "Chuo-dori"
209
- mimic.location.city(); // "Tokyo"
210
- mimic.location.state(); // "Kanagawa"
211
- mimic.location.zipCode(); // "123-4567" (Japan format)
212
-
213
- // Alamat lengkap (format sesuai negara)
214
- mimic.location.fullAddress();
215
- // Japan: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
216
- // US: "1234 Main Street, New York, California 12345"
217
- // ID: "Jl. Merdeka No. 123, RT 5/RW 3, Jakarta, DKI Jakarta 12345"
218
-
219
- // Generate semua data address sekaligus
220
- const address = mimic.location.address();
221
- // {
222
- // street: "Chuo-dori",
223
- // city: "Tokyo",
224
- // state: "Kanagawa",
225
- // zipCode: "123-4567",
226
- // fullAddress: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
227
- // }
228
-
229
- // 🚀 NEW: Generate multiple addresses at once
230
- const addresses = mimic.location.addresses(10); // Array of 10 addresses
231
-
232
- // 🚀 NEW: Generate unique addresses (no duplicate full addresses)
233
- const uniqueAddresses = mimic.location.uniqueAddresses(5);
234
- ```
235
-
236
- ### Physical (Data Fisik)
237
-
238
- ```typescript
239
- // Tinggi (unit sesuai locale)
240
- mimic.physical.height();
241
- // Metric: { height: 175, weight: 0, heightUnit: 'cm', weightUnit: 'kg' }
242
- // Imperial: { height: 5.9, weight: 0, heightUnit: 'ft', weightUnit: 'lb' }
243
-
244
- // Berat (unit sesuai locale)
245
- mimic.physical.weight();
246
- // Metric: { height: 0, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
247
- // Imperial: { height: 0, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
248
-
249
- // Generate semua data physical sekaligus
250
- const physical = mimic.physical.data();
251
- // Metric: { height: 175, weight: 70, heightUnit: 'cm', weightUnit: 'kg' }
252
- // Imperial: { height: 5.9, weight: 154, heightUnit: 'ft', weightUnit: 'lb' }
253
-
254
- // 🚀 NEW: Generate multiple physical data at once
255
- const physicals = mimic.physical.datas(10); // Array of 10 physical data
256
- ```
257
-
258
- ### Work (Data Pekerjaan)
259
-
260
- ```typescript
261
- mimic.work.jobTitle(); // "Software Engineer"
262
- mimic.work.department(); // "Engineering"
263
-
264
- // Generate semua data work sekaligus
265
- const work = mimic.work.data();
266
- // {
267
- // jobTitle: "Software Engineer",
268
- // department: "Engineering"
269
- // }
270
-
271
- // 🚀 NEW: Generate multiple work data at once
272
- const works = mimic.work.datas(10); // Array of 10 work data
273
-
274
- // 🚀 NEW: Generate unique job titles
275
- const uniqueJobTitles = mimic.work.uniqueJobTitles(5);
276
-
277
- // 🚀 NEW: Generate unique departments
278
- const uniqueDepartments = mimic.work.uniqueDepartments(3);
279
- ```
280
-
281
- ### Contact (Kontak) - NEW! 📧
282
-
283
- ```typescript
284
- // Generate email
285
- mimic.contact.email('John', 'Doe'); // "john.doe123@gmail.com"
286
- mimic.contact.email('Jane'); // "jane456@yahoo.com"
287
- mimic.contact.email(); // "random789@outlook.com"
213
+ - `fa_IR` / `fa` / `iran` - 🇮🇷 Iran (metric)
214
+ - `en_ZA` / `za` / `south-africa` - 🇿🇦 South Africa (English)
215
+ - `af_ZA` / `af` / `afrikaans` - 🇿🇦 South Africa (Afrikaans)
216
+ - `en_NG` / `ng` / `nigeria` - 🇳🇬 Nigeria (metric)
217
+ - `en_KE` / `ke` / `kenya` - 🇰🇪 Kenya (English)
218
+ - `sw_KE` / `sw-ke` - 🇰🇪 Kenya (Swahili)
219
+ - `sw_TZ` / `sw-tz` - 🇹🇿 Tanzania (Swahili)
220
+ - `pt_MZ` / `mz` / `mozambique` - 🇲🇿 Mozambique (metric)
288
221
 
289
- // Generate phone number (locale-specific format)
290
- mimic.contact.phone(); // US: "+1 (555) 123-4567"
291
- // ID: "+62 812-3456-7890"
222
+ **Total: 101 Locale dengan 250+ Aliases!**
292
223
 
293
- // Generate website
294
- mimic.contact.website(); // "www.acme-corp.com"
295
- mimic.contact.website('Google');// "www.google.com"
224
+ ## 💻 Contoh Penggunaan
296
225
 
297
- // Generate complete contact data
298
- const contact = mimic.contact.data('John', 'Doe');
299
- // {
300
- // email: "john.doe123@gmail.com",
301
- // phone: "+1 (555) 123-4567",
302
- // website: "www.john-doe.com"
303
- // }
304
-
305
- // 🚀 Generate multiple contact data
306
- const contacts = mimic.contact.datas(10);
307
- ```
308
-
309
- ### Company (Perusahaan) - NEW! 🏢
226
+ ### Penggunaan Dasar
310
227
 
311
228
  ```typescript
312
- // Generate company name
313
- mimic.company.name(); // "Techflow Solutions"
314
- // "PT Telkom Indonesia" (id_ID)
315
-
316
- // Generate industry
317
- mimic.company.industry(); // "Technology"
318
- // "Teknologi" (id_ID)
229
+ import { createMimic } from 'mimic-data';
319
230
 
320
- // Generate catch phrase
321
- mimic.company.catchPhrase(); // "Empower innovative solutions"
231
+ const mimic = createMimic('ja_JP');
322
232
 
323
- // Generate complete company data
324
- const company = mimic.company.data();
325
- // {
326
- // name: "Quantumspark Labs",
327
- // industry: "Technology",
328
- // catchPhrase: "Transform cutting-edge experiences"
329
- // }
233
+ console.log(mimic.identity.fullName());
234
+ // Output: "Tanaka Kenji"
330
235
 
331
- // 🚀 Generate multiple company data
332
- const companies = mimic.company.datas(10);
236
+ console.log(mimic.location.fullAddress());
237
+ // Output: "〒123-4567 Tokyo, Yokohama, Chuo-dori 2-5-10"
333
238
  ```
334
239
 
335
- ### Mengganti Locale
240
+ ### Dengan Class Langsung
336
241
 
337
242
  ```typescript
338
- const mimic = createMimic('en_US');
339
- console.log(mimic.identity.fullName()); // "John Smith"
243
+ import { Mimic, locales } from 'mimic-data';
340
244
 
341
- mimic.setLocale(locales.ja_JP);
342
- console.log(mimic.identity.fullName()); // "Tanaka Kenji"
245
+ const mimic = new Mimic(locales.de_DE);
246
+ console.log(mimic.identity.fullName('female'));
247
+ // Output: "Maria Müller"
343
248
  ```
344
249
 
345
- ## 🚀 Fitur Baru (v1.1.0)
346
-
347
- ### 🔁 Seeded Random (Reproducible Data)
348
-
349
- Generate data yang sama secara konsisten untuk testing:
250
+ ### Seeded Random (Reproducible Data)
350
251
 
351
252
  ```typescript
352
253
  import { createMimic, Random } from 'mimic-data';
353
254
 
354
- // Set seed untuk reproducible randomness
355
255
  Random.seed(12345);
356
256
 
357
257
  const mimic = createMimic('en_US');
358
258
  const person1 = mimic.identity.person('male', { min: 25, max: 35 });
359
259
 
360
- // Reset seed yang sama
361
260
  Random.seed(12345);
362
261
  const person2 = mimic.identity.person('male', { min: 25, max: 35 });
363
262
 
364
- // person1 dan person2 akan IDENTIK!
365
263
  console.log(person1.fullName === person2.fullName); // true
366
- console.log(person1.age === person2.age); // true
367
264
 
368
- // Reset ke random non-deterministik
369
265
  Random.unseed();
370
266
  ```
371
267
 
372
- ### 📦 Bulk Generation
373
-
374
- Generate banyak data sekaligus dengan performa optimal:
268
+ ### Bulk Generation
375
269
 
376
270
  ```typescript
377
271
  import { createMimic } from 'mimic-data';
378
272
 
379
273
  const mimic = createMimic('id_ID');
380
274
 
381
- // Generate 100 persons sekaligus
382
275
  const persons = mimic.identity.persons(100);
383
-
384
- // Generate 50 unique addresses (no duplicates)
385
276
  const addresses = mimic.location.uniqueAddresses(50);
386
277
 
387
- // Generate 200 complete mock entities
388
- const entities = mimic.generateMockEntities(200, {
278
+ const employees = mimic.generateMockEntities(200, {
389
279
  gender: 'female',
390
280
  ageRange: { min: 20, max: 40 }
391
281
  });
392
-
393
- // Generate unique mock entities
394
- const uniqueEntities = mimic.generateUniqueMockEntities(100);
395
282
  ```
396
283
 
397
- ### 🎯 Random Utilities
398
-
399
- ```typescript
400
- import { Random } from 'mimic-data';
401
-
402
- // Generate multiple values
403
- const numbers = Random.multiple(() => Random.int(1, 100), 10);
404
-
405
- // Generate unique values (no duplicates)
406
- const uniqueNumbers = Random.unique(() => Random.int(1, 1000), 20);
407
-
408
- // Shuffle array
409
- const shuffled = Random.shuffle([1, 2, 3, 4, 5]);
410
-
411
- // Pick random element
412
- const randomItem = Random.pick(['apple', 'banana', 'cherry']);
413
- ```
414
-
415
- ### ⚡ Performance Improvements
416
-
417
- - **Caching**: Generator methods di-cache untuk performa lebih cepat
418
- - **Bulk Operations**: Generate banyak data dalam satu panggilan
419
- - **Optimized Getters**: Tidak ada recreation pada setiap akses
420
-
421
- ```typescript
422
- // Getter methods sekarang di-cache (lebih cepat)
423
- const identity1 = mimic.identity;
424
- const identity2 = mimic.identity;
425
- console.log(identity1 === identity2); // true (same cached instance)
426
- ```
427
-
428
- ## 🎯 Contoh Lengkap
284
+ ### Complete Employee Data
429
285
 
430
286
  ```typescript
431
287
  import { createMimic } from 'mimic-data';
432
288
 
433
- // Generate data karyawan Indonesia
434
289
  const mimic = createMimic('id_ID');
435
290
 
436
291
  const employee = {
437
292
  ...mimic.identity.person('male', { min: 25, max: 40 }),
438
293
  ...mimic.location.address(),
439
294
  ...mimic.physical.data(),
440
- ...mimic.work.data()
295
+ ...mimic.work.data(),
296
+ ...mimic.contact.data(),
297
+ ...mimic.company.data()
441
298
  };
442
299
 
443
300
  console.log(employee);
@@ -458,10 +315,109 @@ console.log(employee);
458
315
  // heightUnit: "cm",
459
316
  // weightUnit: "kg",
460
317
  // jobTitle: "Software Engineer",
461
- // department: "Engineering"
318
+ // department: "Engineering",
319
+ // email: "budi.santoso123@gmail.com",
320
+ // phone: "+62 812-3456-7890",
321
+ // website: "www.budi-santoso.com",
322
+ // name: "Techflow Solutions",
323
+ // industry: "Technology",
324
+ // catchPhrase: "Empower innovative solutions"
462
325
  // }
463
326
  ```
464
327
 
328
+ ## 🔧 TypeScript Types
329
+
330
+ ```typescript
331
+ import {
332
+ Gender,
333
+ MetricSystem,
334
+ PersonData,
335
+ AddressData,
336
+ PhysicalData,
337
+ WorkData,
338
+ ContactData,
339
+ CompanyData,
340
+ AgeRange,
341
+ LocaleDefinition
342
+ } from 'mimic-data';
343
+
344
+ const person: PersonData = mimic.identity.person('female', { min: 25, max: 35 });
345
+ const address: AddressData = mimic.location.address();
346
+ const physical: PhysicalData = mimic.physical.data();
347
+ const work: WorkData = mimic.work.data();
348
+ const contact: ContactData = mimic.contact.data();
349
+ const company: CompanyData = mimic.company.data();
350
+ ```
351
+
352
+ ### Type Definitions
353
+
354
+ ```typescript
355
+ type Gender = 'male' | 'female';
356
+ type MetricSystem = 'metric' | 'imperial';
357
+
358
+ interface PersonData {
359
+ firstName: string;
360
+ lastName: string;
361
+ fullName: string;
362
+ gender: Gender;
363
+ age: number;
364
+ dateOfBirth: Date;
365
+ }
366
+
367
+ interface AddressData {
368
+ street: string;
369
+ city: string;
370
+ state: string;
371
+ zipCode: string;
372
+ fullAddress: string;
373
+ }
374
+
375
+ interface PhysicalData {
376
+ height: number;
377
+ weight: number;
378
+ heightUnit: 'cm' | 'ft';
379
+ weightUnit: 'kg' | 'lb';
380
+ }
381
+
382
+ interface WorkData {
383
+ jobTitle: string;
384
+ department: string;
385
+ }
386
+
387
+ interface ContactData {
388
+ email: string;
389
+ phone: string;
390
+ website: string;
391
+ }
392
+
393
+ interface CompanyData {
394
+ name: string;
395
+ industry: string;
396
+ catchPhrase: string;
397
+ }
398
+
399
+ interface AgeRange {
400
+ min?: number;
401
+ max?: number;
402
+ }
403
+ ```
404
+
405
+ ## 🎲 Random Utilities
406
+
407
+ ```typescript
408
+ import { Random } from 'mimic-data';
409
+
410
+ Random.seed(12345);
411
+
412
+ Random.int(1, 100);
413
+ Random.float(1.5, 10.5, 2);
414
+ Random.boolean();
415
+ Random.pick(['a', 'b', 'c']);
416
+ Random.shuffle([1, 2, 3, 4, 5]);
417
+ Random.multiple(() => Random.int(1, 100), 10);
418
+ Random.unique(() => Random.int(1, 1000), 20);
419
+ ```
420
+
465
421
  ## 🛠️ Development
466
422
 
467
423
  ```bash
@@ -489,7 +445,7 @@ MIT
489
445
 
490
446
  Kontribusi sangat diterima! Silakan buka issue atau pull request.
491
447
 
492
- ### Menambahkan Locale Baru (Sangat Mudah!)
448
+ ### Menambahkan Locale Baru
493
449
 
494
450
  Dengan **Registry System**, menambah locale baru sangat mudah:
495
451
 
@@ -497,33 +453,28 @@ Dengan **Registry System**, menambah locale baru sangat mudah:
497
453
  2. **Implement interface** `LocaleDefinition`
498
454
  3. **Import dan register** di `src/index.ts`
499
455
 
500
- **Contoh: Menambahkan locale Spanyol**
501
-
502
456
  ```typescript
503
457
  // 1. Buat file: src/locales/es_ES.ts
504
458
  import { LocaleDefinition } from '../types';
505
459
  import { Random } from '../core/random';
506
460
 
507
461
  export const es_ES: LocaleDefinition = {
508
- firstNamesMale: ['Carlos', 'José', 'Antonio', ...],
509
- firstNamesFemale: ['María', 'Carmen', 'Ana', ...],
510
- lastNames: ['García', 'Fernández', 'López', ...],
511
- streets: ['Calle Mayor', 'Avenida Castellana', ...],
512
- cities: ['Madrid', 'Barcelona', 'Valencia', ...],
513
- states: ['Madrid', 'Cataluña', 'Andalucía', ...],
462
+ firstNamesMale: ['Carlos', 'José', 'Antonio'],
463
+ firstNamesFemale: ['María', 'Carmen', 'Ana'],
464
+ lastNames: ['García', 'Fernández', 'López'],
465
+ streets: ['Calle Mayor', 'Avenida Castellana'],
466
+ cities: ['Madrid', 'Barcelona', 'Valencia'],
467
+ states: ['Madrid', 'Cataluña', 'Andalucía'],
514
468
  zipCodePattern: '#####',
515
- jobTitles: ['Ingeniero de Software', ...],
516
- departments: ['Ingeniería', 'Marketing', ...],
469
+ jobTitles: ['Ingeniero de Software'],
470
+ departments: ['Ingeniería', 'Marketing'],
517
471
  metricSystem: 'metric',
518
-
519
472
  formatFullName(firstName, lastName) {
520
473
  return `${firstName} ${lastName}`;
521
474
  },
522
-
523
475
  formatAddress(street, city, state, zipCode) {
524
476
  return `${street} ${Random.int(1, 200)}, ${zipCode} ${city}`;
525
477
  },
526
-
527
478
  generateZipCode() {
528
479
  return String(Random.int(10000, 99999));
529
480
  }
@@ -532,19 +483,6 @@ export const es_ES: LocaleDefinition = {
532
483
  // 2. Register di src/index.ts
533
484
  import { es_ES } from './locales/es_ES';
534
485
  localeRegistry.register('es_ES', es_ES, ['es', 'spain', 'españa']);
535
-
536
- // 3. Export (opsional, untuk advanced usage)
537
- export const locales = {
538
- // ... existing locales
539
- es_ES
540
- };
541
- ```
542
-
543
- **Selesai!** Locale baru Anda langsung tersedia:
544
-
545
- ```typescript
546
- const mimic = createMimic('es'); // atau 'es_ES' atau 'spain'
547
- console.log(mimic.identity.fullName()); // "Carlos García"
548
486
  ```
549
487
 
550
488
  ## 🙏 Acknowledgments
@@ -553,4 +491,4 @@ Terinspirasi oleh library seperti Faker.js, namun dengan fokus pada:
553
491
  - Zero runtime dependencies
554
492
  - Lokalisasi yang lebih akurat
555
493
  - Bundle size yang lebih kecil
556
- - TypeScript-first approach
494
+ - TypeScript-first approach