ts-data-forge
    Preparing search index...
    • Returns a new array with a value prepended to the beginning.

      Type Parameters

      • const Ar extends readonly unknown[]
      • const V

      Parameters

      • array: Ar
      • newValue: V

      Returns readonly [V, Ar]

      const base = [2, 3] as const;

      const prefixed = Arr.toUnshifted(base, 1);
      const prefixedCurried = Arr.toUnshifted(0)(base);

      assert.deepStrictEqual(prefixed, [1, 2, 3]);
      assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);
    • Returns a new array with a value prepended to the beginning.

      Type Parameters

      • const V

      Parameters

      • newValue: V

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

      const base = [2, 3] as const;

      const prefixed = Arr.toUnshifted(base, 1);
      const prefixedCurried = Arr.toUnshifted(0)(base);

      assert.deepStrictEqual(prefixed, [1, 2, 3]);
      assert.deepStrictEqual(prefixedCurried, [0, 2, 3]);