Skip to content

vlazar/lade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lade

npm version Build Status Code Climate Test Coverage devDependencies Status js-standard-style

Defines object properties evaluated and cached on the first read.

Usage

Define lazy property

var obj = {};

lade(obj, 'lazy', function() { return 40 + 2 });

obj.lazy;     // 42 (calls function, returns result as property value)
obj.lazy;     // 42 (uses cached property value from now on)

obj.lazy = 0; // overwrite property value
obj.lazy;     // 0

Define plain property

var obj = {};

lade(obj, 'prop', 'yes');

obj.prop;        // 'yes'

obj.prop = 'no'; // overwrite property value
obj.prop;        // 'no'

About

Lazy object properties

Resources

License

Stars

Watchers

Forks

Packages

No packages published