@signaldb/core
Version:
SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON in
15 lines (14 loc) • 633 B
TypeScript
import type Modifier from '../types/Modifier';
/**
* Applies a modifier to an object and returns a new modified object.
* @template T - The type of the object to be modified.
* @param item - The object to be modified.
* @param modifier - The modifier to apply. This can be any transformation logic.
* @returns - Returns a new object with the modifications applied.
* @example
* const item = { a: 1, b: 2 }
* const modifier = { $set: { b: 3, c: 4 } }
* const result = modify(item, modifier)
* // result: { a: 1, b: 3, c: 4 }
*/
export default function modify<T extends Record<string, any>>(item: T, modifier: Modifier): T;