Compute weighted sum mod 11, given digits and weights.
Weights are applied 1-to-1 with digits from left to right. If weights
is shorter than digits, an error is thrown — country-specific code must
pre-extend or cycle weights as needed.
Returns the raw sum (NOT yet mod 11). Country-specific code typically
applies 11 - (sum % 11) and maps the special cases (0 / 10 / 11) per
its own variant.
Parameters
digits: string
Digit-only string. Each char must be '0'..'9'.
weights: readonlynumber[]
Array of integer weights with weights.length === digits.length.
Returns number
The raw weighted sum (not yet reduced).
Throws
if digits and weights differ in length, or if digits
contains a non-digit character.
Compute weighted sum mod 11, given digits and weights.
Weights are applied 1-to-1 with
digitsfrom left to right. Ifweightsis shorter thandigits, an error is thrown — country-specific code must pre-extend or cycle weights as needed.Returns the raw sum (NOT yet mod 11). Country-specific code typically applies
11 - (sum % 11)and maps the special cases (0 / 10 / 11) per its own variant.