superjs-core 0.5.0 → 0.7.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "superjs-core",
3
- "version": "0.5.0",
4
- "description": "JavaScript toolkit all-in-one buat developer Indonesia: validasi NIK/NPWP/Phone, terbilang, formatRupiah, timeAgo (WIB/WITA/WIT), deepClone, logger, dep scanner. 100+ fungsi, zero dep runtime.",
3
+ "version": "0.7.0",
4
+ "description": "JavaScript toolkit all-in-one buat developer Indonesia: validasi NIK/NPWP/Phone, terbilang, formatRupiah, timeAgo (WIB/WITA/WIT), deepClone, logger, dep scanner. 200+ fungsi, zero dependency.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -122,10 +122,6 @@
122
122
  "bench": "vitest bench",
123
123
  "ci": "npm run lint && npm run typecheck && npm run build && npm run test:coverage"
124
124
  },
125
- "dependencies": {
126
- "commander": "^12.0.0",
127
- "picocolors": "^1.1.0"
128
- },
129
125
  "devDependencies": {
130
126
  "@biomejs/biome": "^2.5.1",
131
127
  "@size-limit/file": "^11.0.0",
@@ -150,7 +146,13 @@
150
146
  "dependency-scanner",
151
147
  "npm-audit",
152
148
  "bloat-detection",
153
- "security"
149
+ "security",
150
+ "indonesia",
151
+ "nik",
152
+ "npwp",
153
+ "validation",
154
+ "rupiah",
155
+ "terbilang"
154
156
  ],
155
157
  "publishConfig": {
156
158
  "access": "public"
@@ -1,167 +0,0 @@
1
- /**
2
- * Validates an Indonesian NIK (Nomor Induk Kependudukan / Resident Identity Number).
3
- *
4
- * A valid NIK:
5
- * - Must be exactly 16 digits
6
- * - Structure: PP CC DD DDMMYY SSSS
7
- * - PP: Province code (2 digits)
8
- * - CC: City code (2 digits)
9
- * - DD: District code (2 digits)
10
- * - DDMMYY: Birth date (6 digits; for women the day is incremented by 40)
11
- * - SSSS: Serial number (4 digits)
12
- * - The birth date must correspond to a valid calendar date
13
- *
14
- * @param value - The NIK string (digits only or with dots)
15
- * @returns `true` if the value is a valid NIK
16
- *
17
- * @example isNIK('3201010203940001') // => true (male, born 2 March 1994)
18
- * @example isNIK('3201015203940001') // => true (female, born 12 March 1994)
19
- * @example isNIK('1234567890123456') // => false (invalid birth date)
20
- * @example isNIK('320101') // => false (too short)
21
- */
22
- declare function isNIK(value: string): boolean;
23
-
24
- /**
25
- * Validates an Indonesian NPWP (Nomor Pokok Wajib Pajak / Tax Identification Number).
26
- *
27
- * A valid NPWP:
28
- * - Must be 15 or 16 digits (formatted: `XX.XXX.XXX.X-XXX.XXX` or plain digits)
29
- * - The last digit is a checksum computed from the preceding digits
30
- *
31
- * The checksum uses a weighted-sum algorithm with a repeating weight pattern of
32
- * `[3, 7, 1]`. The computed checksum must equal the last digit.
33
- *
34
- * @param value - The NPWP string (formatted with dots & dash, or plain digits)
35
- * @returns `true` if the value is a valid NPWP
36
- *
37
- * @example isNPWP('12.345.678.9-012.344') // => true
38
- * @example isNPWP('123456789012344') // => true (plain digits)
39
- * @example isNPWP('12.345.678.9-012.345') // => false (invalid checksum)
40
- */
41
- declare function isNPWP(value: string): boolean;
42
-
43
- /**
44
- * Validates a phone number.
45
- *
46
- * For Indonesian numbers (`country = 'id'`):
47
- * - Accepted formats: `08xx…`, `+628xx…`, `628xx…`
48
- * - Must start with a valid operator prefix:
49
- * 0811-0819, 0821-0829, 0851-0859, 0877-0879, 0895-0899
50
- * - 10–13 digits after the country code
51
- *
52
- * For generic numbers (`country = 'any'`):
53
- * - Any string with 10–15 digits is accepted
54
- *
55
- * @param value - The phone number string
56
- * @param country - Country to validate against (`'id'` or `'any'`; default `'id'`)
57
- * @returns `true` if the value is a valid phone number
58
- *
59
- * @example isPhone('08123456789') // => true
60
- * @example isPhone('+628123456789') // => true
61
- * @example isPhone('628123456789') // => true
62
- * @example isPhone('081234567') // => false (too short)
63
- * @example isPhone('089123456789') // => false (invalid prefix 91)
64
- */
65
- declare function isPhone(value: string, country?: 'id' | 'any'): boolean;
66
-
67
- /**
68
- * RFC‑compliant email address validation.
69
- *
70
- * Validation rules:
71
- * - Total length ≤ 254 characters
72
- * - Local part ≤ 64 characters; supports quoted strings (including escaped
73
- * characters), unquoted letters / digits / `!#$%&'*+/=?^_`{|}~-`, and dots
74
- * (no leading, trailing, or consecutive dots)
75
- * - Domain part ≤ 255 characters; valid DNS labels separated by dots, each
76
- * label ≤ 63 characters, no leading/trailing hyphens, at least two labels
77
- *
78
- * @param value - The email address string
79
- * @returns `true` if the value is a syntactically valid email address
80
- *
81
- * @example isEmail('user@example.com') // => true
82
- * @example isEmail('user.name+tag@example.co.id') // => true
83
- * @example isEmail('"quoted@local"@example.com') // => true
84
- * @example isEmail('not-an-email') // => false
85
- */
86
- declare function isEmail(value: string): boolean;
87
-
88
- /**
89
- * Validates a URL.
90
- *
91
- * A valid URL:
92
- * - Must use the `http` or `https` protocol
93
- * - Must have a valid hostname (DNS name, IPv4, IPv6 literal, or `localhost`)
94
- * - May include an optional port, path, query string, and fragment
95
- *
96
- * @param value - The URL string
97
- * @returns `true` if the value is a valid http/https URL
98
- *
99
- * @example isURL('https://example.com') // => true
100
- * @example isURL('http://example.com:8080/path?q=1#f') // => true
101
- * @example isURL('ftp://example.com') // => false
102
- * @example isURL('not-a-url') // => false
103
- */
104
- declare function isURL(value: string): boolean;
105
-
106
- /**
107
- * Parse data dari NIK (Nomor Induk Kependudukan).
108
- *
109
- * @example parseNIK('3201010203940001')
110
- * // { nik: '3201010203940001', valid: true, gender: 'LAKI-LAKI', birthDate: Date(1994-03-02), province: 'JAWA BARAT', city: 'BOGOR', district: 'CIAWI' }
111
- *
112
- * @example parseNIK('3201015203940001')
113
- * // { nik: '3201015203940001', valid: true, gender: 'PEREMPUAN', birthDate: Date(1994-03-12), province: 'JAWA BARAT', ... }
114
- */
115
- declare function parseNIK(value: string): NIKInfo;
116
- interface NIKInfo {
117
- nik: string;
118
- valid: boolean;
119
- gender: 'LAKI-LAKI' | 'PEREMPUAN' | null;
120
- birthDate: Date | null;
121
- province: string | null;
122
- provinceCode: string | null;
123
- city: string | null;
124
- cityCode: string | null;
125
- district: string | null;
126
- districtCode: string | null;
127
- uniqueCode: string | null;
128
- }
129
-
130
- /**
131
- * Validasi Plat Nomor Kendaraan Bermotor Indonesia.
132
- *
133
- * Format: [KODE_DEPAN] [ANGKA] [KODE_BELAKANG]
134
- * - Kode depan: 1-2 huruf (kode daerah)
135
- * - Angka: 1-4 digit
136
- * - Kode belakang: 1-3 huruf (opsional)
137
- *
138
- * @example isPlatNomor('B 1234 CD') // true (Jakarta)
139
- * @example isPlatNomor('AB 5678 XYZ') // true
140
- * @example isPlatNomor('B 1 A') // true
141
- * @example isPlatNomor('INVALID') // false
142
- */
143
- declare function isPlatNomor(value: string): boolean;
144
-
145
- /**
146
- * Validasi kode pos Indonesia.
147
- * Kode pos Indonesia terdiri dari 5 digit angka.
148
- *
149
- * @example isKodepos('16110') // true (Bogor)
150
- * @example isKodepos('12345') // true
151
- * @example isKodepos('1234') // false (kurang)
152
- * @example isKodepos('ABCDE') // false
153
- */
154
- declare function isKodepos(value: string): boolean;
155
-
156
- /**
157
- * Validasi nomor rekening bank Indonesia.
158
- * Format: 8-16 digit angka (tergantung bank).
159
- *
160
- * @example isNoRekening('1234567890') // true (10 digit)
161
- * @example isNoRekening('12345678') // true (8 digit - minimum)
162
- * @example isNoRekening('1234567890123456') // true (16 digit - maksimum)
163
- * @example isNoRekening('12345') // false (kurang dari 8 digit)
164
- */
165
- declare function isNoRekening(value: string): boolean;
166
-
167
- export { type NIKInfo as N, isKodepos as a, isNIK as b, isNPWP as c, isNoRekening as d, isPhone as e, isPlatNomor as f, isURL as g, isEmail as i, parseNIK as p };