Skip to content

Find an object by giving it a path with or without context

License

Notifications You must be signed in to change notification settings

brickifyjs/module-get-object-by-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module Get object by path

Find an object by giving it a path with or without context.
Returns an object containing information about the object and paths.

Statistics

Github All Releases npm

Social

GitHub forks GitHub stars GitHub watchers Gitter

Project Health

Travis branch Codecov bitHound bitHound Website

Install

$ npm install @brickify/m-gobp

Usage

var getObject = require('@brickify/m-gobp');

var context = {
  foo: {
    bar: {
      baz: function() {
      }
    }
  }
};

// Use defined context
getObject('foo.bar.baz', context);


process.foo = {
    bar: {
      baz: function() {
      }
    }
};

// Use global context
getObject('foo.bar.baz');

Returns

{
  context: object|process|global|window,
  object: {
    decomposed: [...objects],
    first: object|process|global|window,
    last: End object value,
    parent: End parent object
  },
  paths: {
    decomposed: [...paths],
    first: first path,
    last: End parent object path
  }
}