0.0.4 • Published 6 years ago
dotted-object v0.0.4
dotted-object
A small, single-feature module to use a string with a dot notation to extract values from an object.
npm i dotted-object [--save]
const dotted = require('dotted-object')
const obj = {
data: {
geo: {
lat: 44.335,
lon: 52.983
}
}
}
const value = dotted('data.geo.lat', obj)
/*
To use a custom divider, use the thrid argument:
const value = dotted('data:geo:lat', obj, ':')
*/
console.log(value) // => Outputs 44.335
TypeScript type definition included!
License
Copyright 2017 Michiel van der Velde.
This software is licensed under the MIT License.