We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
isLikeSelector
Reflect.ownKeys().length
1 parent c9a7a21 commit a50b1c8Copy full SHA for a50b1c8
lib/like-selector.js
@@ -1,9 +1,14 @@
1
export function isLikeSelector(selector) {
2
- const prototype = Reflect.getPrototypeOf(selector);
3
- return selector !== null
4
- && typeof selector === 'object'
5
- && (prototype === Object.prototype || prototype === Array.prototype)
6
- && Reflect.ownKeys(selector).length > 0;
+ const isArrayOrObject = selector !== null && typeof selector === 'object';
+
+ if (!isArrayOrObject) {
+ return false;
+ }
7
8
+ const isArray = Array.isArray(selector);
9
+ const minimumKeysRequired = isArray ? 1 : 0;
10
11
+ return Reflect.ownKeys(selector).length > minimumKeysRequired;
12
}
13
14
export const CIRCULAR_SELECTOR = new Error('Encountered a circular selector');
0 commit comments