@ts-for-gir/lib
Version:
Typescript .d.ts generator from GIR for gjs
137 lines (136 loc) • 6.58 kB
TypeScript
import lodash from 'lodash';
export { inspect } from 'util';
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are **not** supported.
*
* @category Lang
* @param value The value to compare.
* @param other The other value to compare.
* @returns Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'user': 'fred' };
* var other = { 'user': 'fred' };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
export declare const isEqual: (value: any, other: any) => boolean;
/**
* Creates an array of values by running each element in collection through iteratee. The iteratee is
* invoked with three arguments: (value, index|key, collection).
*
* Many lodash methods are guarded to work as iteratees for methods like _.every, _.filter, _.map, _.mapValues,
* _.reject, and _.some.
*
* The guarded methods are:
* ary, callback, chunk, clone, create, curry, curryRight, drop, dropRight, every, fill, flatten, invert, max,
* min, parseInt, slice, sortBy, take, takeRight, template, trim, trimLeft, trimRight, trunc, random, range,
* sample, some, sum, uniq, and words
*
* @param collection The collection to iterate over.
* @param iteratee The function invoked per iteration.
* @return Returns the new mapped array.
*/
export declare const map: {
<T extends readonly [unknown, ...unknown[]], TResult>(collection: T, iteratee: lodash.TupleIterator<T, TResult>): { [K in keyof T]: TResult; };
<T, TResult>(collection: T[] | null | undefined, iteratee: lodash.ArrayIterator<T, TResult>): TResult[];
<T, TResult>(collection: lodash.List<T> | null | undefined, iteratee: lodash.ListIterator<T, TResult>): TResult[];
<T>(collection: lodash.Dictionary<T> | lodash.NumericDictionary<T> | null | undefined): T[];
<T extends object, TResult>(collection: T | null | undefined, iteratee: lodash.ObjectIterator<T, TResult>): TResult[];
<T, K extends keyof T>(collection: lodash.Dictionary<T> | lodash.NumericDictionary<T> | null | undefined, iteratee: K): Array<T[K]>;
<T>(collection: lodash.Dictionary<T> | lodash.NumericDictionary<T> | null | undefined, iteratee?: string): any[];
<T>(collection: lodash.Dictionary<T> | lodash.NumericDictionary<T> | null | undefined, iteratee?: object): boolean[];
};
/**
* Iterates over elements of collection, returning the first element predicate returns truthy for.
* The predicate is invoked with three arguments: (value, index|key, collection).
*
* @param collection The collection to search.
* @param predicate The function invoked per iteration.
* @param fromIndex The index to search from.
* @return Returns the matched element, else undefined.
*/
export declare const find: {
<T, S extends T>(collection: lodash.List<T> | null | undefined, predicate: lodash.ListIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
<T>(collection: lodash.List<T> | null | undefined, predicate?: lodash.ListIterateeCustom<T, boolean>, fromIndex?: number): T | undefined;
<T extends object, S extends T[keyof T]>(collection: T | null | undefined, predicate: lodash.ObjectIteratorTypeGuard<T, S>, fromIndex?: number): S | undefined;
<T extends object>(collection: T | null | undefined, predicate?: lodash.ObjectIterateeCustom<T, boolean>, fromIndex?: number): T[keyof T] | undefined;
};
/**
* Recursively merges own and inherited enumerable properties of source
* objects into the destination object, skipping source properties that resolve
* to `undefined`. Array and plain object properties are merged recursively.
* Other objects and value types are overridden by assignment. Source objects
* are applied from left to right. Subsequent sources overwrite property
* assignments of previous sources.
*
* **Note:** This method mutates `object`.
*
* @category Object
* @param object The destination object.
* @param [sources] The source objects.
* @returns Returns `object`.
* @example
*
* var users = {
* 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
* };
*
* var ages = {
* 'data': [{ 'age': 36 }, { 'age': 40 }]
* };
*
* _.merge(users, ages);
* // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
*/
export declare const merge: {
<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): TObject & TSource1 & TSource2 & TSource3;
<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): TObject & TSource1 & TSource2 & TSource3 & TSource4;
(object: any, ...otherArgs: any[]): any;
};
/**
* Creates a shallow clone of value.
*
* Note: This method is loosely based on the structured clone algorithm and supports cloning arrays,
* array buffers, booleans, date objects, maps, numbers, Object objects, regex's, sets, strings, symbols,
* and typed arrays. The own enumerable properties of arguments objects are cloned as plain objects. An empty
* object is returned for not cloneable values such as error objects, functions, DOM nodes, and WeakMaps.
*
* @param value The value to clone.
* @return Returns the cloned value.
*/
export declare const clone: <T>(value: T) => T;
/**
* This method is like clone except that it recursively clones value.
*
* @param value The value to recursively clone.
* @return Returns the deep cloned value.
*/
export declare const cloneDeep: <T>(value: T) => T;
/**
* Checking whether some variable is iterable
* @see https://stackoverflow.com/a/32538867
* @param obj Variable to check for iterable
* @returns Whether the variable is iterable or not
*/
export declare const isIterable: (obj: unknown[]) => boolean;
/**
* Union (a ∪ b): create a set that contains the elements of both set a and set b.
* See https://2ality.com/2015/01/es6-set-operations.html#union
* @param target
* @param source
*/
export declare const union: <T>(target: Set<T> | T[], source: Set<T> | T[]) => Set<T>;