@alwatr/iranian-national-code-validator 2.0.1 → 9.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 CHANGED
@@ -2,6 +2,7 @@ Mozilla Public License Version 2.0
2
2
  ==================================
3
3
 
4
4
  1. Definitions
5
+
5
6
  --------------
6
7
 
7
8
  1.1. "Contributor"
@@ -83,7 +84,8 @@ Mozilla Public License Version 2.0
83
84
  fifty percent (50%) of the outstanding shares or beneficial
84
85
  ownership of such entity.
85
86
 
86
- 2. License Grants and Conditions
87
+ 1. License Grants and Conditions
88
+
87
89
  --------------------------------
88
90
 
89
91
  2.1. Grants
@@ -154,7 +156,8 @@ equivalents.
154
156
  Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
157
  in Section 2.1.
156
158
 
157
- 3. Responsibilities
159
+ 1. Responsibilities
160
+
158
161
  -------------------
159
162
 
160
163
  3.1. Distribution of Source Form
@@ -216,7 +219,8 @@ indemnity or liability terms You offer. You may include additional
216
219
  disclaimers of warranty and limitations of liability specific to any
217
220
  jurisdiction.
218
221
 
219
- 4. Inability to Comply Due to Statute or Regulation
222
+ 1. Inability to Comply Due to Statute or Regulation
223
+
220
224
  ---------------------------------------------------
221
225
 
222
226
  If it is impossible for You to comply with any of the terms of this
@@ -229,7 +233,8 @@ Software under this License. Except to the extent prohibited by statute
229
233
  or regulation, such description must be sufficiently detailed for a
230
234
  recipient of ordinary skill to be able to understand it.
231
235
 
232
- 5. Termination
236
+ 1. Termination
237
+
233
238
  --------------
234
239
 
235
240
  5.1. The rights granted under this License will terminate automatically
@@ -259,48 +264,53 @@ have been validly granted by You or Your distributors under this License
259
264
  prior to termination shall survive termination.
260
265
 
261
266
  ************************************************************************
267
+
262
268
  * *
263
- * 6. Disclaimer of Warranty *
264
- * ------------------------- *
269
+ * 1. Disclaimer of Warranty *
270
+ * ------------------------- *
265
271
  * *
266
- * Covered Software is provided under this License on an "as is" *
267
- * basis, without warranty of any kind, either expressed, implied, or *
268
- * statutory, including, without limitation, warranties that the *
269
- * Covered Software is free of defects, merchantable, fit for a *
270
- * particular purpose or non-infringing. The entire risk as to the *
271
- * quality and performance of the Covered Software is with You. *
272
- * Should any Covered Software prove defective in any respect, You *
273
- * (not any Contributor) assume the cost of any necessary servicing, *
274
- * repair, or correction. This disclaimer of warranty constitutes an *
275
- * essential part of this License. No use of any Covered Software is *
276
- * authorized under this License except under this disclaimer. *
272
+ * Covered Software is provided under this License on an "as is" *
273
+ * basis, without warranty of any kind, either expressed, implied, or *
274
+ * statutory, including, without limitation, warranties that the *
275
+ * Covered Software is free of defects, merchantable, fit for a *
276
+ * particular purpose or non-infringing. The entire risk as to the *
277
+ * quality and performance of the Covered Software is with You. *
278
+ * Should any Covered Software prove defective in any respect, You *
279
+ * (not any Contributor) assume the cost of any necessary servicing, *
280
+ * repair, or correction. This disclaimer of warranty constitutes an *
281
+ * essential part of this License. No use of any Covered Software is *
282
+ * authorized under this License except under this disclaimer. *
277
283
  * *
284
+
278
285
  ************************************************************************
279
286
 
280
287
  ************************************************************************
288
+
281
289
  * *
282
- * 7. Limitation of Liability *
283
- * -------------------------- *
290
+ * 1. Limitation of Liability *
291
+ * -------------------------- *
284
292
  * *
285
- * Under no circumstances and under no legal theory, whether tort *
286
- * (including negligence), contract, or otherwise, shall any *
287
- * Contributor, or anyone who distributes Covered Software as *
288
- * permitted above, be liable to You for any direct, indirect, *
289
- * special, incidental, or consequential damages of any character *
290
- * including, without limitation, damages for lost profits, loss of *
291
- * goodwill, work stoppage, computer failure or malfunction, or any *
292
- * and all other commercial damages or losses, even if such party *
293
- * shall have been informed of the possibility of such damages. This *
294
- * limitation of liability shall not apply to liability for death or *
295
- * personal injury resulting from such party's negligence to the *
296
- * extent applicable law prohibits such limitation. Some *
297
- * jurisdictions do not allow the exclusion or limitation of *
298
- * incidental or consequential damages, so this exclusion and *
299
- * limitation may not apply to You. *
293
+ * Under no circumstances and under no legal theory, whether tort *
294
+ * (including negligence), contract, or otherwise, shall any *
295
+ * Contributor, or anyone who distributes Covered Software as *
296
+ * permitted above, be liable to You for any direct, indirect, *
297
+ * special, incidental, or consequential damages of any character *
298
+ * including, without limitation, damages for lost profits, loss of *
299
+ * goodwill, work stoppage, computer failure or malfunction, or any *
300
+ * and all other commercial damages or losses, even if such party *
301
+ * shall have been informed of the possibility of such damages. This *
302
+ * limitation of liability shall not apply to liability for death or *
303
+ * personal injury resulting from such party's negligence to the *
304
+ * extent applicable law prohibits such limitation. Some *
305
+ * jurisdictions do not allow the exclusion or limitation of *
306
+ * incidental or consequential damages, so this exclusion and *
307
+ * limitation may not apply to You. *
300
308
  * *
309
+
301
310
  ************************************************************************
302
311
 
303
- 8. Litigation
312
+ 1. Litigation
313
+
304
314
  -------------
305
315
 
306
316
  Any litigation relating to this License may be brought only in the
@@ -310,7 +320,8 @@ jurisdiction, without reference to its conflict-of-law provisions.
310
320
  Nothing in this Section shall prevent a party's ability to bring
311
321
  cross-claims or counter-claims.
312
322
 
313
- 9. Miscellaneous
323
+ 1. Miscellaneous
324
+
314
325
  ----------------
315
326
 
316
327
  This License represents the complete agreement concerning the subject
@@ -320,7 +331,8 @@ necessary to make it enforceable. Any law or regulation which provides
320
331
  that the language of a contract shall be construed against the drafter
321
332
  shall not be used to construe this License against a Contributor.
322
333
 
323
- 10. Versions of the License
334
+ 1. Versions of the License
335
+
324
336
  ---------------------------
325
337
 
326
338
  10.1. New Versions
@@ -357,7 +369,7 @@ Exhibit A - Source Code Form License Notice
357
369
 
358
370
  This Source Code Form is subject to the terms of the Mozilla Public
359
371
  License, v. 2.0. If a copy of the MPL was not distributed with this
360
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
372
+ file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
361
373
 
362
374
  If it is not possible or desirable to put the notice in a particular
363
375
  file, then You may include the notice in a location (such as a LICENSE
@@ -370,4 +382,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
382
  ---------------------------------------------------------
371
383
 
372
384
  This Source Code Form is "Incompatible With Secondary Licenses", as
373
- defined by the Mozilla Public License, v. 2.0.
385
+ defined by the Mozilla Public License, v. 2.0.
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- /* 📦 @alwatr/iranian-national-code-validator v2.0.1 */
1
+ /* 📦 @alwatr/iranian-national-code-validator v9.1.0 */
2
2
  function n(i){if(!/^\d{10}$/.test(i))return!1;let a=+i[9],e=i.split("").slice(0,9).reduce((t,o,l)=>t+ +o*(10-l),0)%11;return e<2?a===e:a+e===11}export{n as isValidIranianNationalCode};
3
3
 
4
- //# debugId=9DFBA588E70979FA64756E2164756E21
4
+ //# debugId=CFF192B562F4675064756E2164756E21
5
5
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -5,6 +5,6 @@
5
5
  "/**\n * Validates an Iranian National Code (Code Melli).\n *\n * The validation is based on the official algorithm:\n * 1. The code must be 10 digits.\n * 2. The last digit is a check digit.\n * 3. A weighted sum of the first 9 digits is calculated.\n * 4. The remainder of the sum divided by 11 is compared with the check digit based on a specific rule.\n *\n * @param str The Iranian National Code to validate.\n * @returns `true` if the national code is valid, `false` otherwise.\n *\n * @example\n * ```ts\n * console.log(isValidIranianNationalCode('0018550152')); // true\n * console.log(isValidIranianNationalCode('0018550153')); // false\n * console.log(isValidIranianNationalCode('12345')); // false\n * ```\n */\nexport function isValidIranianNationalCode(str: string): boolean {\n if (!/^\\d{10}$/.test(str)) return false;\n\n const check = +str[9];\n const sum = str.split('').slice(0, 9).reduce((acc, x, i) => acc + +x * (10 - i), 0) % 11;\n\n return sum < 2 ? check === sum : check + sum === 11;\n}\n"
6
6
  ],
7
7
  "mappings": ";AAmBO,SAAS,CAA0B,CAAC,EAAsB,CAC/D,GAAI,CAAC,WAAW,KAAK,CAAG,EAAG,MAAO,GAElC,IAAM,EAAQ,CAAC,EAAI,GACb,EAAM,EAAI,MAAM,EAAE,EAAE,MAAM,EAAG,CAAC,EAAE,OAAO,CAAC,EAAK,EAAG,IAAM,GAAM,CAAC,GAAK,GAAK,GAAI,CAAC,EAAI,GAEtF,OAAO,EAAM,EAAI,IAAU,EAAM,EAAQ,IAAQ",
8
- "debugId": "9DFBA588E70979FA64756E2164756E21",
8
+ "debugId": "CFF192B562F4675064756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
1
  {
2
2
  "name": "@alwatr/iranian-national-code-validator",
3
- "version": "2.0.1",
3
+ "version": "9.1.0",
4
4
  "description": "A tiny TypeScript library to Validates an Iranian National Code (Code Melli).",
5
5
  "license": "MPL-2.0",
6
- "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
+ "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
7
7
  "type": "module",
8
8
  "repository": {
9
- "directory": "packages/iranian-national-code-validator",
10
9
  "type": "git",
11
- "url": "https://github.com/Alwatr/nanolib"
10
+ "url": "https://github.com/Alwatr/alwatr",
11
+ "directory": "pkg/nanolib/iranian-national-code-validator"
12
12
  },
13
- "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/iranian-national-code-validator#readme",
14
- "bugs": "https://github.com/Alwatr/nanolib/issues",
13
+ "homepage": "https://github.com/Alwatr/alwatr/tree/main/pkg/nanolib/iranian-national-code-validator#readme",
14
+ "bugs": "https://github.com/Alwatr/alwatr/issues",
15
15
  "exports": {
16
16
  ".": {
17
17
  "types": "./dist/main.d.ts",
18
+ "import": "./dist/main.js",
18
19
  "default": "./dist/main.js"
19
20
  }
20
21
  },
21
22
  "sideEffects": false,
22
23
  "devDependencies": {
23
- "@alwatr/nano-build": "7.0.1",
24
- "@alwatr/prettier-config": "7.0.1",
25
- "@alwatr/tsconfig-base": "8.0.0",
26
- "@alwatr/type-helper": "8.0.1",
27
- "typescript": "^5.9.3"
24
+ "@alwatr/nano-build": "9.1.0",
25
+ "@alwatr/tsconfig-base": "9.1.0",
26
+ "@alwatr/type-helper": "9.1.0",
27
+ "typescript": "^6.0.2"
28
28
  },
29
29
  "scripts": {
30
30
  "b": "bun run build",
31
31
  "build": "bun run build:ts && bun run build:es",
32
32
  "build:es": "nano-build --preset=module src/main.ts",
33
33
  "build:ts": "tsc --build",
34
- "c": "bun run clean",
35
- "cb": "bun run clean && bun run build",
34
+ "cl": "bun run clean",
36
35
  "clean": "rm -rfv dist *.tsbuildinfo",
37
- "d": "bun run build:es && bun",
36
+ "format": "prettier --write \"src/**/*.ts\"",
37
+ "lint": "eslint src/ --ext .ts",
38
38
  "t": "bun run test",
39
- "test": "bun test",
39
+ "test": "ALWATR_DEBUG=0 bun test",
40
40
  "w": "bun run watch",
41
41
  "watch": "bun run watch:ts & bun run watch:es",
42
42
  "watch:es": "bun run build:es --watch",
43
43
  "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
44
44
  },
45
45
  "files": [
46
- "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
46
+ "dist",
47
+ "src/**/*.ts",
48
+ "!src/**/*.test.ts",
47
49
  "README.md",
48
- "LICENSE",
49
- "!demo/**/*",
50
- "!**/*.test.js"
50
+ "LICENSE"
51
51
  ],
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -69,6 +69,5 @@
69
69
  "utils",
70
70
  "validator"
71
71
  ],
72
- "prettier": "@alwatr/prettier-config",
73
- "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
72
+ "gitHead": "4a25cd3e0499cf61dd761e87d3711abf9b0cd208"
74
73
  }