search-object

1.2.0 • Public • Published

search-object

Deep dive into an object to find what your looking for!

Pass it an object and what you want to find.

Installation

$ npm install search-object

Usage

const searchObject = require("search-object");
 
// OR
 
import searchObject from "search-object";
 
const data = {
    place: {
        with: {
            deeply: {
                nested: {
                    data: [
                        {
                            city: {
                                name: "Manchester",
                                number: 200
                            }
                        },
                        {
                            city: {
                                name: "London",
                                number: 100
                            }
                        }
                    ]
                }
            }
        }
    }
};
 
searchObject(data, "London"); // true
searchObject(data, "Manchester"); // true
searchObject(data, 100); // true
 
searchObject(data, "New York"); // false

TODO = write more tests, add an options parameter

Package Sidebar

Install

npm i search-object

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

65.6 kB

Total Files

15

Last publish

Collaborators

  • andycoupe