import Rupiah from 'https://deno.land/x/rupiah_ts/rupiah.ts'
let rupiah = new Rupiah(350000);
console.log(rupiah.format);
// result Rp350.000,00
You can also make number to terbilang (words version of rupiah)
import Rupiah from 'https://deno.land/x/rupiah_ts/rupiah.ts'
let rupiah = new Rupiah(350000);
console.log(rupiah.terbilang);
// result Tiga Ratus Lima Puluh Ribu Rupiah
Default prefix is configured as Rp
and suffix is configured as ,00
you can set custom prefix and suffix with this following API
import Rupiah from 'https://deno.land/x/rupiah/rupiah.ts'
let rupiah = new Rupiah(350000);
rupiah.setPrefix = "RP";
rupiah.setSuffix = ",-";
console.log(rupiah.format);
// result Rp350.000,-
Default separator is configured as .
you can set custom separator with this following API
import Rupiah from 'https://deno.land/x/rupiah/rupiah.ts'
let rupiah = new Rupiah(350000);
rupiah.setSeparator = "-";
console.log(rupiah.format);
// result 350-000
This repo is in early development stage. PRs is welcomed.
Just run from cli
deno test
- Rupiah Format
- Terbilang
- This work is inspired by gist from https://gist.github.com/faisalman/845309 with refactoring code into more modern javascript way.
- Terbilang version is inspired by stackexchange thread https://codereview.stackexchange.com/questions/90349/changing-number-to-words-in-javascript
- Standart Rupiah format is taken from https://ivanlanin.github.io/puebi/kata/angka-dan-bilangan/