Erster Docker-Stand
This commit is contained in:
23
_node_modules/fast-check/lib/arbitrary/date.js
generated
Normal file
23
_node_modules/fast-check/lib/arbitrary/date.js
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.date = date;
|
||||
const globals_1 = require("../utils/globals");
|
||||
const integer_1 = require("./integer");
|
||||
const TimeToDate_1 = require("./_internals/mappers/TimeToDate");
|
||||
const safeNumberIsNaN = Number.isNaN;
|
||||
function date(constraints = {}) {
|
||||
const intMin = constraints.min !== undefined ? (0, globals_1.safeGetTime)(constraints.min) : -8640000000000000;
|
||||
const intMax = constraints.max !== undefined ? (0, globals_1.safeGetTime)(constraints.max) : 8640000000000000;
|
||||
const noInvalidDate = constraints.noInvalidDate === undefined || constraints.noInvalidDate;
|
||||
if (safeNumberIsNaN(intMin))
|
||||
throw new Error('fc.date min must be valid instance of Date');
|
||||
if (safeNumberIsNaN(intMax))
|
||||
throw new Error('fc.date max must be valid instance of Date');
|
||||
if (intMin > intMax)
|
||||
throw new Error('fc.date max must be greater or equal to min');
|
||||
if (noInvalidDate) {
|
||||
return (0, integer_1.integer)({ min: intMin, max: intMax }).map(TimeToDate_1.timeToDateMapper, TimeToDate_1.timeToDateUnmapper);
|
||||
}
|
||||
const valueForNaN = intMax + 1;
|
||||
return (0, integer_1.integer)({ min: intMin, max: intMax + 1 }).map((0, TimeToDate_1.timeToDateMapperWithNaN)(valueForNaN), (0, TimeToDate_1.timeToDateUnmapperWithNaN)(valueForNaN));
|
||||
}
|
||||
Reference in New Issue
Block a user