/ archiveofbelonging.org / back / node_modules / @emotion / weak-memoize /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]src/2 years ago -  
[DIR]dist/2 years ago -  
[DIR]types/2 years ago -  
[TXT]CHANGELOG.md39 years ago819  
[   ]LICENSE39 years ago1.1K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
[TXT]README.md39 years ago740 f12eb36 documentaiton updates [كارل مبارك]
[   ]package.json2 years ago1.6K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
README.md

@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
Apache/2.4.38 (Debian) Server at www.karls.computer Port 80