We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1ead8a commit a2b4e1eCopy full SHA for a2b4e1e
src/index.ts
@@ -15,17 +15,16 @@ export default function isValidNIP(rawNip: string | number): boolean {
15
16
// calculate checksum
17
let sum = 0;
18
- for (let position = 0; position < weights.length; position += 1) {
19
- const weight = weights[position];
20
- const digit = parseInt(nip[position], 10);
+ weights.forEach((weight, position) => {
+ const digit = Number(nip[position]);
21
sum += weight * digit;
22
- }
+ });
23
24
const checksum = sum % 11;
25
26
if (checksum === 10) {
27
return false;
28
}
29
30
- return checksum === parseInt(nip[9], 10);
+ return checksum === Number(nip[9]);
31
0 commit comments