Fix dependabot issues
This commit is contained in:
parent
c89d9bd8b0
commit
531c6ba7c8
705 changed files with 53406 additions and 20466 deletions
37
node_modules/ava/lib/like-selector.js
generated
vendored
Normal file
37
node_modules/ava/lib/like-selector.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
function isLikeSelector(selector) {
|
||||
return selector !== null &&
|
||||
typeof selector === 'object' &&
|
||||
Reflect.getPrototypeOf(selector) === Object.prototype &&
|
||||
Reflect.ownKeys(selector).length > 0;
|
||||
}
|
||||
|
||||
exports.isLikeSelector = isLikeSelector;
|
||||
|
||||
const CIRCULAR_SELECTOR = new Error('Encountered a circular selector');
|
||||
exports.CIRCULAR_SELECTOR = CIRCULAR_SELECTOR;
|
||||
|
||||
function selectComparable(lhs, selector, circular = new Set()) {
|
||||
if (circular.has(selector)) {
|
||||
throw CIRCULAR_SELECTOR;
|
||||
}
|
||||
|
||||
circular.add(selector);
|
||||
|
||||
if (lhs === null || typeof lhs !== 'object') {
|
||||
return lhs;
|
||||
}
|
||||
|
||||
const comparable = {};
|
||||
for (const [key, rhs] of Object.entries(selector)) {
|
||||
if (isLikeSelector(rhs)) {
|
||||
comparable[key] = selectComparable(Reflect.get(lhs, key), rhs, circular);
|
||||
} else {
|
||||
comparable[key] = Reflect.get(lhs, key);
|
||||
}
|
||||
}
|
||||
|
||||
return comparable;
|
||||
}
|
||||
|
||||
exports.selectComparable = selectComparable;
|
||||
Loading…
Add table
Add a link
Reference in a new issue