id-rupiah-formatter 1.0.0

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.
Files changed (4) hide show
  1. package/README.md +7 -0
  2. package/index.js +19 -0
  3. package/package.json +20 -0
  4. package/test.js +4 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # ID Rupiah Formatter
2
+ Library sederhana untuk mengubah angka menjadi format mata uang Rupiah.
3
+
4
+ ## Cara Pakai
5
+ const formatRupiah = require('id-rupiah-formatter');
6
+
7
+ console.log(formatRupiah(150000)); // Hasil: Rp 150.000
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Fungsi untuk mengubah angka menjadi format Rupiah
3
+ * @param {number} amount - Angka yang ingin diubah
4
+ * @param {boolean} withSymbol - Pakai "Rp" atau tidak (default: true)
5
+ */
6
+ function formatRupiah(amount, withSymbol = true) {
7
+ if (isNaN(amount)) return "Bukan Angka";
8
+
9
+ const formatted = new Intl.NumberFormat("id-ID", {
10
+ style: withSymbol ? "currency" : "decimal",
11
+ currency: "IDR",
12
+ minimumFractionDigits: 0,
13
+ }).format(amount);
14
+
15
+ return formatted;
16
+ }
17
+
18
+
19
+ module.exports = formatRupiah;
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "id-rupiah-formatter",
3
+ "version": "1.0.0",
4
+ "description": "Library sederhana untuk mengubah angka menjadi format mata uang Rupiah (IDR) secara otomatis.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js"
8
+ },
9
+ "keywords": [
10
+ "rupiah",
11
+ "currency",
12
+ "indonesia",
13
+ "formatter",
14
+ "idr",
15
+ "money"
16
+ ],
17
+ "author": "Muhammad Zili",
18
+ "license": "MIT",
19
+ "type": "commonjs"
20
+ }
package/test.js ADDED
@@ -0,0 +1,4 @@
1
+ const formatRupiah = require('./index.js');
2
+
3
+ console.log("Tes 1:", formatRupiah(1000000)); // Rp 1.000.000
4
+ console.log("Tes 2 (Tanpa Rp):", formatRupiah(5000, false)); // 5.000