ixfx
    Preparing search index...

    Function atWrap

    • Similar to Javascript's in-built Array.at function, but allows offsets to wrap.

      Type Parameters

      • V

      Parameters

      • array: V[]

        Array

      • index: number

        Index

      Returns V

      const test = [1,2,3,4,5,6];
      atWrap(0); // 1
      atWrap(-1); // 6
      atWrap(-6); // 1

      These values would return undefined using Array.at since its beyond the length of the array

      atWrap(6);   // 1
      atWrap(-7); // 6