Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Apr 3, 2022
1 parent 0f18992 commit 0376af0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/iterate/missing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions src/iterate/path.js
Original file line number Diff line number Diff line change
@@ -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* (
Expand Down Expand Up @@ -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

0 comments on commit 0376af0

Please sign in to comment.