0.0.2 • Published 9 years ago
declr v0.0.2
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
License
Licensed under the MIT license.