memo
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

memo

Memoization with shallowly comparing object arguments with support for document fragments.

Based on fast-memoize.js by Caio Gondim.

npm i memo
import { memo } from 'memo';
 
let called = 0
const memoized = memo(
  a => {
    called++
    return a
  }
)
let obj = { a: 9 }
console.log(memoized(obj) === obj)
console.log(memoized({ a: 9 }) === obj)
console.log(called === 1)
 
let obj2 = { a: 7 }
console.log(memoized(obj2) === obj2)
console.log(called === 2)

/memo/

    Package Sidebar

    Install

    npm i memo

    Weekly Downloads

    59

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    35.2 kB

    Total Files

    9

    Last publish

    Collaborators

    • luwes