New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

objnav

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objnav

create fast getters and setters for deep obj traversal

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

objnav

create fast getters and setters for deep obj traversal.

objnav creates, compiles and caches appropiate getter/setter functions by using 'Function'

examples


var objnav = require('objnav');

var obj={
  a:[0,{b:42}]
};

var N = objnav(['a',1,'b']); 

N.get(obj); // returns 42 
N.set(obj,5); // returns 5; N.get(obj) == 5

//lazy getter/setter

N(obj); // returns 5;
N(obj,6); returns 6; T.get(obj) is now 6

// more functions:
N.unset(obj) // unsets obj['a'][1]['b']

// secure[exception safe] operations
N.sGet(obj,42) // returns N.get(obj) when no error occurs otherwise 42; 
N.sSet(obj,42) // returns value which has been set otherwise null is returned
N.sUnset(obj)  // returns 1 if unset was successfull otherwise 0

//traversal

N.chain([1]).get(obj); // accesses obj['a'][1]['b'][1]  
N.parent().get(obj); // accesses obj['a'][1];


// templates :

var N2 = objnav(['a','$x','$y']); // threads $<str> as placeholder

N2.bind({x:1,y:'b'})(obj); // works the same way with get/set/ etc...


// cache

N.cache // raw access
N.clearCache() // self explanatory 


Keywords

FAQs

Package last updated on 01 Jun 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc