UNPKG

@arrows/array

Version:
25 lines (24 loc) 743 B
declare type Curry1<T> = (arr: T[]) => T[]; declare type Curry2<T> = { (index: number): Curry1<T>; (index: number, arr: T[]): T[]; }; declare type Curry3 = { <T>(value: T): Curry2<T>; <T>(value: T, index: number): Curry1<T>; }; declare type _Insert_ = <T>(value: T, index: number, arr: T[]) => T[]; declare type Insert_ = _Insert_ & Curry3; /** * Creates a new array with an additional value at the provided index. * Shifts old values to the right. * If the index is out of bound of the array - adds a value as a last element. * * @param value Additional value * @param index Specific index * @param arr Initial array * @returns New array */ declare const insert_: Insert_; export { insert_ }; export default insert_;