From ced4b6dde428066d4280230901e1b032911e8a54 Mon Sep 17 00:00:00 2001 From: Rebecca Stevens Date: Fri, 27 Nov 2020 15:15:32 +1300 Subject: [PATCH] refactor: extract out defaultClone --- src/options.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/options.ts b/src/options.ts index 016f4c5..f23c76e 100644 --- a/src/options.ts +++ b/src/options.ts @@ -27,7 +27,7 @@ export type FullOptions = FlattenAlias<{ readonly arrayMerge: O[`arrayMerge`] extends undefined ? typeof defaultArrayMerge : NonNullable - readonly clone: O[`clone`] extends undefined ? true : NonNullable + readonly clone: O[`clone`] extends undefined ? typeof defaultClone : NonNullable readonly customMerge?: O[`customMerge`] readonly isMergeable: O[`isMergeable`] extends undefined ? typeof defaultIsMergeable @@ -52,6 +52,8 @@ export type ObjectMerge = ( key: K ) => ((target: any, source: any, options: FullOptions) => any) | undefined +const defaultClone = true as const + function defaultIsMergeable(value: unknown): value is Record | Array { return Array.isArray(value) || isPlainObj(value) } @@ -82,7 +84,7 @@ export function getFullOptions(options?: O): FullOptions { return { arrayMerge: defaultArrayMerge, isMergeable: defaultIsMergeable, - clone: true, + clone: defaultClone, ...overrides, cloneUnlessOtherwiseSpecified, } as unknown as FullOptions