ts-data-forge
    Preparing search index...
    • Flattens nested arrays up to the specified depth.

      Type Parameters

      • const Ar extends readonly unknown[]
      • D extends SafeUintWithSmallInt = 1

      Parameters

      • array: Ar
      • Optionaldepth: D

      Returns readonly FlatArray<Ar, D>[]

      const nested = [
      [1, 2],
      [3, 4],
      ] as const;

      const flatOnce = Arr.flat(nested, 1);
      const flatCurried = Arr.flat()(nested);

      assert.deepStrictEqual(flatOnce, [1, 2, 3, 4]);
      assert.deepStrictEqual(flatCurried, [1, 2, 3, 4]);
    • Flattens nested arrays up to the specified depth.

      Type Parameters

      • D extends SafeUintWithSmallInt = 1

      Parameters

      • Optionaldepth: number

      Returns <const Ar extends readonly unknown[]>(array: Ar) => readonly FlatArray<Ar, D>[]

      const nested = [
      [1, 2],
      [3, 4],
      ] as const;

      const flatOnce = Arr.flat(nested, 1);
      const flatCurried = Arr.flat()(nested);

      assert.deepStrictEqual(flatOnce, [1, 2, 3, 4]);
      assert.deepStrictEqual(flatCurried, [1, 2, 3, 4]);