JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 89
  • Score
    100M100P100Q12246F
  • License MIT

Memoization in JS made easy

Package Exports

  • sb-memoize

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sb-memoize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Memoize

Memoize is a javascript helper utility to fulfill your function memoization needs.

Installation

npm install --save sb-memoize

API

function memoize(
  callback: Function,
  options = { async: false }
): Function

module.exports = memoize

Examples

import resolve from 'resolve'
import promisify from 'sb-promisify'
import memoize from 'sb-memoize'

const resolveSync = memoize(resolve.sync)
const resolveAsync = memoize(promisify(resolve), { async: true })

console.log(resolveSync('sb-memoize', { basedir: __dirname }))
resolveAsync('sb-memoize', { basedir: __dirname })
  .then(function(path) {
    console.log(path)
  })

Notes

This package automatically adds these methods on any memoized function

clearCache(): void
getCache(parameters: Array<any>): any
setCache(parameters: Array<any>, cacheValue: any): void
deleteCache(parameters: Array<any>): void

License

This project is licensed under the terms of MIT License, see the LICENSE file for more info