import { ICancellable, Constructor, IDestroyable, ICancellation, IRemovable, PromiseOrValue } from "./interfaces"; export declare function oid(instance: null | undefined): undefined; export declare function oid(instance: NonNullable): string; export declare function keys(arg: T): (Extract)[]; export declare function isKeyof(k: string, target: T): k is Extract; export declare function argumentNotNull(arg: any, name: string): void; export declare function argumentNotEmptyString(arg: any, name: string): void; export declare function argumentNotEmptyArray(arg: any, name: string): void; export declare function argumentOfType(arg: any, type: Constructor<{}>, name: string): void; export declare function isNull(val: any): val is null | undefined; export declare type primitive = symbol | string | number | boolean | undefined | null; export declare function isPrimitive(val: any): val is primitive; export declare function isObject(value: T): value is Exclude; export declare function isInteger(val: any): val is number; export declare function isNumber(val: any): val is number; export declare function isString(val: any): val is string; export declare function isPromise(val: any): val is PromiseLike; export declare function isCancellable(val: any): val is ICancellable; export declare function isNullOrEmptyString(val: any): val is ("" | null | undefined); export declare function isNotEmptyArray(arg: any): arg is T[]; export declare function getGlobal(): any; export declare function get(member: string, context?: object): any; /** * Выполняет метод для каждого элемента массива, останавливается, когда * либо достигнут конец массива, либо функция cb вернула * значение. * * @param {Array | Object} obj массив элементов для просмотра * @param {Function} cb функция, вызываемая для каждого элемента * @param {Object} thisArg значение, которое будет передано в качестве * this в cb. * @returns {void} */ export declare function each(obj: T, cb: >(v: NonNullable, k: X) => void): void; export declare function each(array: T[], cb: (v: T, i: number) => void): void; export declare function each(obj: any, cb: any, thisArg?: any): any; /** Copies property values from a source object to the destination and returns * the destination object. * * @param dest The destination object into which properties from the source * object will be copied. * @param source The source of values which will be copied to the destination * object. * @param template An optional parameter specifies which properties should be * copied from the source and how to map them to the destination. If the * template is an array it contains the list of property names to copy from the * source to the destination. In case of object the templates contains the map * where keys are property names in the source and the values are property * names in the destination object. If the template isn't specified then the * own properties of the source are entirely copied to the destination. * */ export declare function mixin(dest: T, source: S, template?: (keyof S)[]): T & S; export declare function mixin(dest: T, source: S, template: { [p in keyof S]?: keyof R; }): T & R; /** Wraps the specified function to emulate an asynchronous execution. * @param{Object} thisArg [Optional] Object which will be passed as 'this' to the function. * @param{Function|String} fn [Required] Function wich will be wrapped. */ export declare function async T | PromiseLike>(fn: F, thisArg?: ThisParameterType): (...args: Parameters) => PromiseLike; export declare function async T | PromiseLike; }>(fn: M, thisArg: O): (...args: Parameters>) => PromiseLike; export declare function delegate any>(target: T, method: F): OmitThisParameter; export declare function delegate any; }>(target: T, method: M): OmitThisParameter; /** Returns promise which will be resolved after the specified amount of time. * * @param timeMs The delay before the promise will be resolved in milliseconds. * @param ct Optional. A cancellation token for the operation. */ export declare function delay(timeMs: number, ct?: ICancellation): Promise; /** * Wraps the specified function to delay its execution by the specified timeout. * If the wrapped function was called multiple times before the timeout has elapsed, * the target function will be executed only once. * Each call to the wrapped function will return a promise is the timeout hasn't * elapsed the subsequent calls to the wrapped function will reject previous promises. * * @param func function that accepts a cancellation token as a single * parameter and returns the callback which will be invoked. * @param wait A timeout to wait before the callback should be invoked * @returns The function withe the same parameters as the original callback. */ export declare function debounce(func: (ct: ICancellation) => ((this: This, ...args: T) => PromiseOrValue), wait: number): { (this: This, ...args: T): Promise; cancel(e?: any): void; }; /** Returns resolved promise, awaiting this method will cause the asynchronous * completion of the rest of the code. */ export declare function fork(): Promise; /** Always throws Error, can be used as a stub for the methods which should be * assigned later and are required to be not null. */ export declare function notImplemented(): never; /** * Iterates over the specified array of items and calls the callback `cb`, if * the result of the callback is a promise the next item from the array will be * proceeded after the promise is resolved. * */ export declare function pmap(items: ArrayLike | PromiseLike>, cb: (item: T, i: number) => T2 | PromiseLike): T2[] | PromiseLike; export declare function pfor(items: ArrayLike | PromiseLike>, cb: (item: T, i: number) => any): void | PromiseLike; export declare function first(sequence: ArrayLike): T; export declare function first(sequence: PromiseLike>): PromiseLike; export declare function first(sequence: ArrayLike | PromiseLike>, cb?: (x: T) => void, err?: (x: Error) => void): void; export declare function firstWhere(sequence: ArrayLike, predicate: (x: T) => boolean): T; export declare function firstWhere(sequence: PromiseLike>, predicate: (x: T) => boolean): PromiseLike; export declare function firstWhere(sequence: ArrayLike | PromiseLike>, predicate: (x: T) => boolean, cb: (x: T) => void, err?: (x: Error) => void): void; export declare function isDestroyable(d: any): d is IDestroyable; export declare function isRemovable(value: any): value is IRemovable; export declare function destroy(d: any): void; /** * Used to mark that the async operation isn't awaited intentionally. * @param p The promise which represents the async operation. */ export declare function nowait(p: Promise): void; /** represents already destroyed object. */ export declare const destroyed: { /** Calling to this method doesn't affect anything, noop. */ destroy(): void; };