UNPKG

deleight

Version:

A library with 9 modules for writing more expressive web applications with traditional HTML, CSS and JavaScript.

46 lines (45 loc) 1.26 kB
/** * Functions for using objects to perform different tasks. Here * objects contain actions to run or things to interpret. * * API Table of Contents * * * @module */ import { IObjectCallable } from "../types.js"; /** * Performs the specified action with all object keys. * * If the action returns an object type, Process will be * called again with it. * * Extra arguments to be passed to the action (after the object and key) * can be specified with extra optional arguments to Process. * * * @example * import { process } from 'deleight/object/process' * let count = 0; * process({ a: 1, b: 2, c: 3 }, (obj, key) => count += (obj[key] * obj[key])); * console.log(count) // 14 * * @param object * @param action * @param args */ export declare function process<T extends object, U = any>(object: T, action: IObjectCallable<T, U>, ...args: any[]): T; /** * Run the action over all the property keys of the object, optionally * including further args in the call. This is effectively {@link process} * without the recursion. * * @example * * * @param object * @param action * @param args * @returns */ export declare function forEach<T extends object, U = any>(object: T, action: IObjectCallable<T, U>, ...args: any[]): T;