Skip to content

Commit

Permalink
docs for .withOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Mar 9, 2024
1 parent 8289bac commit 571bf9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

Cross-runtime deep object merging in JavaScript environments, including Deno, Bun, Node.js and Browser. It is designed to handle complex data structures, including arrays, Maps, Sets, and primitive values. It provides flexible customization options for handling array, Set, and Map merging strategies.

Follow the library on [JSR.io](https://jsr.io/@cross/deepmerge)

## Features

* **Cross-Runtime Compatibility:**
Expand Down
2 changes: 1 addition & 1 deletion jsr.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@cross/deepmerge",
"version": "0.1.0",
"version": "0.1.1",
"exports": "./mod.ts"
}
9 changes: 9 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ function isObject(item: unknown): item is MergeableObject {
* Performs a deep merge of objects, handling arrays, Maps, Sets, and primitives.
* Supports multiple source objects.
*
* **Customizing Behavior with the attached `deepMerge.withOptions()` method**
* `.withOptions()` allows you to create a modified version of `deepMerge` with
* pre-configured merge behavior. For instance:
*
* ```javascript
* const combineUniqueArrays = deepMerge.withOptions({ arrayMergeStrategy: 'unique' });
* const combined = combineUniqueArrays({ arr: [1, 2] }, { arr: [2, 3] }); // combined.arr = [1, 2, 3]
* ```
*
* @template T
* @param {T} target - The base object to merge into.
* @param {...T} sources - One or more source objects to merge.
Expand Down

0 comments on commit 571bf9f

Please sign in to comment.