dset icon indicating copy to clipboard operation
dset copied to clipboard

docs(dset): Add `merge` function typing and add JSDoc documentation for `dset` and `dset/merge`

Open telesvar opened this issue 1 year ago • 0 comments

Includes type definitions to handle deep merging of nested objects and overwriting arrays.

The types ensure that primitive values from the second argument (U) overwrite those in the first (T), while arrays are replaced entirely, not merged element-wise.

Example:

const obj1 = { a: { b: [1, 2] }, c: null, d: "jaja" };
const obj2 = { a: { b: [3, 4], c: [5, 6] } };

const result = merge(obj1, obj2);
// const result: {
//   a: {
//     c: number[];
//     b: number[];
//   };
//   c: null;
//   d: string;
// }

Also, adds JSDoc to the function type declarations for documentation.

telesvar avatar Apr 03 '24 01:04 telesvar