@monstermann/fn
Version:
A utility library for TypeScript.
22 lines • 659 B
TypeScript
//#region src/array/insertAt.d.ts
/**
* `insertAt(array, index, value)`
*
* Inserts `value` at the specified `index` in `array`, returning a new array with the inserted element.
*
* ```ts
* insertAt([1, 2, 3], 1, 10); // [1, 10, 2, 3]
* ```
*
* ```ts
* pipe([1, 2, 3], insertAt(1, 10)); // [1, 10, 2, 3]
* ```
*/
declare const insertAt: {
<T>(idx: number, value: NoInfer<T>): (target: T[]) => T[];
<T>(idx: number, value: NoInfer<T>): (target: readonly T[]) => readonly T[];
<T>(target: T[], idx: number, value: NoInfer<T>): T[];
<T>(target: readonly T[], idx: number, value: NoInfer<T>): readonly T[];
};
//#endregion
export { insertAt };