updeep-remeda/lib/is.js
2017-04-18 17:55:46 -07:00

22 lines
445 B
JavaScript

import splitPath from './util/splitPath'
import curry from './util/curry'
function is(path, predicate, object) {
const parts = splitPath(path)
let rest = object
for (let i = 0; i < parts.length; i += 1) {
if (typeof rest === 'undefined') return false
const part = parts[i]
rest = rest[part]
}
if (typeof predicate === 'function') {
return predicate(rest)
}
return predicate === rest
}
export default curry(is)