UNPKG

@arrows/array

Version:
38 lines (37 loc) 1.15 kB
declare type Curry1<T> = (arr: T[]) => T[]; declare type Curry2<T> = { (to: number): Curry1<T>; (to: number, arr: T[]): T[]; }; declare type Curry3 = { <T>(from: number): Curry2<T>; <T>(from: number, to: number): Curry1<T>; }; declare type _Slice = <T>(from: number, to: number, arr: T[]) => T[]; declare type _SliceFrom = <T>(from: number, arr: T[]) => T[]; declare type _SliceTo = <T>(to: number, arr: T[]) => T[]; declare type CurriesSlice = _Slice & Curry3; declare type Slice = CurriesSlice & { from: _SliceFrom & { <T>(from: number): (arr: T[]) => T[]; }; to: _SliceTo & { <T>(to: number): (arr: T[]) => T[]; }; }; /** * Functional wrapper for Array.prototype.slice * * Creates a new array as a a section of an initial array. * * @param from The beginning of the specified portion of the array. * @param to The end of the specified portion of the array. * @param arr Initial array * @returns New array * * @method from Version with implicit end index (arr.length) * @method to Version with implicit start index (0) */ declare const slice: Slice; export { slice }; export default slice;