ixfx
    Preparing search index...

    Function cycle

    • Cycle through the contents of an array. By default starts at index 0.

      const c = arrayCycle([`apples`, `oranges`, `pears`]);
      c.current; // `apples`
      c.next(); // `oranges`
      c.next(); // `pears`
      c.next(); // `apples`
      c.prev(); // `pears`

      You can select an item by index or value:

      c.select(1); // `oranges`
      c.select(`pears`); // `pears`

      Other features:

      c.current;   // Current value
      c.toArray(); // Copy of array being cycled over

      Additional info:

      • Selecting by value uses === semantics.
      • Works with a copy of input array

      Type Parameters

      • T

      Parameters

      • options: readonly T[] | T[]

        Array to cycle over

      Returns {
          next: () => T;
          prev: () => T;
          select: (indexOrValue: number | T) => void;
          toArray: () => T[];
          get current(): T;
      }