ixfx
    Preparing search index...

    Function zip

    • Zip combines the elements of two or more arrays based on their index.

      const a = [ 1, 2, 3 ];
      const b = [ `red`, `blue`, `green` ];

      const c = Arrays.zip(a, b);
      // Yields:
      // [
      // [ 1, `red` ],
      // [ 2, `blue` ],
      // [ 3, `green` ]
      // ]

      Typically the arrays you zip together are all about the same logical item. Eg, in the above example perhaps a is size and b is colour. So thing #1 (at array index 0) is a red thing of size 1. Before zipping we'd access it by a[0] and b[0]. After zipping, we'd have c[0], which is array of [1, red].

      Type Parameters

      • T extends readonly (readonly unknown[])[]

      Parameters

      • ...arrays: T

      Returns ZippedTuple<T>[]

      Zipped together array

      If any of the parameters are not arrays

      If the arrays are not all of the same length