lazyprop

1.0.1 • Public • Published

lazyprop

Lazy properties for JavaScript. This allows for defining properties that are lazily created using a given function upon first access. Subsequent access to the property exposes the value created by the original function (the function is only called once):

var lazyprop = require('lazyprop')
var obj = {}
lazyprop(obj, 'answer', function() {
  console.log('only called once')
  return 42
})
var answer1 = obj.answer // will console.log
var answer2 = obj.answer // will NOT console.log

Readme

Keywords

none

Package Sidebar

Install

npm i lazyprop

Weekly Downloads

0

Version

1.0.1

License

none

Last publish

Collaborators

  • daaku