Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
.npmignore | D | 12-May-2024 | 105 | 16 | 14 | |
LICENSE | D | 12-May-2024 | 1.1 KiB | 23 | 17 | |
README.md | D | 12-May-2024 | 806 | 45 | 32 | |
component.json | D | 12-May-2024 | 177 | 8 | 7 | |
lazyProperty.js | D | 12-May-2024 | 532 | 20 | 17 | |
package.json | D | 12-May-2024 | 1.5 KiB | 66 | 65 |
README.md
1lazy-property 2============= 3Adds a lazily initialized property to an object. 4 5## Example 6 7```javascript 8var addLazyProperty = require("lazy-property") 9 10var obj = {} 11 12addLazyProperty(obj, "foo", function() { 13 console.log("initialized!") 14 return "bar" 15}) 16 17//Access the property 18console.log(obj.foo) 19console.log(obj.foo) 20 21//Prints out: 22// 23// initialized! 24// bar 25// bar 26// 27``` 28 29## Install 30 31 npm install lazy-property 32 33## API 34 35### `require("lazy-property")(obj, name, init[, enumerable])` 36Adds a lazily initialized property to the object. 37 38* `obj` is the object to add the property to 39* `name` is the name of the property 40* `init` is a function that computes the value of the property 41* `enumerable` if the property is enumerable (default `false`) 42 43## Credits 44(c) 2013 Mikola Lysenko. MIT License 45