remeda
Version:
A utility library for JavaScript and Typescript.
47 lines (44 loc) • 1.87 kB
TypeScript
import { E as EnumerableStringKeyOf } from './EnumerableStringKeyOf-CLExxPV5.js';
import { E as EnumerableStringKeyedValueOf } from './EnumerableStringKeyedValueOf-BU9R_cEk.js';
import './ToString-DO8zw6jS.js';
import 'type-fest';
/**
* Iterate an object using a defined callback function.
*
* The dataLast version returns the original object (instead of not returning
* anything (`void`)) to allow using it in a pipe. The returned object is the
* same reference as the input object, and not a shallow copy of it!
*
* @param data - The object who'se entries would be iterated on.
* @param callbackfn - A function to execute for each element in the array.
* @signature
* R.forEachObj(object, fn)
* @example
* R.forEachObj({a: 1}, (val, key, obj) => {
* console.log(`${key}: ${val}`)
* }) // "a: 1"
* @dataFirst
* @category Object
*/
declare function forEachObj<T extends object>(data: T, callbackfn: (value: EnumerableStringKeyedValueOf<T>, key: EnumerableStringKeyOf<T>, obj: T) => void): void;
/**
* Iterate an object using a defined callback function.
*
* The dataLast version returns the original object (instead of not returning
* anything (`void`)) to allow using it in a pipe. The returned object is the
* same reference as the input object, and not a shallow copy of it!
*
* @param callbackfn - A function to execute for each element in the array.
* @returns The original object (the ref itself, not a shallow copy of it).
* @signature
* R.forEachObj(fn)(object)
* @example
* R.pipe(
* {a: 1},
* R.forEachObj((val, key) => console.log(`${key}: ${val}`))
* ) // "a: 1"
* @dataLast
* @category Object
*/
declare function forEachObj<T extends object>(callbackfn: (value: EnumerableStringKeyedValueOf<T>, key: EnumerableStringKeyOf<T>, obj: T) => void): (object: T) => T;
export { forEachObj };