Data uji (fake)
- 3174081502956104
- 5321124709513217
- 3603145212584822
- 7102226209055152
- 3471126703912239
Seed yang sama memberi hasil yang sama di Go dan TypeScript. Hanya untuk pengujian.
Jalan di browser kamu.
Setiap generator menerima seed 32-bit (uint32 di Go, bilangan bulat 0 sampai 4.294.967.295 di TypeScript). Seed dan opsi yang sama memberi hasil yang sama di Go dan TypeScript, jadi fixture bisa dipakai bareng oleh backend Go dan frontend TypeScript.
Fungsi
Section titled “Fungsi”| Go | TypeScript | Opsi |
|---|---|---|
fake.NIK(seed, opts) |
await fake.nik(seed, opts?) |
region, birthDate, sex |
fake.NPWP(seed) |
fake.npwp(seed) |
|
fake.Phone(seed) |
fake.phone(seed) |
|
fake.NIP(seed, opts) |
fake.nip(seed, opts?) |
birthDate, sex |
fake.NISN(seed) |
fake.nisn(seed) |
|
fake.Plate(seed, opts) |
fake.plate(seed, opts?) |
region (kode plat seperti B) |
- NIK memakai kode kecamatan yang nyata.
regionbisa mengunci ke provinsi (31), kabupaten/kota (31.71), atau kecamatan (31.71.01).birthDate(YYYY-MM-DD) dansex(maleataufemale) menentukan tanggal dan tambahan +40 untuk perempuan. - Di TypeScript
fakehanya diekspor darinusaindex/fake, tidak dari root, supaya tidak ikut masuk ke bundle produksi.fake.nikbersifat async karena data kecamatan dimuat per provinsi. - Go mengembalikan
stringuntuk generator tanpa opsi. TypeScript selalu mengembalikanResult, yang gagal denganoptionskalau seed-nya tidak valid.
Perubahan data wilayah bisa mengubah NIK yang dihasilkan untuk seed yang sama. Kunci versi NusaIndex kalau test-mu membandingkan nilai persis.
options, date, region.
Contoh
Section titled “Contoh”package main
import ( "fmt"
"github.com/haikalmumtaz233/nusaindex/fake")
func main() { id, err := fake.NIK(7, fake.NIKOptions{Region: "31.71", BirthDate: "1990-05-17", Sex: fake.SexFemale}) if err == nil { fmt.Println(id) }
fmt.Println(fake.NPWP(3)) fmt.Println(fake.Phone(11)) fmt.Println(fake.NISN(7))
employee, err := fake.NIP(5, fake.NIPOptions{BirthDate: "1990-05-17", Sex: fake.SexFemale}) if err == nil { fmt.Println(employee) }
car, err := fake.Plate(7, fake.PlateOptions{Region: "B"}) if err == nil { fmt.Println(car) }}import * as fake from "nusaindex/fake";
const id = await fake.nik(7, { region: "31.71", birthDate: "1990-05-17", sex: "female" });if (id.ok) { console.log(id.value);}
for (const generated of [fake.npwp(3), fake.phone(11), fake.nisn(7)]) { if (generated.ok) { console.log(generated.value); }}
const employee = fake.nip(5, { birthDate: "1990-05-17", sex: "female" });if (employee.ok) { console.log(employee.value);}
const car = fake.plate(7, { region: "B" });if (car.ok) { console.log(car.value);}31710357059008120315588931648000+62832356444886299763315199005172021112541B 3739 J© 2026 Haikal Mumtaz