slex-memoize

$ npm install slex-memoize

Usage no npm install needed!

<script type="module">
  import slexMemoize from 'https://cdn.skypack.dev/slex-memoize';
</script>

README

CircleCI

Slex Memoize

$ npm install slex-memoize

slex-memoize is a memoize function which supports multi argument functions.

Usage

import memoize from 'slex-memoize'
// import memoize, { memoizeArgs as memoize } from 'slex-memoize'

const arg1 = {}
const arg2 = []
const arg3 = () => {}

const memoized = memoize((arg1, arg2, arg3) => {
  // do something
})

const result1 = memoized(arg1, arg2, arg3)
const result2 = memoized(arg1, arg2, arg3)

console.info(result1 === result2) // true

Usage for options pattern

import { memoizeOptions as memoize } from 'slex-memoize'

const arg1 = {}
const arg2 = []
const arg3 = () => {}

const memoized = memoize(({ arg1, arg2, arg3 }) => {
  // do something
})

const result1 = memoized({ arg1, arg2, arg3 })
const result2 = memoized({ arg1, arg2, arg3 })

console.info(result1 === result2) // true