UNPKG

1.49 kBTypeScriptView Raw
1import { Constructor } from './resolvers';
2/**
3 * Quick flatten utility to flatten a 2-dimensional array.
4 *
5 * @param {Array<Array<Item>>} array
6 * The array to flatten.
7 *
8 * @return {Array<Item>}
9 * The flattened array.
10 */
11export declare function flatten<T>(array: Array<Array<T>>): Array<T>;
12/**
13 * Creates a { name: value } object if the input isn't already in that format.
14 *
15 * @param {string|object} name
16 * Either a string or an object.
17 *
18 * @param {*} value
19 * The value, only used if name is not an object.
20 *
21 * @return {object}
22 */
23export declare function nameValueToObject(name: string | symbol | object, value?: any): Record<string | symbol, any>;
24/**
25 * Returns the last item in the array.
26 *
27 * @param {*[]} arr
28 * The array.
29 *
30 * @return {*}
31 * The last element.
32 */
33export declare function last<T>(arr: Array<T>): T;
34/**
35 * Determines if the given function is a class.
36 *
37 * @param {Function} fn
38 * @return {boolean}
39 */
40export declare function isClass(fn: Function | Constructor<any>): boolean;
41/**
42 * Determines if the given value is a function.
43 *
44 * @param {Any} val
45 * Any value to check if it's a function.
46 *
47 * @return {boolean}
48 * true if the value is a function, false otherwise.
49 */
50export declare function isFunction(val: any): boolean;
51/**
52 * Returns the unique items in the array.
53 *
54 * @param {Array<T>}
55 * The array to remove dupes from.
56 *
57 * @return {Array<T>}
58 * The deduped array.
59 */
60export declare function uniq<T>(arr: Array<T>): Array<T>;