diff --git a/src/iterate/missing.js b/src/iterate/missing.js index 0623476..051136b 100644 --- a/src/iterate/missing.js +++ b/src/iterate/missing.js @@ -41,7 +41,7 @@ const getDefaultArray = function () { return [] } -const MISSING_HANDLERS = { +export const MISSING_HANDLERS = { objectArray: { isPresent(value, classes) { return isObject(value, classes) || Array.isArray(value) diff --git a/src/iterate/path.js b/src/iterate/path.js index 06c338e..5ec581f 100644 --- a/src/iterate/path.js +++ b/src/iterate/path.js @@ -1,5 +1,5 @@ import { isAllowedProp } from './expand.js' -import { isWeakObject } from './object.js' +import { MISSING_HANDLERS } from './missing.js' // Performance-optimized `iterate()` logic when the query is a path export const iteratePath = function* ( @@ -28,8 +28,13 @@ const iterateLevel = function (value, pathArray, index) { const isPresent = function (value, prop) { if (typeof prop === 'string') { - return isWeakObject(value) && prop in value + return isPresentProp(value) && prop in value } - return Array.isArray(value) && prop < value.length + return isPresentIndex(value) && prop < value.length } + +const { + array: { isPresent: isPresentIndex }, + weakObject: { isPresent: isPresentProp }, +} = MISSING_HANDLERS