get-data-from-objects
v1.0.1
Published
this package will allow to get objects,arrays and values from a object across the itself key
Downloads
3
Readme
Table of Contents
Installing
Package manager
Using npm:
$ npm i get-data-from-objects
Once the package is installed, you can import the library using import
or require
approach:
import { findObject } from "get-data-from-objects";
console.log(findObject(jsObject,"key-to-find"));
## Example
```js
import { findObject } from "get-data-from-objects";
const passenger = {
name: "Espartaco",
age: 25,
address: { city: "Caracas", country: "Venezuela" },
};
console.log(findObject(passenger, "address"));
//result [{ city: "Caracas", country: "Venezuela" }]
```
You also can get element which share the same key
```js
import { findObject } from "get-data-from-objects";
const data = {
passengers: [
[
{
name: "Espartaco",
age: 25,
address: { city: "Caracas", country: "Venezuela" },
},
{
name: "Carlos",
age: 23,
address: { city: "Santa cruz", country: "Bolivia" },
},
],
],
};
console.log(findObject(passenger, "address"));
//result [{ city: "Caracas", country: "Venezuela" },{ city: "Santa cruz", country: "Bolivia" }]
```