prop-factory

Getter-setter factory utility

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
prop-factory
1.0.09 years ago9 years agoMinified + gzip package size for prop-factory in KB

Readme

prop-factory
Getter-setter factory utility.
!npm Versionnpm-badgenpm !Build Statusbuild-badgebuild-status !Test Coveragecoverage-badgecoverage-result !Dependency Statusdep-badgedep-status

Installation

Install using npm:
$ npm install prop-factory

Usage

Borrowed from Mithrilmithril'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