UNPKG

@deepkit/core

Version:
57 lines (56 loc) 1.23 kB
/** * Iterator for each key of an array or object. * * @example * ``` * for (const i of eachKey(['a', 'b']) { * console.log(i); //0, 1 * } * ``` * * @public * @category iterator */ export declare function eachKey<T>(object: ArrayLike<T>): IterableIterator<number>; /** @public */ export declare function eachKey<T extends { [key: string]: any; }, K extends keyof T>(object: T): IterableIterator<string>; /** * Iterator for each value of an array or object. * * @example * ``` * for (const v of each(['a', 'b']) { * console.log(v); //a, b * } * ``` * * @public * @category iterator */ export declare function each<T>(object: { [s: string]: T; } | ArrayLike<T>): IterableIterator<T>; /** * Iterator for key value pair of an array or object. * * @example * ``` * for (const [i, v] of eachPair(['a', 'b']) { * console.log(i, v); //0 a, 1 b * } * * for (const [i, v] of eachPair({'foo': 'bar}) { * console.log(i, v); //foo bar * } * ``` * * @public * @category iterator */ export declare function eachPair<T>(object: ArrayLike<T>): IterableIterator<[number, T]>; /** @public */ export declare function eachPair<T>(object: { [s: string]: T; }): IterableIterator<[string, T]>;