@ghifari29/id-kit 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ghifari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # id-kit
2
+
3
+ Utilitas kecil untuk kebutuhan Indonesia: terbilang, format Rupiah, dan normalisasi nomor telepon.
4
+ Tanpa dependency, TypeScript penuh, bisa dipakai offline.
5
+
6
+ ## Instalasi
7
+
8
+ ```bash
9
+ npm i @ghifari29/id-kit
10
+ ```
11
+
12
+ ## Pemakaian
13
+
14
+ ```ts
15
+ import { terbilang, rupiah } from "@ghifari29/id-kit/format";
16
+ import { normalizePhone, isValidPhone } from "@ghifari29/id-kit/phone";
17
+
18
+ terbilang(1250000);
19
+ // "satu juta dua ratus lima puluh ribu rupiah"
20
+
21
+ rupiah(1250000);
22
+ // "Rp1.250.000"
23
+
24
+ normalizePhone("0812-3456-789");
25
+ // "+628123456789"
26
+
27
+ isValidPhone("021-555-1234");
28
+ // false
29
+ ```
30
+
31
+ ## Fitur
32
+
33
+ - [x] `terbilang`, `rupiah`
34
+ - [x] `normalizePhone`, `isValidPhone`
35
+ - [ ] Deteksi operator seluler
36
+ - [ ] Validasi NIK
37
+ - [ ] Validasi NPWP dan nomor rekening
38
+ - [ ] Libur nasional dan cuti bersama
39
+ - [ ] Data wilayah
40
+
41
+ ## Batasan
42
+
43
+ - `terbilang` hanya mendukung bilangan bulat.
44
+ - `normalizePhone` hanya mengecek pola umum nomor seluler, belum memastikan awalan operator.
45
+
46
+ ## Berkontribusi
47
+
48
+ Issue dan pull request sangat diterima. Jalankan `npm test` sebelum mengirim PR.
49
+
50
+ ## Lisensi
51
+
52
+ MIT
@@ -0,0 +1,50 @@
1
+ // src/format/terbilang.ts
2
+ var SATUAN = [
3
+ "",
4
+ "satu",
5
+ "dua",
6
+ "tiga",
7
+ "empat",
8
+ "lima",
9
+ "enam",
10
+ "tujuh",
11
+ "delapan",
12
+ "sembilan",
13
+ "sepuluh",
14
+ "sebelas"
15
+ ];
16
+ var SKALA = [
17
+ [1e12, "triliun"],
18
+ [1e9, "miliar"],
19
+ [1e6, "juta"],
20
+ [1e3, "ribu"]
21
+ ];
22
+ function gabung(depan, sisa) {
23
+ return sisa ? `${depan} ${baca(sisa)}` : depan;
24
+ }
25
+ function baca(n) {
26
+ if (n < 12) return SATUAN[n];
27
+ if (n < 20) return `${SATUAN[n - 10]} belas`;
28
+ if (n < 100) return gabung(`${SATUAN[Math.floor(n / 10)]} puluh`, n % 10);
29
+ if (n < 200) return gabung("seratus", n - 100);
30
+ if (n < 1e3) return gabung(`${SATUAN[Math.floor(n / 100)]} ratus`, n % 100);
31
+ if (n < 2e3) return gabung("seribu", n - 1e3);
32
+ for (const [nilai, nama] of SKALA) {
33
+ if (n >= nilai) return gabung(`${baca(Math.floor(n / nilai))} ${nama}`, n % nilai);
34
+ }
35
+ return "";
36
+ }
37
+ function terbilang(n) {
38
+ if (!Number.isSafeInteger(n)) throw new RangeError("Hanya bilangan bulat yang didukung");
39
+ if (n === 0) return "nol rupiah";
40
+ const hasil = baca(Math.abs(n));
41
+ return `${n < 0 ? "minus " : ""}${hasil} rupiah`;
42
+ }
43
+ function rupiah(n) {
44
+ return "Rp" + new Intl.NumberFormat("id-ID").format(n);
45
+ }
46
+
47
+ export {
48
+ terbilang,
49
+ rupiah
50
+ };
@@ -0,0 +1,18 @@
1
+ // src/phone/index.ts
2
+ function normalizePhone(input) {
3
+ let d = input.replace(/[^\d+]/g, "");
4
+ if (d.startsWith("+62")) d = d.slice(3);
5
+ else if (d.startsWith("62")) d = d.slice(2);
6
+ else if (d.startsWith("0")) d = d.slice(1);
7
+ else return null;
8
+ if (!/^8\d{8,11}$/.test(d)) return null;
9
+ return "+62" + d;
10
+ }
11
+ function isValidPhone(input) {
12
+ return normalizePhone(input) !== null;
13
+ }
14
+
15
+ export {
16
+ normalizePhone,
17
+ isValidPhone
18
+ };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/format/index.ts
21
+ var format_exports = {};
22
+ __export(format_exports, {
23
+ rupiah: () => rupiah,
24
+ terbilang: () => terbilang
25
+ });
26
+ module.exports = __toCommonJS(format_exports);
27
+
28
+ // src/format/terbilang.ts
29
+ var SATUAN = [
30
+ "",
31
+ "satu",
32
+ "dua",
33
+ "tiga",
34
+ "empat",
35
+ "lima",
36
+ "enam",
37
+ "tujuh",
38
+ "delapan",
39
+ "sembilan",
40
+ "sepuluh",
41
+ "sebelas"
42
+ ];
43
+ var SKALA = [
44
+ [1e12, "triliun"],
45
+ [1e9, "miliar"],
46
+ [1e6, "juta"],
47
+ [1e3, "ribu"]
48
+ ];
49
+ function gabung(depan, sisa) {
50
+ return sisa ? `${depan} ${baca(sisa)}` : depan;
51
+ }
52
+ function baca(n) {
53
+ if (n < 12) return SATUAN[n];
54
+ if (n < 20) return `${SATUAN[n - 10]} belas`;
55
+ if (n < 100) return gabung(`${SATUAN[Math.floor(n / 10)]} puluh`, n % 10);
56
+ if (n < 200) return gabung("seratus", n - 100);
57
+ if (n < 1e3) return gabung(`${SATUAN[Math.floor(n / 100)]} ratus`, n % 100);
58
+ if (n < 2e3) return gabung("seribu", n - 1e3);
59
+ for (const [nilai, nama] of SKALA) {
60
+ if (n >= nilai) return gabung(`${baca(Math.floor(n / nilai))} ${nama}`, n % nilai);
61
+ }
62
+ return "";
63
+ }
64
+ function terbilang(n) {
65
+ if (!Number.isSafeInteger(n)) throw new RangeError("Hanya bilangan bulat yang didukung");
66
+ if (n === 0) return "nol rupiah";
67
+ const hasil = baca(Math.abs(n));
68
+ return `${n < 0 ? "minus " : ""}${hasil} rupiah`;
69
+ }
70
+ function rupiah(n) {
71
+ return "Rp" + new Intl.NumberFormat("id-ID").format(n);
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ rupiah,
76
+ terbilang
77
+ });
@@ -0,0 +1,4 @@
1
+ declare function terbilang(n: number): string;
2
+ declare function rupiah(n: number): string;
3
+
4
+ export { rupiah, terbilang };
@@ -0,0 +1,4 @@
1
+ declare function terbilang(n: number): string;
2
+ declare function rupiah(n: number): string;
3
+
4
+ export { rupiah, terbilang };
package/dist/format.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ rupiah,
3
+ terbilang
4
+ } from "./chunk-3347TRCX.js";
5
+ export {
6
+ rupiah,
7
+ terbilang
8
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ isValidPhone: () => isValidPhone,
24
+ normalizePhone: () => normalizePhone,
25
+ rupiah: () => rupiah,
26
+ terbilang: () => terbilang
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/format/terbilang.ts
31
+ var SATUAN = [
32
+ "",
33
+ "satu",
34
+ "dua",
35
+ "tiga",
36
+ "empat",
37
+ "lima",
38
+ "enam",
39
+ "tujuh",
40
+ "delapan",
41
+ "sembilan",
42
+ "sepuluh",
43
+ "sebelas"
44
+ ];
45
+ var SKALA = [
46
+ [1e12, "triliun"],
47
+ [1e9, "miliar"],
48
+ [1e6, "juta"],
49
+ [1e3, "ribu"]
50
+ ];
51
+ function gabung(depan, sisa) {
52
+ return sisa ? `${depan} ${baca(sisa)}` : depan;
53
+ }
54
+ function baca(n) {
55
+ if (n < 12) return SATUAN[n];
56
+ if (n < 20) return `${SATUAN[n - 10]} belas`;
57
+ if (n < 100) return gabung(`${SATUAN[Math.floor(n / 10)]} puluh`, n % 10);
58
+ if (n < 200) return gabung("seratus", n - 100);
59
+ if (n < 1e3) return gabung(`${SATUAN[Math.floor(n / 100)]} ratus`, n % 100);
60
+ if (n < 2e3) return gabung("seribu", n - 1e3);
61
+ for (const [nilai, nama] of SKALA) {
62
+ if (n >= nilai) return gabung(`${baca(Math.floor(n / nilai))} ${nama}`, n % nilai);
63
+ }
64
+ return "";
65
+ }
66
+ function terbilang(n) {
67
+ if (!Number.isSafeInteger(n)) throw new RangeError("Hanya bilangan bulat yang didukung");
68
+ if (n === 0) return "nol rupiah";
69
+ const hasil = baca(Math.abs(n));
70
+ return `${n < 0 ? "minus " : ""}${hasil} rupiah`;
71
+ }
72
+ function rupiah(n) {
73
+ return "Rp" + new Intl.NumberFormat("id-ID").format(n);
74
+ }
75
+
76
+ // src/phone/index.ts
77
+ function normalizePhone(input) {
78
+ let d = input.replace(/[^\d+]/g, "");
79
+ if (d.startsWith("+62")) d = d.slice(3);
80
+ else if (d.startsWith("62")) d = d.slice(2);
81
+ else if (d.startsWith("0")) d = d.slice(1);
82
+ else return null;
83
+ if (!/^8\d{8,11}$/.test(d)) return null;
84
+ return "+62" + d;
85
+ }
86
+ function isValidPhone(input) {
87
+ return normalizePhone(input) !== null;
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ isValidPhone,
92
+ normalizePhone,
93
+ rupiah,
94
+ terbilang
95
+ });
@@ -0,0 +1,2 @@
1
+ export { rupiah, terbilang } from './format.cjs';
2
+ export { isValidPhone, normalizePhone } from './phone.cjs';
@@ -0,0 +1,2 @@
1
+ export { rupiah, terbilang } from './format.js';
2
+ export { isValidPhone, normalizePhone } from './phone.js';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ rupiah,
3
+ terbilang
4
+ } from "./chunk-3347TRCX.js";
5
+ import {
6
+ isValidPhone,
7
+ normalizePhone
8
+ } from "./chunk-GH7ECGI2.js";
9
+ export {
10
+ isValidPhone,
11
+ normalizePhone,
12
+ rupiah,
13
+ terbilang
14
+ };
package/dist/phone.cjs ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/phone/index.ts
21
+ var phone_exports = {};
22
+ __export(phone_exports, {
23
+ isValidPhone: () => isValidPhone,
24
+ normalizePhone: () => normalizePhone
25
+ });
26
+ module.exports = __toCommonJS(phone_exports);
27
+ function normalizePhone(input) {
28
+ let d = input.replace(/[^\d+]/g, "");
29
+ if (d.startsWith("+62")) d = d.slice(3);
30
+ else if (d.startsWith("62")) d = d.slice(2);
31
+ else if (d.startsWith("0")) d = d.slice(1);
32
+ else return null;
33
+ if (!/^8\d{8,11}$/.test(d)) return null;
34
+ return "+62" + d;
35
+ }
36
+ function isValidPhone(input) {
37
+ return normalizePhone(input) !== null;
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ isValidPhone,
42
+ normalizePhone
43
+ });
@@ -0,0 +1,4 @@
1
+ declare function normalizePhone(input: string): string | null;
2
+ declare function isValidPhone(input: string): boolean;
3
+
4
+ export { isValidPhone, normalizePhone };
@@ -0,0 +1,4 @@
1
+ declare function normalizePhone(input: string): string | null;
2
+ declare function isValidPhone(input: string): boolean;
3
+
4
+ export { isValidPhone, normalizePhone };
package/dist/phone.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ isValidPhone,
3
+ normalizePhone
4
+ } from "./chunk-GH7ECGI2.js";
5
+ export {
6
+ isValidPhone,
7
+ normalizePhone
8
+ };
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@ghifari29/id-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Utilitas Indonesia: terbilang, rupiah, nomor telepon, dan lainnya",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "main": "./dist/index.cjs",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
+ },
19
+ "./format": {
20
+ "types": "./dist/format.d.ts",
21
+ "import": "./dist/format.js",
22
+ "require": "./dist/format.cjs"
23
+ },
24
+ "./phone": {
25
+ "types": "./dist/phone.d.ts",
26
+ "import": "./dist/phone.js",
27
+ "require": "./dist/phone.cjs"
28
+ }
29
+ },
30
+ "scripts": {
31
+ "build": "tsup",
32
+ "test": "vitest run",
33
+ "typecheck": "tsc --noEmit",
34
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
35
+ },
36
+ "keywords": [
37
+ "indonesia",
38
+ "terbilang",
39
+ "rupiah",
40
+ "nik",
41
+ "phone"
42
+ ],
43
+ "license": "MIT",
44
+ "devDependencies": {
45
+ "tsup": "^8.5.1",
46
+ "typescript": "^5.9.3",
47
+ "vitest": "^5.1.0"
48
+ }
49
+ }