Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ffa5c0

Browse files
committed
chore: merge changes from avajs#3023
1 parent 0001831 commit 3ffa5c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎lib/like-selector.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
export function isLikeSelector(selector) {
2+
const prototype = Reflect.getPrototypeOf(selector);
23
return selector !== null
34
&& typeof selector === 'object'
4-
&& Reflect.getPrototypeOf(selector) === Object.prototype
5+
&& (prototype === Object.prototype || prototype === Array.prototype)
56
&& Reflect.ownKeys(selector).length > 0;
67
}
78

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

21-
const comparable = {};
22+
const comparable = Array.isArray(selector) ? [] : {};
2223
for (const [key, rhs] of Object.entries(selector)) {
2324
if (isLikeSelector(rhs)) {
2425
comparable[key] = selectComparable(Reflect.get(lhs, key), rhs, circular);

0 commit comments

Comments
 (0)