@emotion/weak-memoize
A memoization function that uses a WeakMap
Last updated 8 years ago by mitchellhamilton .
MIT · Repository · Original npm · Tarball · package.json
$ npm install @emotion/weak-memoize 
SYNC missed versions from official npm registry.

@emotion/weak-memoize

A memoization function that uses a WeakMap

Install

yarn add @emotion/weak-memoize

Usage

Because @emotion/weak-memoize uses a WeakMap the argument must be a non primitive type, e.g. objects, functions, arrays and etc. The function passed to weakMemoize must also only accept a single argument.

import weakMemoize from '@emotion/weak-memoize'

let doThing = weakMemoize(({ someProperty }) => {
  return { newName: someProperty }
})

let obj = { someProperty: true }

let firstResult = doThing(obj)

let secondResult = doThing(obj)

firstResult === secondResult // true

let newObj = { someProperty: true }

let thirdResult = doThing(newObj)

thirdResult === firstResult // false

Current Tags

  • 0.4.0                                ...           latest (2 years ago)
  • 10.0.0-really-unsafe-please-do-not-use.2                                ...           really-unsafe-please-do-not-use (8 years ago)

15 Versions

  • 0.4.0                                ...           2 years ago
  • 0.3.1                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.5                                ...           7 years ago
  • 0.2.4                                ...           7 years ago
  • 0.2.3                                ...           7 years ago
  • 0.2.2                                ...           8 years ago
  • 0.2.1                                ...           8 years ago
  • 0.2.0                                ...           8 years ago
  • 10.0.0-really-unsafe-please-do-not-use.2                                ...           8 years ago
  • 10.0.0-really-unsafe-please-do-not-use.1                                ...           8 years ago
  • 10.0.0-really-unsafe-please-do-not-use.0                                ...           8 years ago
  • 0.1.3                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
Downloads
Total 38
Today 0
This Week 0
This Month 22
Last Day 0
Last Week 12
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE