Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
36
node_modules/fast-check/lib/arbitrary/_internals/helpers/IsSubarrayOf.js
generated
vendored
Normal file
36
node_modules/fast-check/lib/arbitrary/_internals/helpers/IsSubarrayOf.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isSubarrayOf = isSubarrayOf;
|
||||
const globals_1 = require("../../../utils/globals");
|
||||
const safeObjectIs = Object.is;
|
||||
function isSubarrayOf(source, small) {
|
||||
const countMap = new globals_1.Map();
|
||||
let countMinusZero = 0;
|
||||
for (const sourceEntry of source) {
|
||||
if (safeObjectIs(sourceEntry, -0)) {
|
||||
++countMinusZero;
|
||||
}
|
||||
else {
|
||||
const oldCount = (0, globals_1.safeMapGet)(countMap, sourceEntry) || 0;
|
||||
(0, globals_1.safeMapSet)(countMap, sourceEntry, oldCount + 1);
|
||||
}
|
||||
}
|
||||
for (let index = 0; index !== small.length; ++index) {
|
||||
if (!(index in small)) {
|
||||
return false;
|
||||
}
|
||||
const smallEntry = small[index];
|
||||
if (safeObjectIs(smallEntry, -0)) {
|
||||
if (countMinusZero === 0)
|
||||
return false;
|
||||
--countMinusZero;
|
||||
}
|
||||
else {
|
||||
const oldCount = (0, globals_1.safeMapGet)(countMap, smallEntry) || 0;
|
||||
if (oldCount === 0)
|
||||
return false;
|
||||
(0, globals_1.safeMapSet)(countMap, smallEntry, oldCount - 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue