ts-randomizer
Version:
A tool to create random data by type parameters
38 lines • 1.26 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Randomizer = void 0;
const fp_1 = require("lodash/fp");
const specimen_factory_1 = require("./specimen-factory");
class Randomizer {
/**
* Creates anonymous variables by description of T.
* @returns An anonymous variable of type T.
*/
static create(...args) {
if ((0, fp_1.isUndefined)(args[0])) {
return undefined;
}
return new specimen_factory_1.SpecimenFactory(args[0]).create();
}
/**
* Creates many anonymous objects by requested type.
* @returns A sequence of anonymous object of type T.
*/
static createMany(firstArg, minCount, maxCount) {
if ((0, fp_1.isUndefined)(firstArg)) {
return undefined;
}
return new specimen_factory_1.SpecimenFactory(firstArg).createMany(minCount, maxCount);
}
/**
* Returns a specimen factory
*/
static build(...args) {
if ((0, fp_1.isUndefined)(args[0])) {
throw new Error('[Randomizer] Error: Missing type description');
}
return new specimen_factory_1.SpecimenFactory(args[0]);
}
}
exports.Randomizer = Randomizer;
//# sourceMappingURL=randomizer.js.map
;