0.0.0 • Published 1 month ago
@shortkit/make-lazy v0.0.0
Read at: https://berkekaragoz.com/p/readme-shortkit-make-lazy
const obj = { count: 0, init: false }
const initObj = (count: number) => {
obj.init = true
obj.count = obj.count + count
return obj
}
const lazyObj = makeLazy(() => initObj(5))
obj.init == false
obj.count == 0
lazyObj.value.init == true // ← function runs here
lazyObj.value.count == 5 // ← second access, it is not 10
obj.init == true
obj.count == 5
0.0.0
1 month ago