Usage
Creating a Mimic Instance
Use the createMimic factory function with a locale code:
import { createMimic } from '@fazelstudio/mimic-data';
// Indonesian locale
const mimic = createMimic('id_ID');
// Defaults to 'en_US' if no locale is provided
const defaultMimic = createMimic();
Identity Module
mimic.identity.firstName(); // "Budi"
mimic.identity.lastName(); // "Santoso"
mimic.identity.fullName(); // "Budi Santoso"
mimic.identity.gender(); // "male"
mimic.identity.age(); // 32
mimic.identity.dateOfBirth(); // 1992-03-15T00:00:00.000Z
mimic.identity.person('male', { min: 25, max: 40 });
// { firstName: 'Budi', lastName: 'Santoso', gender: 'male', age: 32, dateOfBirth: ... }
Location Module
mimic.location.street(); // "Jl. Merdeka No. 42"
mimic.location.city(); // "Jakarta Pusat"
mimic.location.state(); // "DKI Jakarta"
mimic.location.zipCode(); // "10110"
mimic.location.fullAddress(); // "Jl. Merdeka No. 42, Jakarta Pusat, DKI Jakarta 10110"
mimic.location.address(); // { street, city, state, zipCode, fullAddress }
Physical Module
Respects the locale's measurement system (metric vs. imperial):
mimic.physical.height(); // 170 (cm) for metric locales
mimic.physical.weight(); // 65 (kg) for metric locales
mimic.physical.data(); // { height, weight, heightUnit, weightUnit }
Work Module
mimic.work.jobTitle(); // "Software Engineer"
mimic.work.department(); // "Engineering"
mimic.work.data(); // { jobTitle, department }
Contact Module
mimic.contact.email(); // "budi.santoso@example.com"
mimic.contact.phone(); // "+62-21-5555-1234"
mimic.contact.website(); // "https://example.com"
mimic.contact.data(); // { email, phone, website }
Company Module
mimic.company.name(); // "PT Teknologi Maju"
mimic.company.industry(); // "Technology"
mimic.company.catchPhrase(); // "Innovating the future"
mimic.company.data(); // { name, industry, catchPhrase }
Bulk Generation
const persons = mimic.identity.persons(5);
const addresses = mimic.location.addresses(3);
Unique Generation
const unique = mimic.identity.uniquePersons(10);
Mock Entities
Combine all modules into a single object:
const employee = mimic.generateMockEntities(1);
const employees = mimic.generateMockEntities(5, {
gender: 'male',
ageRange: { min: 25, max: 40 },
});
Seeded Random
For reproducible test data:
import { Random } from '@fazelstudio/mimic-data';
Random.seed(12345);
// All subsequent calls are deterministic
Random.unseed();
// Reverts to Math.random()
Runtime Locale Switching
mimic.setLocale('ja_JP');
// All cached generators are cleared and re-initialized