UNPKG

@arrows/array

Version:
27 lines (26 loc) 843 B
declare type UpdaterFn<T> = (value: T) => T; declare type Curry1<T> = (arr: T[]) => T[]; declare type Curry2<T> = { (index: number): Curry1<T>; (index: number, arr: T[]): T[]; }; declare type Curry3 = { <T>(updaterFn: UpdaterFn<T>): Curry2<T>; <T>(reducingFn: UpdaterFn<T>, index: number): Curry1<T>; }; declare type _Update_ = <T>(updaterFn: UpdaterFn<T>, index: number, arr: T[]) => T[]; declare type Update_ = _Update_ & Curry3; /** * Creates a new array with a new value at the provided index, * calculated by updater function that maps an old value into a new one. * * If the index is out of bound of the array throws an error. * * @param value New value * @param index Specific index * @param arr Initial array * @returns New array */ declare const update_: Update_; export { update_ }; export default update_;