@fast-check/poisoning
Version:
Set of utilities to ease detection and revert of poisoning
24 lines (23 loc) • 924 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.shouldIgnoreGlobal = shouldIgnoreGlobal;
exports.shouldIgnoreProperty = shouldIgnoreProperty;
function shouldIgnoreGlobal(globalDetails, ignoredRootRegex) {
switch (globalDetails.depth) {
case 0:
return false;
case 1:
return ignoredRootRegex.test(globalDetails.name);
default: {
let allRootsIgnored = true;
const allRoots = [...globalDetails.rootAncestors];
for (let rootIndex = 0; rootIndex !== allRoots.length; ++rootIndex) {
allRootsIgnored = allRootsIgnored && ignoredRootRegex.test(allRoots[rootIndex]);
}
return allRootsIgnored;
}
}
}
function shouldIgnoreProperty(globalDetails, propertyName, ignoredRootRegex) {
return globalDetails.depth === 0 && ignoredRootRegex.test(propertyName);
}