We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5591554 commit 277854fCopy full SHA for 277854f
lib/Check.js
@@ -6,6 +6,8 @@ module.exports = class {
6
this.checkSumLength = checkSumLength
7
this.totalLength = totalLength
8
9
+ this.modulus = 10; for (let i = 1; i < checkSumLength; i ++) this.modulus *= 10
10
+
11
}
12
13
raise (s, o) {
@@ -54,11 +56,9 @@ module.exports = class {
54
56
55
57
this.process (str)
58
- const {sum} = this; delete this.sum
-
59
- return String (this.checkSumLength === 1 ? sum % 11 % 10 : sum % 101 % 100)
+ const {sum, modulus} = this; delete this.sum
60
61
- .padStart (this.checkSumLength, '0')
+ return String (sum % (modulus + 1) % modulus).padStart (this.checkSumLength, '0')
62
63
64
0 commit comments