2015-08-07 03:48:04 +00:00
|
|
|
import splitPath from './util/splitPath';
|
2015-08-12 06:53:05 +00:00
|
|
|
import curry from './util/curry';
|
2015-08-07 03:48:04 +00:00
|
|
|
|
|
|
|
function is(path, predicate, object) {
|
|
|
|
const parts = splitPath(path);
|
|
|
|
|
|
|
|
let rest = object;
|
|
|
|
let part;
|
|
|
|
for (part of parts) {
|
|
|
|
if (typeof rest === 'undefined') return false;
|
|
|
|
rest = rest[part];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof predicate === 'function') {
|
|
|
|
return predicate(rest);
|
|
|
|
}
|
|
|
|
|
|
|
|
return predicate === rest;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default curry(is);
|