Comparing version 2.2.1 to 2.2.2
@@ -17,3 +17,3 @@ import { GeneratorFn, HookFn, DeepPartial, OnCreateFn, AfterCreateFn } from './types'; | ||
setOnCreate: (hook: OnCreateFn<T, C>) => void; | ||
_mergeParamsOntoObject(object: T): void; | ||
_mergeParamsOntoObject(object: T): T; | ||
_callAfterBuilds(object: T): void; | ||
@@ -20,0 +20,0 @@ _callOnCreate(object: T): Promise<C>; |
@@ -127,4 +127,3 @@ 'use strict'; | ||
}; | ||
var object = this.generator(generatorOptions); | ||
this._mergeParamsOntoObject(object); | ||
var object = this._mergeParamsOntoObject(this.generator(generatorOptions)); | ||
this._callAfterBuilds(object); | ||
@@ -153,3 +152,13 @@ return object; | ||
FactoryBuilder.prototype._mergeParamsOntoObject = function (object) { | ||
merge(object, this.params, this.associations, mergeCustomizer); | ||
if (typeof object !== 'object') { | ||
return object; | ||
} | ||
var targetObject = object; | ||
if (Object.getPrototypeOf(object) === Object.prototype) { | ||
targetObject = {}; | ||
} | ||
else if (Array.isArray(object)) { | ||
targetObject = []; | ||
} | ||
return merge(targetObject, object, this.params, this.associations, mergeCustomizer); | ||
}; | ||
@@ -156,0 +165,0 @@ FactoryBuilder.prototype._callAfterBuilds = function (object) { |
@@ -8,2 +8,2 @@ export declare const merge: { | ||
}; | ||
export declare const mergeCustomizer: (objValue: any, srcVal: any, key: 'string', object: any) => any[] | undefined; | ||
export declare const mergeCustomizer: (objValue: any, srcVal: any, key: string, object: any) => any[] | undefined; |
{ | ||
"name": "fishery", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "A library for setting up JavaScript factories to help build objects as test data, with full TypeScript support", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130124
3004