forked from bryan-hunter/deepmerge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move options stuff to its own file
- Loading branch information
Rebecca Stevens
committed
Nov 13, 2020
1 parent
a0dd8e7
commit cdd1795
Showing
2 changed files
with
24 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import isPlainObj from "is-plain-obj" | ||
|
||
import { cloneUnlessOtherwiseSpecified } from "./utils" | ||
|
||
function defaultIsMergeable(value) { | ||
return Array.isArray(value) || isPlainObj(value) | ||
} | ||
|
||
function defaultArrayMerge(target, source, options) { | ||
return [...target, ...source].map((element) => | ||
cloneUnlessOtherwiseSpecified(element, options) | ||
) | ||
} | ||
|
||
export function getFullOptions(options) { | ||
return { | ||
arrayMerge: defaultArrayMerge, | ||
isMergeable: defaultIsMergeable, | ||
clone: true, | ||
...options, | ||
cloneUnlessOtherwiseSpecified: cloneUnlessOtherwiseSpecified, | ||
} | ||
} |