UNPKG

2.84 kBTypeScriptView Raw
1/**
2 * Compares a to b and b to a.
3 *
4 * @public
5 */
6export declare function shallowCompare<TA extends any, TB extends any>(a: TA, b: TB): boolean;
7/**
8 * Makes a resulting merge of a bunch of objects. Pass in the target object followed by 1 or more
9 * objects as arguments and they will be merged sequentially into the target. Note that this will
10 * shallow merge; it will not create new cloned values for target members.
11 *
12 * @public
13 * @param target - Target object to merge following object arguments into.
14 * @param args - One or more objects that will be mixed into the target in the order they are provided.
15 * @returns Resulting merged target.
16 */
17export declare function assign(target: any, ...args: any[]): any;
18/**
19 * Makes a resulting merge of a bunch of objects, but allows a filter function to be passed in to filter
20 * the resulting merges. This allows for scenarios where you want to merge "everything except that one thing"
21 * or "properties that start with data-". Note that this will shallow merge; it will not create new cloned
22 * values for target members.
23 *
24 * @public
25 * @param isAllowed - Callback to determine if the given propName is allowed in the result.
26 * @param target - Target object to merge following object arguments into.
27 * @param args - One or more objects that will be mixed into the target in the order they are provided.
28 * @returns Resulting merged target.
29 */
30export declare function filteredAssign(isAllowed: (propName: string) => boolean, target: any, ...args: any[]): any;
31/**
32 * Takes an enum and iterates over each value of the enum (as a string), running the callback on each,
33 * returning a mapped array.
34 * @param theEnum - Enum to iterate over
35 * @param callback - The first parameter the name of the entry, and the second parameter is the value
36 * of that entry, which is the value you'd normally use when using the enum (usually a number).
37 */
38export declare function mapEnumByName<T>(theEnum: any, callback: (name?: string, value?: string | number) => T | undefined): (T | undefined)[] | undefined;
39/**
40 * Get all values in an object dictionary
41 *
42 * @param obj - The dictionary to get values for
43 */
44export declare function values<T>(obj: any): T[];
45/**
46 * Tiny helper to do the minimal amount of work in duplicating an object but omitting some
47 * props. This ends up faster than using object ...rest or reduce to filter.
48 *
49 * This behaves very much like filteredAssign, but does not merge many objects together,
50 * uses an exclusion object map, and avoids spreads all for optimal performance.
51 *
52 * See perf test for background:
53 * https://jsperf.com/omit-vs-rest-vs-reduce/1
54 *
55 * @param obj - The object to clone
56 * @param exclusions - The array of keys to exclude
57 */
58export declare function omit<TObj extends Record<string, any>>(obj: TObj, exclusions: (keyof TObj)[]): TObj;