# @emotion/weak-memoize

> A memoization function that uses a WeakMap

Latest version **0.4.0** (published 2024-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @emotion/weak-memoize
pnpm add @emotion/weak-memoize
yarn add @emotion/weak-memoize
bun add @emotion/weak-memoize
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2024-07-19 |
| First published | 2018-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18020 |
| Maintainers | emmatown, tkh44, emotion-release-bot, andarist |

## Links

- npm: https://www.npmjs.com/package/@emotion/weak-memoize
- Repository: https://github.com/emotion-js/emotion.git#main
- Homepage: https://github.com/emotion-js/emotion/tree/main#readme
- Issues: https://github.com/emotion-js/emotion/issues
- npm.io page: https://npm.io/package/@emotion/weak-memoize

## Recent versions

- 0.4.0 (latest) — 2024-07-19
- 10.0.0-really-unsafe-please-do-not-use.2 (really-unsafe-please-do-not-use) — 2018-09-28
- 0.3.1 — 2023-05-06
- 0.3.0 — 2022-07-31
- 0.2.5 — 2019-12-22
- 0.2.4 — 2019-09-17
- 0.2.3 — 2019-06-25
- 0.2.2 — 2018-11-20
- 0.2.1 — 2018-11-13
- 0.2.0 — 2018-10-13
- 10.0.0-really-unsafe-please-do-not-use.1 — 2018-09-28
- 10.0.0-really-unsafe-please-do-not-use.0 — 2018-09-27
- 0.1.3 — 2018-09-20
- 0.1.2 — 2018-07-29
- 0.1.1 — 2018-07-15

## README

# @emotion/weak-memoize

> A memoization function that uses a WeakMap

## Install

```bash
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.

```jsx
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
```

---
_Source: https://npm.io/package/@emotion/weak-memoize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
