Nerfing Powerful Megalomaniacs
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    getter-setterpublic

    getter-setter

    Build Status

    Install

    npm install getter-setter

    2 methods for decorating objects with getters and setters:

    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');

    Full Example

    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'));

    Keywords

    none

    install

    npm i getter-setter

    Downloadsweekly downloads

    16

    version

    0.2.1

    license

    none

    last publish

    collaborators

    • avatar