Skip to content

Commit

Permalink
feat(collections): add deepMerge (#1075)
Browse files Browse the repository at this point in the history
Co-authored-by: Leon Strauss <[email protected]>
  • Loading branch information
lowlighter and LionC authored Aug 5, 2021
1 parent eaaf2ef commit 08457ed
Show file tree
Hide file tree
Showing 3 changed files with 725 additions and 0 deletions.
19 changes: 19 additions & 0 deletions collections/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ console.assert(
);
```

## deepMerge

Merges the two given Records, recursively merging any nested Records with the
second collection overriding the first in case of conflict

For arrays, maps and sets, a merging strategy can be specified to either
`replace` values, or `merge` them instead. Use `includeNonEnumerable` option to
include non enumerable properties too.

```ts
import { deepMerge } from "./deep_merge.ts";
import { assertEquals } from "../testing/asserts.ts";

const a = { foo: true };
const b = { foo: { bar: true } };

assertEquals(deepMerge(a, b), { foo: { bar: true } });
```

## distinctBy

Returns all elements in the given array that produce a distinct value using the
Expand Down
Loading

0 comments on commit 08457ed

Please sign in to comment.