/** * util.ts * * A minimalist implementation of [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide) */ /** * This method returns the first argument it receives. */ export declare const identity: (item: T) => T; /** * Checks if value is an empty array. */ export declare const isEmpty: (items?: T[] | undefined) => boolean; export declare function tail(items: [unknown, ...T[]]): T[]; export declare function tail(items: T[]): T[]; export declare function last(items?: [...unknown[], T]): T; export declare function last(items?: T[]): T | undefined; export declare function first(items?: [T, ...unknown[]]): T; export declare function first(items?: T[]): T | undefined; export declare function initial(items: [...T[], unknown]): T[]; export declare function initial(items: T[]): T[]; /** * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. */ export declare function range(start: number, end: number): number[]; /** * Filter out items that are not unique based on a predicate. * * ```typescript * myArray.filter(isUnique((item) => item.id)); * ``` */ export declare const isUnique: (predicate?: (item: T) => unknown) => (item: T, index: number, items: T[]) => boolean; /** * Filter out items that are not unique based on a predicate that compares two items. * * ```typescript * myArray.filter(isUniqueBy((a, b) => a.id === b.id)); * ``` */ export declare const isUniqueBy: (predicate?: (a: T, b: T) => boolean) => (item: T, index: number, items: T[]) => boolean; /** * Order items by a predicate, ascending order * * ```typescript * myArray.sort(orderBy(item) => a.position)); * ``` */ export declare const orderBy: (predicate?: (item: T) => any) => (a: T, b: T) => number; /** * Filter out falsy values from an array * * ```typescript * myArray.filter(isNil); * ``` */ export declare const isNil: (item: T | null | undefined) => item is T; export declare const isDiffBy: (predicate: (item: T) => unknown, to: T[]) => (fromItem: T) => boolean; /** * Creates an object composed of keys generated from the results of running each element of collection thru iteratee. * The order of grouped values is determined by the order they occur in collection. * The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value). */ export declare const groupBy: (predicate: (item: T) => K, items: T[]) => Record; /** * Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements. */ export declare const chunk: (size: number, items: T[]) => T[][]; /** * Checks if value is the language type of Object. (e.g. arrays, functions, objects, new RegExp(''), new Number(0), and new String('')) */ export declare const isObject: (item: unknown) => item is Record; /** * Convert to milliseconds the response from process.hrtime */ export declare const toMilliseconds: (time: [number, number]) => number; /** * Performs a deep comparison between two values to determine if they are equivalent. */ export declare const isEqual: (a: unknown, b: unknown) => boolean; /** * Reverse of findIndex */ export declare const findLastIndex: (predicate: (value: T) => boolean, array: T[]) => number;