Socket
Book a DemoInstallSign in
Socket

deep-object-search

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-object-search

Performs a traversal on a tree object

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
184
666.67%
Maintainers
1
Weekly downloads
 
Created
Source

Performs a traversal on a tree object.

Install

npm install deep-object-search --save

Usage

import deepSearch from 'deep-object-search'

let tree = {
  body: {
    data: {
      firstname: 'Norman',
      lastname: 'Carcamo',
      house:399,
      games: {
        console: true,
        gameboy: undefined,
        physic: null
      }
    }
  },
  sports: {
    tennis: true,
    basketball: true,
    football: true,
    rugby: false,
  }
}

deepSearch(tree, 'body.data.games.console')
/* output:
{
  "found": true,
  "search": "body.data.games",
  "value": true,
  "parent": {
    "name": "body",
    "content": {
      "data": {
        "firstname": "Norman",
        "lastname": "Carcamo",
        "house": 399,
        "games": {
          "console": true,
          "physic": null
        }
      }
    }
  },
  "path": "root.body.data.body.data.games"
}
*/

deepSearch(object, path, options)

  • object {Object} The "tree" to search.
  • path {String} Used to search a path or a key name.
  • options {Object} An optional object to change the root key name.
    • rootLabel {String} The name of the first key appended to the end path. Defaults to root.

Keywords

Norman Carcamo

FAQs

Package last updated on 25 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts