nik-parser-indonesia 1.0.0 → 1.0.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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/NikParser.js +4 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nik-parser-indonesia",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Library untuk melakukan parsing NIK (No Induk Kependudukan) Indonesia untuk mendapatkan info daerah, jenis kelamin, dan tanggal lahir.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,4 +17,4 @@
17
17
  "author": "Zealish",
18
18
  "license": "MIT",
19
19
  "dependencies": {}
20
- }
20
+ }
package/src/NikParser.js CHANGED
@@ -1,10 +1,7 @@
1
- // src/NikParser.js
2
- const path = require("path");
3
-
4
1
  class NikParser {
5
2
  constructor() {
6
- // Langsung load data wilayah secara internal dari folder data
7
3
  try {
4
+ // Memuat data JSON wilayah secara internal
8
5
  this.dataWilayah = require("../data/data_wilayah.json");
9
6
  } catch (error) {
10
7
  throw new Error(
@@ -43,7 +40,7 @@ class NikParser {
43
40
 
44
41
  const padTanggal = String(tanggal).padStart(2, "0");
45
42
 
46
- // Aturan Abad: Jika tahun lahir > 26 (Asumsi tahun berjalan 2026), berarti lahir di tahun 19xx
43
+ // Aturan Abad: Jika tahun lahir > 26 (Tahun berjalan 2026), berarti lahir di tahun 19xx
47
44
  const tahunPenuh = parseInt(tahun, 10) > 26 ? `19${tahun}` : `20${tahun}`;
48
45
  const tanggalLahirFull = `${padTanggal}-${bulan}-${tahunPenuh}`;
49
46
 
@@ -57,9 +54,9 @@ class NikParser {
57
54
  if (!provinsi)
58
55
  return { valid: false, error: "Kode Provinsi pada NIK tidak terdaftar" };
59
56
 
60
- // Cari Kabupaten/Kota
57
+ // Cari Kabupaten/Kota (Sudah difix di sini 👍)
61
58
  const kabupaten = provinsi.kabupaten.find((k) => k.code === kodeKab);
62
- if (!browse_result)
59
+ if (!kabupaten)
63
60
  return {
64
61
  valid: false,
65
62
  error: "Kode Kabupaten/Kota pada NIK tidak terdaftar",