prop-factory
v1.0.0
Published
Getter-setter factory utility
Downloads
1,048
Maintainers
Readme
prop-factory
Getter-setter factory utility.
Installation
Install using npm:
$ npm install prop-factory
Usage
Borrowed from Mithril's m.prop
, prop-factory is a simple
factory that returns a function for storing and retrieving a value.
var prop = require('prop-factory');
// Define a setter-getter with an initial value of "John" (without a given
// value, the initial value will be undefined)
var name = prop('John');
// Read the value
var a = name(); // a === 'John'
// Set the value to "Mary"
name('Mary');
// Read the new value
var b = name(); // b === 'Mary'
License
MIT