Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
29
node_modules/fast-check/lib/arbitrary/record.js
generated
vendored
Normal file
29
node_modules/fast-check/lib/arbitrary/record.js
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.record = record;
|
||||
const PartialRecordArbitraryBuilder_1 = require("./_internals/builders/PartialRecordArbitraryBuilder");
|
||||
function record(recordModel, constraints) {
|
||||
const noNullPrototype = constraints === undefined || constraints.noNullPrototype === undefined || constraints.noNullPrototype;
|
||||
if (constraints == null) {
|
||||
return (0, PartialRecordArbitraryBuilder_1.buildPartialRecordArbitrary)(recordModel, undefined, noNullPrototype);
|
||||
}
|
||||
if ('withDeletedKeys' in constraints && 'requiredKeys' in constraints) {
|
||||
throw new Error(`requiredKeys and withDeletedKeys cannot be used together in fc.record`);
|
||||
}
|
||||
const requireDeletedKeys = ('requiredKeys' in constraints && constraints.requiredKeys !== undefined) ||
|
||||
('withDeletedKeys' in constraints && !!constraints.withDeletedKeys);
|
||||
if (!requireDeletedKeys) {
|
||||
return (0, PartialRecordArbitraryBuilder_1.buildPartialRecordArbitrary)(recordModel, undefined, noNullPrototype);
|
||||
}
|
||||
const requiredKeys = ('requiredKeys' in constraints ? constraints.requiredKeys : undefined) || [];
|
||||
for (let idx = 0; idx !== requiredKeys.length; ++idx) {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(recordModel, requiredKeys[idx]);
|
||||
if (descriptor === undefined) {
|
||||
throw new Error(`requiredKeys cannot reference keys that have not been defined in recordModel`);
|
||||
}
|
||||
if (!descriptor.enumerable) {
|
||||
throw new Error(`requiredKeys cannot reference keys that have are enumerable in recordModel`);
|
||||
}
|
||||
}
|
||||
return (0, PartialRecordArbitraryBuilder_1.buildPartialRecordArbitrary)(recordModel, requiredKeys, noNullPrototype);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue