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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    3
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    3
  • 1.0.0
    1
  • 0.0.3
    1
  • 0.0.1
    1
  • 0.0.2
    1

Package Sidebar

Install

npm i lazyprop

Weekly Downloads

7

Version

1.0.1

License

none

Last publish

Collaborators

  • daaku