memorizer

memoize a getter of an object

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
memorizer
1.0.18 years ago10 years agoMinified + gzip package size for memorizer in KB

Readme

memorizer
!NPM versionnpm-imagenpm-url !build statustravis-imagetravis-url !Test coveragecoveralls-imagecoveralls-url
Memoize a property with a lazy callback. Great for creating internal promises or computationally expensive rproperties.
const memoize = require('memorizer')

function Constructor () {
  this.promise.then(val => {
    // val === true
  })
}

memoize(Constructor.prototype, 'promise', function () {
  return new Promise(true)
})

API

memoize(object: Object, property: String, getter: Function)

The getter's return value will be memoized.