react-mapfilter
Version:
These components are designed for viewing data in Mapeo. They share a common interface:
20 lines (17 loc) • 803 B
JavaScript
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
import { set as originalSet } from 'object-path-immutable';
import { isObj } from './helpers';
export function get(object, path, defaultValue) {
if (typeof path === 'string') path = [path];
if (!_Array$isArray(path)) return object;
if (!isObj(object) || path.length === 0) {
return defaultValue === undefined && path.length === 0 ? object : defaultValue;
}
if (!Object.prototype.propertyIsEnumerable.call(object, path[0])) {
return defaultValue;
}
return get(object[path[0]], _sliceInstanceProperty(path).call(path, 1), defaultValue);
}
export const set = originalSet;
//# sourceMappingURL=get_set.js.map