@indodev/toolkit 0.2.0 → 0.3.1

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 (58) hide show
  1. package/dist/{compare-B1MKSOWV.d.cts → compare-CZadJMGl.d.cts} +54 -1
  2. package/dist/{compare-B1MKSOWV.d.ts → compare-CZadJMGl.d.ts} +54 -1
  3. package/dist/currency/index.cjs +23 -0
  4. package/dist/currency/index.cjs.map +1 -1
  5. package/dist/currency/index.d.cts +367 -3
  6. package/dist/currency/index.d.ts +367 -3
  7. package/dist/currency/index.js +21 -1
  8. package/dist/currency/index.js.map +1 -1
  9. package/dist/index.cjs +1188 -0
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +7 -4
  12. package/dist/index.d.ts +7 -4
  13. package/dist/index.js +1165 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/nik/index.cjs +44 -0
  16. package/dist/nik/index.cjs.map +1 -1
  17. package/dist/nik/index.d.cts +44 -1
  18. package/dist/nik/index.d.ts +44 -1
  19. package/dist/nik/index.js +41 -1
  20. package/dist/nik/index.js.map +1 -1
  21. package/dist/npwp/index.cjs +95 -0
  22. package/dist/npwp/index.cjs.map +1 -0
  23. package/dist/npwp/index.d.cts +76 -0
  24. package/dist/npwp/index.d.ts +76 -0
  25. package/dist/npwp/index.js +90 -0
  26. package/dist/npwp/index.js.map +1 -0
  27. package/dist/phone/index.cjs +42 -0
  28. package/dist/phone/index.cjs.map +1 -1
  29. package/dist/phone/index.d.cts +57 -1
  30. package/dist/phone/index.d.ts +57 -1
  31. package/dist/phone/index.js +39 -1
  32. package/dist/phone/index.js.map +1 -1
  33. package/dist/plate/index.cjs +99 -0
  34. package/dist/plate/index.cjs.map +1 -0
  35. package/dist/plate/index.d.cts +8 -0
  36. package/dist/plate/index.d.ts +8 -0
  37. package/dist/plate/index.js +94 -0
  38. package/dist/plate/index.js.map +1 -0
  39. package/dist/text/index.cjs +811 -0
  40. package/dist/text/index.cjs.map +1 -1
  41. package/dist/text/index.d.cts +1 -1
  42. package/dist/text/index.d.ts +1 -1
  43. package/dist/text/index.js +808 -1
  44. package/dist/text/index.js.map +1 -1
  45. package/dist/types-i5e6R0AS.d.cts +39 -0
  46. package/dist/types-i5e6R0AS.d.ts +39 -0
  47. package/dist/utils-DDVlOusI.d.cts +30 -0
  48. package/dist/utils-DDVlOusI.d.ts +30 -0
  49. package/dist/vin/index.cjs +84 -0
  50. package/dist/vin/index.cjs.map +1 -0
  51. package/dist/vin/index.d.cts +39 -0
  52. package/dist/vin/index.d.ts +39 -0
  53. package/dist/vin/index.js +74 -0
  54. package/dist/vin/index.js.map +1 -0
  55. package/package.json +48 -18
  56. package/LICENCE +0 -21
  57. package/dist/words-Dy8iYkbv.d.cts +0 -333
  58. package/dist/words-Dy8iYkbv.d.ts +0 -333
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Validates an Indonesian license plate number format.
3
+ * Format: [1-2 letters] [1-4 digits] [1-3 letters]
4
+ *
5
+ * @param plate - The plate number string to validate
6
+ * @returns `true` if valid, `false` otherwise
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * validatePlate('B 1234 ABC'); // true
11
+ * validatePlate('AB 1 CD'); // true
12
+ * ```
13
+ */
14
+ declare function validatePlate(plate: string): boolean;
15
+ /**
16
+ * Gets the region name from a license plate number.
17
+ *
18
+ * @param plate - The plate number
19
+ * @returns Region name or null if not found
20
+ */
21
+ declare function getRegionFromPlate(plate: string): string | null;
22
+ /**
23
+ * Formats a license plate number with spaces (e.g., B 1234 ABC).
24
+ *
25
+ * @param plate - The plate number
26
+ * @returns Formatted plate string
27
+ */
28
+ declare function formatPlate(plate: string): string;
29
+
30
+ export { formatPlate as f, getRegionFromPlate as g, validatePlate as v };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Validates an Indonesian license plate number format.
3
+ * Format: [1-2 letters] [1-4 digits] [1-3 letters]
4
+ *
5
+ * @param plate - The plate number string to validate
6
+ * @returns `true` if valid, `false` otherwise
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * validatePlate('B 1234 ABC'); // true
11
+ * validatePlate('AB 1 CD'); // true
12
+ * ```
13
+ */
14
+ declare function validatePlate(plate: string): boolean;
15
+ /**
16
+ * Gets the region name from a license plate number.
17
+ *
18
+ * @param plate - The plate number
19
+ * @returns Region name or null if not found
20
+ */
21
+ declare function getRegionFromPlate(plate: string): string | null;
22
+ /**
23
+ * Formats a license plate number with spaces (e.g., B 1234 ABC).
24
+ *
25
+ * @param plate - The plate number
26
+ * @returns Formatted plate string
27
+ */
28
+ declare function formatPlate(plate: string): string;
29
+
30
+ export { formatPlate as f, getRegionFromPlate as g, validatePlate as v };
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ // src/vin/constants.ts
4
+ var VIN_LENGTH = 17;
5
+ var VIN_CHECK_DIGIT_INDEX = 8;
6
+ var VIN_MODULUS = 11;
7
+ var VIN_CHECK_DIGIT_X = "X";
8
+ var VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
9
+ var VIN_CHAR_VALUES = {
10
+ "0": 0,
11
+ "1": 1,
12
+ "2": 2,
13
+ "3": 3,
14
+ "4": 4,
15
+ "5": 5,
16
+ "6": 6,
17
+ "7": 7,
18
+ "8": 8,
19
+ "9": 9,
20
+ "A": 1,
21
+ "B": 2,
22
+ "C": 3,
23
+ "D": 4,
24
+ "E": 5,
25
+ "F": 6,
26
+ "G": 7,
27
+ "H": 8,
28
+ "J": 1,
29
+ "K": 2,
30
+ "L": 3,
31
+ "M": 4,
32
+ "N": 5,
33
+ "P": 7,
34
+ "R": 9,
35
+ "S": 2,
36
+ "T": 3,
37
+ "U": 4,
38
+ "V": 5,
39
+ "W": 6,
40
+ "X": 7,
41
+ "Y": 8,
42
+ "Z": 9
43
+ };
44
+ var EXCLUDED_VIN_CHARS = ["I", "O", "Q"];
45
+ var VIN_VERSION = "1.0.0";
46
+
47
+ // src/vin/validate.ts
48
+ function validateVIN(vin) {
49
+ if (!vin || vin.length !== VIN_LENGTH) {
50
+ return false;
51
+ }
52
+ const normalizedVIN = vin.toUpperCase();
53
+ for (const char of EXCLUDED_VIN_CHARS) {
54
+ if (normalizedVIN.includes(char)) {
55
+ return false;
56
+ }
57
+ }
58
+ let sum = 0;
59
+ for (let i = 0; i < VIN_LENGTH; i++) {
60
+ const char = normalizedVIN[i];
61
+ const weight = VIN_WEIGHTS[i];
62
+ const val = VIN_CHAR_VALUES[char];
63
+ if (val === void 0) {
64
+ return false;
65
+ }
66
+ sum += val * weight;
67
+ }
68
+ const checkDigitValue = sum % VIN_MODULUS;
69
+ const expectedCheckDigit = checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();
70
+ const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];
71
+ return actualCheckDigit === expectedCheckDigit;
72
+ }
73
+
74
+ exports.EXCLUDED_VIN_CHARS = EXCLUDED_VIN_CHARS;
75
+ exports.VIN_CHAR_VALUES = VIN_CHAR_VALUES;
76
+ exports.VIN_CHECK_DIGIT_INDEX = VIN_CHECK_DIGIT_INDEX;
77
+ exports.VIN_CHECK_DIGIT_X = VIN_CHECK_DIGIT_X;
78
+ exports.VIN_LENGTH = VIN_LENGTH;
79
+ exports.VIN_MODULUS = VIN_MODULUS;
80
+ exports.VIN_VERSION = VIN_VERSION;
81
+ exports.VIN_WEIGHTS = VIN_WEIGHTS;
82
+ exports.validateVIN = validateVIN;
83
+ //# sourceMappingURL=index.cjs.map
84
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/vin/constants.ts","../../src/vin/validate.ts"],"names":[],"mappings":";;;AAGO,IAAM,UAAA,GAAa;AAKnB,IAAM,qBAAA,GAAwB;AAK9B,IAAM,WAAA,GAAc;AAKpB,IAAM,iBAAA,GAAoB;AAO1B,IAAM,cAAc,CAAC,CAAA,EAAG,GAAG,CAAA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AKzC,IAAM,WAAA,GAAc;;;ACjBpB,SAAS,YAAY,GAAA,EAAsB;AAChD,EAAA,IAAI,CAAC,GAAA,IAAO,GAAA,CAAI,MAAA,KAAW,UAAA,EAAY;AACrC,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,aAAA,GAAgB,IAAI,WAAA,EAAY;AAGtC,EAAA,KAAA,MAAW,QAAQ,kBAAA,EAAoB;AACrC,IAAA,IAAI,aAAA,CAAc,QAAA,CAAS,IAAI,CAAA,EAAG;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAGA,EAAA,IAAI,GAAA,GAAM,CAAA;AACV,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,UAAA,EAAY,CAAA,EAAA,EAAK;AACnC,IAAA,MAAM,IAAA,GAAO,cAAc,CAAC,CAAA;AAC5B,IAAA,MAAM,MAAA,GAAS,YAAY,CAAC,CAAA;AAC5B,IAAA,MAAM,GAAA,GAAM,gBAAgB,IAAI,CAAA;AAEhC,IAAA,IAAI,QAAQ,MAAA,EAAW;AACrB,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,GAAA,IAAO,GAAA,GAAM,MAAA;AAAA,EACf;AAEA,EAAA,MAAM,kBAAkB,GAAA,GAAM,WAAA;AAC9B,EAAA,MAAM,kBAAA,GACJ,eAAA,KAAoB,EAAA,GAAK,iBAAA,GAAoB,gBAAgB,QAAA,EAAS;AACxE,EAAA,MAAM,gBAAA,GAAmB,cAAc,qBAAqB,CAAA;AAE5D,EAAA,OAAO,gBAAA,KAAqB,kBAAA;AAC9B","file":"index.cjs","sourcesContent":["/**\n * The standard length of a VIN (ISO 3779).\n */\nexport const VIN_LENGTH = 17;\n\n/**\n * The 0-based index of the check digit in the VIN (Position 9).\n */\nexport const VIN_CHECK_DIGIT_INDEX = 8;\n\n/**\n * The modulus used in the VIN checksum calculation.\n */\nexport const VIN_MODULUS = 11;\n\n/**\n * The character representing a checksum value of 10.\n */\nexport const VIN_CHECK_DIGIT_X = 'X';\n\n/**\n * Weights used in the VIN checksum calculation.\n * Each position (1-17) is multiplied by its corresponding weight.\n * Position 9 is the check digit itself (weight 0).\n */\nexport const VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * Values assigned to each valid character for VIN calculation.\n * Invalid characters: I, O, Q are not allowed in VIN.\n */\nexport const VIN_CHAR_VALUES: Record<string, number> = {\n '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,\n 'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8,\n 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9,\n 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9,\n};\n\n/**\n * Characters excluded from VIN (I, O, Q).\n */\nexport const EXCLUDED_VIN_CHARS = ['I', 'O', 'Q'];\n\n/**\n * Version of the VIN utility module.\n */\nexport const VIN_VERSION = '1.0.0';\n\n","import {\n VIN_WEIGHTS,\n VIN_CHAR_VALUES,\n EXCLUDED_VIN_CHARS,\n VIN_LENGTH,\n VIN_CHECK_DIGIT_INDEX,\n VIN_MODULUS,\n VIN_CHECK_DIGIT_X,\n} from './constants';\n\n/**\n * Validates a Vehicle Identification Number (VIN) based on ISO 3779.\n *\n * Checks for:\n * - Exactly 17 characters length.\n * - Exclusion of characters I, O, and Q.\n * - Checksum validation using the check digit at position 9.\n *\n * @param vin - The VIN string to validate\n * @returns boolean indicating if the VIN is valid\n *\n * @example\n * ```typescript\n * import { validateVIN } from '@indodev/toolkit/vin';\n *\n * validateVIN('1HBHA82L7ZB000001'); // true\n * validateVIN('1HBHA82I7ZB000001'); // false (contains 'I')\n * ```\n */\nexport function validateVIN(vin: string): boolean {\n if (!vin || vin.length !== VIN_LENGTH) {\n return false;\n }\n\n const normalizedVIN = vin.toUpperCase();\n\n // 1. Check for excluded characters (I, O, Q)\n for (const char of EXCLUDED_VIN_CHARS) {\n if (normalizedVIN.includes(char)) {\n return false;\n }\n }\n\n // 2. Checksum validation (Position 9)\n let sum = 0;\n for (let i = 0; i < VIN_LENGTH; i++) {\n const char = normalizedVIN[i];\n const weight = VIN_WEIGHTS[i];\n const val = VIN_CHAR_VALUES[char];\n\n if (val === undefined) {\n return false; // Invalid character found\n }\n\n sum += val * weight;\n }\n\n const checkDigitValue = sum % VIN_MODULUS;\n const expectedCheckDigit =\n checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();\n const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];\n\n return actualCheckDigit === expectedCheckDigit;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ export { V as VINOptions, a as VINValidationResult, v as validateVIN } from '../types-i5e6R0AS.cjs';
2
+
3
+ /**
4
+ * The standard length of a VIN (ISO 3779).
5
+ */
6
+ declare const VIN_LENGTH = 17;
7
+ /**
8
+ * The 0-based index of the check digit in the VIN (Position 9).
9
+ */
10
+ declare const VIN_CHECK_DIGIT_INDEX = 8;
11
+ /**
12
+ * The modulus used in the VIN checksum calculation.
13
+ */
14
+ declare const VIN_MODULUS = 11;
15
+ /**
16
+ * The character representing a checksum value of 10.
17
+ */
18
+ declare const VIN_CHECK_DIGIT_X = "X";
19
+ /**
20
+ * Weights used in the VIN checksum calculation.
21
+ * Each position (1-17) is multiplied by its corresponding weight.
22
+ * Position 9 is the check digit itself (weight 0).
23
+ */
24
+ declare const VIN_WEIGHTS: number[];
25
+ /**
26
+ * Values assigned to each valid character for VIN calculation.
27
+ * Invalid characters: I, O, Q are not allowed in VIN.
28
+ */
29
+ declare const VIN_CHAR_VALUES: Record<string, number>;
30
+ /**
31
+ * Characters excluded from VIN (I, O, Q).
32
+ */
33
+ declare const EXCLUDED_VIN_CHARS: string[];
34
+ /**
35
+ * Version of the VIN utility module.
36
+ */
37
+ declare const VIN_VERSION = "1.0.0";
38
+
39
+ export { EXCLUDED_VIN_CHARS, VIN_CHAR_VALUES, VIN_CHECK_DIGIT_INDEX, VIN_CHECK_DIGIT_X, VIN_LENGTH, VIN_MODULUS, VIN_VERSION, VIN_WEIGHTS };
@@ -0,0 +1,39 @@
1
+ export { V as VINOptions, a as VINValidationResult, v as validateVIN } from '../types-i5e6R0AS.js';
2
+
3
+ /**
4
+ * The standard length of a VIN (ISO 3779).
5
+ */
6
+ declare const VIN_LENGTH = 17;
7
+ /**
8
+ * The 0-based index of the check digit in the VIN (Position 9).
9
+ */
10
+ declare const VIN_CHECK_DIGIT_INDEX = 8;
11
+ /**
12
+ * The modulus used in the VIN checksum calculation.
13
+ */
14
+ declare const VIN_MODULUS = 11;
15
+ /**
16
+ * The character representing a checksum value of 10.
17
+ */
18
+ declare const VIN_CHECK_DIGIT_X = "X";
19
+ /**
20
+ * Weights used in the VIN checksum calculation.
21
+ * Each position (1-17) is multiplied by its corresponding weight.
22
+ * Position 9 is the check digit itself (weight 0).
23
+ */
24
+ declare const VIN_WEIGHTS: number[];
25
+ /**
26
+ * Values assigned to each valid character for VIN calculation.
27
+ * Invalid characters: I, O, Q are not allowed in VIN.
28
+ */
29
+ declare const VIN_CHAR_VALUES: Record<string, number>;
30
+ /**
31
+ * Characters excluded from VIN (I, O, Q).
32
+ */
33
+ declare const EXCLUDED_VIN_CHARS: string[];
34
+ /**
35
+ * Version of the VIN utility module.
36
+ */
37
+ declare const VIN_VERSION = "1.0.0";
38
+
39
+ export { EXCLUDED_VIN_CHARS, VIN_CHAR_VALUES, VIN_CHECK_DIGIT_INDEX, VIN_CHECK_DIGIT_X, VIN_LENGTH, VIN_MODULUS, VIN_VERSION, VIN_WEIGHTS };
@@ -0,0 +1,74 @@
1
+ // src/vin/constants.ts
2
+ var VIN_LENGTH = 17;
3
+ var VIN_CHECK_DIGIT_INDEX = 8;
4
+ var VIN_MODULUS = 11;
5
+ var VIN_CHECK_DIGIT_X = "X";
6
+ var VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
7
+ var VIN_CHAR_VALUES = {
8
+ "0": 0,
9
+ "1": 1,
10
+ "2": 2,
11
+ "3": 3,
12
+ "4": 4,
13
+ "5": 5,
14
+ "6": 6,
15
+ "7": 7,
16
+ "8": 8,
17
+ "9": 9,
18
+ "A": 1,
19
+ "B": 2,
20
+ "C": 3,
21
+ "D": 4,
22
+ "E": 5,
23
+ "F": 6,
24
+ "G": 7,
25
+ "H": 8,
26
+ "J": 1,
27
+ "K": 2,
28
+ "L": 3,
29
+ "M": 4,
30
+ "N": 5,
31
+ "P": 7,
32
+ "R": 9,
33
+ "S": 2,
34
+ "T": 3,
35
+ "U": 4,
36
+ "V": 5,
37
+ "W": 6,
38
+ "X": 7,
39
+ "Y": 8,
40
+ "Z": 9
41
+ };
42
+ var EXCLUDED_VIN_CHARS = ["I", "O", "Q"];
43
+ var VIN_VERSION = "1.0.0";
44
+
45
+ // src/vin/validate.ts
46
+ function validateVIN(vin) {
47
+ if (!vin || vin.length !== VIN_LENGTH) {
48
+ return false;
49
+ }
50
+ const normalizedVIN = vin.toUpperCase();
51
+ for (const char of EXCLUDED_VIN_CHARS) {
52
+ if (normalizedVIN.includes(char)) {
53
+ return false;
54
+ }
55
+ }
56
+ let sum = 0;
57
+ for (let i = 0; i < VIN_LENGTH; i++) {
58
+ const char = normalizedVIN[i];
59
+ const weight = VIN_WEIGHTS[i];
60
+ const val = VIN_CHAR_VALUES[char];
61
+ if (val === void 0) {
62
+ return false;
63
+ }
64
+ sum += val * weight;
65
+ }
66
+ const checkDigitValue = sum % VIN_MODULUS;
67
+ const expectedCheckDigit = checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();
68
+ const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];
69
+ return actualCheckDigit === expectedCheckDigit;
70
+ }
71
+
72
+ export { EXCLUDED_VIN_CHARS, VIN_CHAR_VALUES, VIN_CHECK_DIGIT_INDEX, VIN_CHECK_DIGIT_X, VIN_LENGTH, VIN_MODULUS, VIN_VERSION, VIN_WEIGHTS, validateVIN };
73
+ //# sourceMappingURL=index.js.map
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/vin/constants.ts","../../src/vin/validate.ts"],"names":[],"mappings":";AAGO,IAAM,UAAA,GAAa;AAKnB,IAAM,qBAAA,GAAwB;AAK9B,IAAM,WAAA,GAAc;AAKpB,IAAM,iBAAA,GAAoB;AAO1B,IAAM,cAAc,CAAC,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,EAAA,EAAI,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAC;AAMvE,IAAM,eAAA,GAA0C;AAAA,EACrD,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAC7E,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAC7D,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,EAAK,CAAA;AAAA,EAAG,GAAA,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B,GAAA,GAAM,WAAA;AAC9B,EAAA,MAAM,kBAAA,GACJ,eAAA,KAAoB,EAAA,GAAK,iBAAA,GAAoB,gBAAgB,QAAA,EAAS;AACxE,EAAA,MAAM,gBAAA,GAAmB,cAAc,qBAAqB,CAAA;AAE5D,EAAA,OAAO,gBAAA,KAAqB,kBAAA;AAC9B","file":"index.js","sourcesContent":["/**\n * The standard length of a VIN (ISO 3779).\n */\nexport const VIN_LENGTH = 17;\n\n/**\n * The 0-based index of the check digit in the VIN (Position 9).\n */\nexport const VIN_CHECK_DIGIT_INDEX = 8;\n\n/**\n * The modulus used in the VIN checksum calculation.\n */\nexport const VIN_MODULUS = 11;\n\n/**\n * The character representing a checksum value of 10.\n */\nexport const VIN_CHECK_DIGIT_X = 'X';\n\n/**\n * Weights used in the VIN checksum calculation.\n * Each position (1-17) is multiplied by its corresponding weight.\n * Position 9 is the check digit itself (weight 0).\n */\nexport const VIN_WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];\n\n/**\n * Values assigned to each valid character for VIN calculation.\n * Invalid characters: I, O, Q are not allowed in VIN.\n */\nexport const VIN_CHAR_VALUES: Record<string, number> = {\n '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,\n 'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8,\n 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9,\n 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9,\n};\n\n/**\n * Characters excluded from VIN (I, O, Q).\n */\nexport const EXCLUDED_VIN_CHARS = ['I', 'O', 'Q'];\n\n/**\n * Version of the VIN utility module.\n */\nexport const VIN_VERSION = '1.0.0';\n\n","import {\n VIN_WEIGHTS,\n VIN_CHAR_VALUES,\n EXCLUDED_VIN_CHARS,\n VIN_LENGTH,\n VIN_CHECK_DIGIT_INDEX,\n VIN_MODULUS,\n VIN_CHECK_DIGIT_X,\n} from './constants';\n\n/**\n * Validates a Vehicle Identification Number (VIN) based on ISO 3779.\n *\n * Checks for:\n * - Exactly 17 characters length.\n * - Exclusion of characters I, O, and Q.\n * - Checksum validation using the check digit at position 9.\n *\n * @param vin - The VIN string to validate\n * @returns boolean indicating if the VIN is valid\n *\n * @example\n * ```typescript\n * import { validateVIN } from '@indodev/toolkit/vin';\n *\n * validateVIN('1HBHA82L7ZB000001'); // true\n * validateVIN('1HBHA82I7ZB000001'); // false (contains 'I')\n * ```\n */\nexport function validateVIN(vin: string): boolean {\n if (!vin || vin.length !== VIN_LENGTH) {\n return false;\n }\n\n const normalizedVIN = vin.toUpperCase();\n\n // 1. Check for excluded characters (I, O, Q)\n for (const char of EXCLUDED_VIN_CHARS) {\n if (normalizedVIN.includes(char)) {\n return false;\n }\n }\n\n // 2. Checksum validation (Position 9)\n let sum = 0;\n for (let i = 0; i < VIN_LENGTH; i++) {\n const char = normalizedVIN[i];\n const weight = VIN_WEIGHTS[i];\n const val = VIN_CHAR_VALUES[char];\n\n if (val === undefined) {\n return false; // Invalid character found\n }\n\n sum += val * weight;\n }\n\n const checkDigitValue = sum % VIN_MODULUS;\n const expectedCheckDigit =\n checkDigitValue === 10 ? VIN_CHECK_DIGIT_X : checkDigitValue.toString();\n const actualCheckDigit = normalizedVIN[VIN_CHECK_DIGIT_INDEX];\n\n return actualCheckDigit === expectedCheckDigit;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indodev/toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Indonesian developer utilities for validation, formatting, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -57,6 +57,36 @@
57
57
  "types": "./dist/text/index.d.cts",
58
58
  "default": "./dist/text/index.cjs"
59
59
  }
60
+ },
61
+ "./npwp": {
62
+ "import": {
63
+ "types": "./dist/npwp/index.d.ts",
64
+ "default": "./dist/npwp/index.js"
65
+ },
66
+ "require": {
67
+ "types": "./dist/npwp/index.d.cts",
68
+ "default": "./dist/npwp/index.cjs"
69
+ }
70
+ },
71
+ "./plate": {
72
+ "import": {
73
+ "types": "./dist/plate/index.d.ts",
74
+ "default": "./dist/plate/index.js"
75
+ },
76
+ "require": {
77
+ "types": "./dist/plate/index.d.cts",
78
+ "default": "./dist/plate/index.cjs"
79
+ }
80
+ },
81
+ "./vin": {
82
+ "import": {
83
+ "types": "./dist/vin/index.d.ts",
84
+ "default": "./dist/vin/index.js"
85
+ },
86
+ "require": {
87
+ "types": "./dist/vin/index.d.cts",
88
+ "default": "./dist/vin/index.cjs"
89
+ }
60
90
  }
61
91
  },
62
92
  "files": [
@@ -68,6 +98,22 @@
68
98
  "access": "public",
69
99
  "registry": "https://registry.npmjs.org/"
70
100
  },
101
+ "scripts": {
102
+ "dev": "tsup --watch",
103
+ "build": "tsup",
104
+ "test": "vitest",
105
+ "test:ui": "vitest --ui",
106
+ "test:coverage": "vitest --coverage",
107
+ "test:run": "vitest run",
108
+ "typecheck": "tsc --noEmit",
109
+ "lint": "eslint src --ext .ts",
110
+ "lint:fix": "eslint src --ext .ts --fix",
111
+ "format": "prettier --write \"src/**/*.ts\"",
112
+ "format:check": "prettier --check \"src/**/*.ts\"",
113
+ "prepublish:only": "pnpm run build && pnpm run test:run && publint",
114
+ "changeset": "changeset",
115
+ "release": "changeset publish"
116
+ },
71
117
  "keywords": [
72
118
  "indonesia",
73
119
  "indonesian",
@@ -122,21 +168,5 @@
122
168
  "typescript-eslint": "^8.49.0",
123
169
  "vitest": "^2.1.8",
124
170
  "zod": "^3.24.1"
125
- },
126
- "scripts": {
127
- "dev": "tsup --watch",
128
- "build": "tsup",
129
- "test": "vitest",
130
- "test:ui": "vitest --ui",
131
- "test:coverage": "vitest --coverage",
132
- "test:run": "vitest run",
133
- "typecheck": "tsc --noEmit",
134
- "lint": "eslint src --ext .ts",
135
- "lint:fix": "eslint src --ext .ts --fix",
136
- "format": "prettier --write \"src/**/*.ts\"",
137
- "format:check": "prettier --check \"src/**/*.ts\"",
138
- "prepublish:only": "pnpm run build && pnpm run test:run && publint",
139
- "changeset": "changeset",
140
- "release": "changeset publish"
141
171
  }
142
- }
172
+ }
package/LICENCE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Adamm
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.