You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
532 B

"use strict"
function addLazyProperty(object, name, initializer, enumerable) {
Object.defineProperty(object, name, {
get: function() {
var v = initializer.call(this)
Object.defineProperty(this, name, { value: v, enumerable: !!enumerable, writable: true })
return v
},
set: function(v) {
Object.defineProperty(this, name, { value: v, enumerable: !!enumerable, writable: true })
return v
},
enumerable: !!enumerable,
configurable: true
})
}
module.exports = addLazyProperty