memorizer

2019-09-08 admin

memorizer是什么

什么是memorizer,memoize a getter of an object

memorizer使用教程帮助文档

memorizer

NPM version build status Test coverage

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.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-74641.html

文章标题:memorizer

回到顶部