UNPKG

super-utils-plus

Version:

A superior alternative to Lodash with improved performance, TypeScript support, and developer experience

43 lines (42 loc) 1.41 kB
/** * Iterates over elements of collection and invokes iteratee for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning false. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @returns The collection * * @example * ```ts * forEach([1, 2], function(value) { * console.log(value); * }); * // => Logs `1` then `2`. * * forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); * // => Logs 'a' then 'b' (iteration order is not guaranteed). * ``` */ export declare function forEach<T>(collection: T[], iteratee: (value: T, index: number, collection: T[]) => boolean | void): T[]; /** * This method is like forEach except that it iterates over elements of * collection from right to left. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @returns The collection * * @example * ```ts * forEachRight([1, 2], function(value) { * console.log(value); * }); * // => Logs `2` then `1`. * ``` */ export declare function forEachRight<T>(collection: T[], iteratee: (value: T, index: number, collection: T[]) => boolean | void): T[]; export declare const each: typeof forEach; export declare const eachRight: typeof forEachRight;