0.0.2 • Published 10 years ago

declr v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

declr

Assign property value to object, return if assigned

Installation

npm install declr

Usage

Useful when we want to cache property value in object. Consider this example:

var declr = require('declr');

var Cat = function() {}
Cat.prototype = {
	action: null,

	response: function() {
		// i'm a lazy cat and so sleepy
		// zzzZZZ ....
		// .... zzzZZZ
		// zzzZZZ ....
		// .... zzzZZZ
		// zzzZZZ ....
		
		return 'meooowwww';
	},

	petme: function() {
		return declr(this, 'action', this.response());
	}
}

var simon = new Cat();
// response after long time
simon.petme();

// meooowwww
simon.petme();

// meooowwww
simon.petme();

Authors

xmhscratch

License

Licensed under the MIT license.

0.0.2

10 years ago

0.0.1

10 years ago