Overview
Resolves paths in Javascript objects, providing tools to get, set, replace, or remove the resolved item.
Install
Web Browser
<script src="https://unpkg.com/js-path-resolver/dist/index.js"></script>
<script>
const resolver = jsPathResolver.default;
</script>
Node
import resolver from 'js-path-resolver';
Usage
const state = lists: todo: caption:'wake up' completed:true caption:'eat' completed:false const info = const value = infoinfo // Remove a field from its parent object or array.
By default, if a path cannot be resolved up to the parent, an exception will be thrown.
// will not throw // will throw
To never throw, use the onError
option. The property exists
will be set to false instead. However, all mutation operations (delete, get, set) will throw.
const info = // will not throw// info.exists === falseinfo // will throw
API
See js-path-resolver official documentation for API and tutorials.