getter-setter

set and get decoration for js objects

getter-setter

npm install getter-setter
  1. .node(obj) proto method only works in node.js or v8 browsers such as chrome

    var obj = require('getter-setter').node({hello: 'world'});
    obj.get('hello');
  2. .browser(obj) underscore extend method (works in all browsers as well as node.js)

    var obj = require('getter-setter').browser({hello: 'world'});
    obj.get('hello');
var decorate = require('getter-setter').browser,
    obj = decorate({
        hello: 'world'
    });
 
// outputs "world"
console.log(obj.get('hello'));
 
// outputs "bye"
console.log(obj.set('hello', 'bye'));
console.log(obj.get('hello'));