Package Exports
- find-value
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (find-value) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
find-value 
Find object values by passing the path as string.
Installation
$ npm i --save find-value
Example
const findValue = require("find-value");
// Some random object :)
const obj = {
location: {
planet: "Mars"
, town: "Somewhere"
}
, names: [
{ first: "Alice", age: 19 }
, { first: "Bob", age: 20 }
]
};
console.log(findValue(obj, "location.planet"));
// => "Mars"
console.log(findValue(obj, "names"));
// => [ { first: "Alice", age: 19 }, { first: "Bob", age: 20 } ]
console.log(findValue(obj, "names.0.first"));
// => "Alice"
console.log(findValue(obj, "names.1.age"));
// => 20
console.log(findValue(obj, "something.that.does.not.exist"));
// => undefined
Documentation
findValue(obj, path)
Finds the value at given path in the specified object.
Params
- Object
obj
: The input object. - String
path
: The path to the value you want to find.
Return
- Anything The path value.
How to contribute
Have an idea? Found a bug? See how to contribute.
Where is this library used?
If you are using this library in one of your projects, add it in this list. ✨