Skip to content

Commit

Permalink
refactor: extract out defaultClone
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Nov 27, 2020
1 parent 0c343f2 commit ced4b6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type FullOptions<O extends Options = Options> = FlattenAlias<{
readonly arrayMerge: O[`arrayMerge`] extends undefined
? typeof defaultArrayMerge
: NonNullable<O[`arrayMerge`]>
readonly clone: O[`clone`] extends undefined ? true : NonNullable<O[`clone`]>
readonly clone: O[`clone`] extends undefined ? typeof defaultClone : NonNullable<O[`clone`]>
readonly customMerge?: O[`customMerge`]
readonly isMergeable: O[`isMergeable`] extends undefined
? typeof defaultIsMergeable
Expand All @@ -52,6 +52,8 @@ export type ObjectMerge<K = any> = (
key: K
) => ((target: any, source: any, options: FullOptions) => any) | undefined

const defaultClone = true as const

function defaultIsMergeable(value: unknown): value is Record<Property, unknown> | Array<unknown> {
return Array.isArray(value) || isPlainObj(value)
}
Expand Down Expand Up @@ -82,7 +84,7 @@ export function getFullOptions<O extends Options>(options?: O): FullOptions<O> {
return {
arrayMerge: defaultArrayMerge,
isMergeable: defaultIsMergeable,
clone: true,
clone: defaultClone,
...overrides,
cloneUnlessOtherwiseSpecified,
} as unknown as FullOptions<O>
Expand Down

0 comments on commit ced4b6d

Please sign in to comment.