factory.ts
Advanced tools
Comparing version 0.3.3 to 0.3.4
import { RecPartial } from "./shared"; | ||
import * as Sync from "./sync"; | ||
export declare type FactoryFunc<T, U = T> = (item?: RecPartial<T>) => Promise<U>; | ||
@@ -49,1 +50,2 @@ export declare type ListFactoryFunc<T, U = T> = (count: number, item?: RecPartial<T>) => Promise<U[]>; | ||
export declare function makeFactory<T>(builder: Builder<T>): Factory<T>; | ||
export declare function makeFactoryFromSync<T>(builder: Sync.Builder<T>): Factory<T>; |
@@ -11,2 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Sync = require("./sync"); | ||
function isPromise(t) { | ||
@@ -182,2 +183,8 @@ return typeof t["then"] === "function"; | ||
} | ||
else if (v.constructor === Sync.Generator) { | ||
value = v.build(seqNum); | ||
} | ||
else if (v.constructor == Sync.Derived) { | ||
derived.push({ key, derived: new Derived(v.func) }); | ||
} | ||
} | ||
@@ -193,2 +200,6 @@ t[key] = value; | ||
exports.makeFactory = makeFactory; | ||
function makeFactoryFromSync(builder) { | ||
return new Factory(builder); | ||
} | ||
exports.makeFactoryFromSync = makeFactoryFromSync; | ||
//# sourceMappingURL=async.js.map |
@@ -50,3 +50,4 @@ "use strict"; | ||
let yKeys = Object.keys(y); | ||
for (const key of Object.keys(v)) { | ||
const allKeys = uniq(Object.keys(v).concat(yKeys)); | ||
for (const key of allKeys) { | ||
if (yKeys.indexOf(key) >= 0) { | ||
@@ -143,2 +144,11 @@ const itemKeyVal = y[key]; | ||
exports.makeFactory = makeFactory; | ||
function uniq(ts) { | ||
const out = []; | ||
for (const v of ts) { | ||
if (out.indexOf(v) < 0) { | ||
out.push(v); | ||
} | ||
} | ||
return out; | ||
} | ||
//# sourceMappingURL=sync.js.map |
{ | ||
"name": "factory.ts", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A Typescript test data factory similar to factory_bot and rosie", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
45358
19
538