Skip to content

Getting started

  1. Install the package. Go 1.25 or later uses only the standard library. TypeScript runs on Node.js 22.18 or later, Bun, Deno, edge runtimes and modern browsers (ESM only).

    Go
    go get github.com/haikalmumtaz233/nusaindex
    TypeScript
    npm install nusaindex
  2. Run a first check. This example runs on every build, in both languages, and must print the same output.

    package main
    import (
    "fmt"
    "github.com/haikalmumtaz233/nusaindex/nik"
    "github.com/haikalmumtaz233/nusaindex/phone"
    "github.com/haikalmumtaz233/nusaindex/rupiah"
    )
    func main() {
    person, err := nik.Parse("3273275705901349")
    if err == nil {
    fmt.Println(person.BirthDate, person.Sex)
    }
    mobile, err := phone.Parse("0859-5257-171")
    if err == nil {
    fmt.Println(mobile.E164, mobile.Brand)
    }
    words, err := rupiah.Terbilang(1_500_000*rupiah.Rupiah + 50*rupiah.Sen)
    if err == nil {
    fmt.Println(words)
    }
    }
    Output
    1990-05-17 female
    +628595257171 XL
    satu juta lima ratus ribu rupiah lima puluh sen
  3. Import only what you need. Each module is its own Go package (github.com/haikalmumtaz233/nusaindex/<name>) and TypeScript subpath (nusaindex/<name>). nusaindex/nik adds less than 2 KB gzip to a browser bundle, and region data loads one province at a time.

Operation Go TypeScript
Quick check Valid(s) bool isValid(s): boolean
Parse Parse(s) (T, error) parse(s): Result<T>
Normalize Format(s) (string, error) format(s): Result<string>
Mask Mask(s) string mask(s): string

Names follow each language (WhatsAppLink, whatsappLink). Shared test vectors run against both implementations, so results are identical. In TypeScript, fake, zod and valibot are subpath-only.