Buckets:
@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
Xet Storage Details
- Size:
- 740 Bytes
- Xet hash:
- 7a3a77bfe599acab5d5ed644a07368b11ce0dfe209af55d2cdc1728da4c685ec
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.