Skip to content

Commit

Permalink
chore: merge changes from avajs#3023
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Mar 13, 2023
1 parent c45e837 commit c9a7a21
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/like-selector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export function isLikeSelector(selector) {
const prototype = Reflect.getPrototypeOf(selector);
return selector !== null
&& typeof selector === 'object'
&& Reflect.getPrototypeOf(selector) === Object.prototype
&& (prototype === Object.prototype || prototype === Array.prototype)
&& Reflect.ownKeys(selector).length > 0;
}

Expand All @@ -18,7 +19,7 @@ export function selectComparable(lhs, selector, circular = new Set()) {
return lhs;
}

const comparable = {};
const comparable = Array.isArray(selector) ? [] : {};
for (const [key, rhs] of Object.entries(selector)) {
if (isLikeSelector(rhs)) {
comparable[key] = selectComparable(Reflect.get(lhs, key), rhs, circular);
Expand Down

0 comments on commit c9a7a21

Please sign in to comment.