lazy-instance
Lazily define instance properties through the prototype chain.
This provides a mechanism to dynamically add instance values via the prototype chain without modifying constructors. Very useful for those using a subscriber pattern such as AngularJs or KnockoutJs.
Installation
Node
npm install lazy-instance
Web
bower install lazy-instance
Usage
node
var lazyInstance = ; {} ; console;
web (global)
web (amd)
require;;
API
lazyInstance(ctor, name, create)
Assigns a lazy instance property to the prototype chain of ctor
.
Examples
KnockoutJS
{ thisa = ko;} ; ; var instances = 0 1 2; console;// result: 2 3 4 instances0; instances0; // 8instances1; instances1; // 18instances2; instances2; // 30 console;// result: 8 18 30