Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Latest commit

 

History

History
49 lines (36 loc) · 813 Bytes

readme.md

File metadata and controls

49 lines (36 loc) · 813 Bytes

object-search

A node.js module for looking up deep paths inside of an object

install

$ npm install [--save] object-search

usage

var objectSearch = require('object-search');

var obj = {
    abc: [
        {def: 'foo', ghi: 'baz'}
    ]
};

// Get a property
objectSearch.get(obj, 'abc.0.def');  // 'foo'

// Set a property
objectSearch.set(obj, 'abc.1', {def: 'bar'});

// Delete a property
objectSearch.del(obj, 'abc.0.ghi');

// Lookup a property for multiple/more complex operations
objectSearch.find(obj, 'abc.0');
//
// Returns an object:
//  {
//    "get": function() { },
//    "set": function(value) { },
//    "del": function() { },
//    "object": obj,
//    "key": "abc.0",
//    "keys": ["abc", "0"],
//    "lastKey": "0",
//    "scope": obj.abc
//  }
//