nationid - v2.2.1
    Preparing search index...

    Function cycleWeights

    • 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.

      Parameters

      • base: readonly number[]

        Non-empty base weight sequence to cycle.

      • length: number

        Desired output length (must equal the digit count).

      Returns number[]

      A fresh array of length weights aligned with left-to-right digits.

      if base is empty.

      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]