Build a weight array by cycling a base sequence to a target length, applied right-to-left then reversed so it lines up with left-to-right digits.
Used by CL RUT (cycle 2..7 right-to-left) and other variants that need a right-aligned cyclic weight pattern.
2..7
Non-empty base weight sequence to cycle.
Desired output length (must equal the digit count).
A fresh array of length weights aligned with left-to-right digits.
length
if base is empty.
base
import { cycleWeights } from "nationid/algorithms";cycleWeights([2,3,4,5,6,7], 9); // [4,3,2,7,6,5,4,3,2] (CL RUT pattern)cycleWeights([2,3,4,5,6,7], 8); // [3,2,7,6,5,4,3,2] Copy
import { cycleWeights } from "nationid/algorithms";cycleWeights([2,3,4,5,6,7], 9); // [4,3,2,7,6,5,4,3,2] (CL RUT pattern)cycleWeights([2,3,4,5,6,7], 8); // [3,2,7,6,5,4,3,2]
Build a weight array by cycling a base sequence to a target length, applied right-to-left then reversed so it lines up with left-to-right digits.
Used by CL RUT (cycle
2..7right-to-left) and other variants that need a right-aligned cyclic weight pattern.