diff --git a/index.js b/index.js index acc3a53..c8dccea 100644 --- a/index.js +++ b/index.js @@ -177,6 +177,15 @@ function assertNotStringIndex(object, key) { } } +export default function dotProp(object) { + return new Proxy(object, { + get: (_target, property, _receiver) => getProperty(object, property), + set: (_target, property, value, _receiver) => setProperty(object, property, value), + deleteProperty: (_target, property) => deleteProperty(object, property), + has: (_target, property) => hasProperty(object, property), + }); +} + export function getProperty(object, path, value) { if (!isObject(object) || typeof path !== 'string') { return value === undefined ? object : value;