# @cspell/strong-weak-map

> A Map with weakly referenced values.

Latest version **10.3.3** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cspell/strong-weak-map
pnpm add @cspell/strong-weak-map
yarn add @cspell/strong-weak-map
bun add @cspell/strong-weak-map
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 10.3.3 |
| Published | 2026-09-16 |
| First published | 2022-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.18.0 |
| Dependencies | 0 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1670 |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | Map, WeakMap, Weak, Values |

## Links

- npm: https://www.npmjs.com/package/@cspell/strong-weak-map
- Repository: https://github.com/streetsidesoftware/cspell
- Homepage: https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-strong-weak-map#readme
- Issues: https://github.com/streetsidesoftware/cspell
- npm.io page: https://npm.io/package/@cspell/strong-weak-map

## Recent versions

- 10.3.3 (latest) — 2026-09-16
- 10.3.4-alpha.0 (next) — 2026-09-17
- 10.3.2 — 2026-09-15
- 10.3.2-alpha.0 — 2026-09-13
- 10.3.1 — 2026-09-13
- 10.3.1-alpha.1 — 2026-09-12
- 10.3.1-alpha.0 — 2026-09-12
- 10.3.0 — 2026-09-08
- 10.3.0-alpha.0 — 2026-09-04
- 10.2.2 — 2026-09-04
- 10.2.1 — 2026-09-03
- 10.2.0 — 2026-08-31
- 10.2.0-alpha.7 — 2026-08-30
- 10.2.0-alpha.5 — 2026-08-30
- 10.2.0-alpha.4 — 2026-08-30
- … 157 more at https://npm.io/package/@cspell/strong-weak-map/versions

## README

# `@cspell/strong-weak-map`

A Map with weakly referenced values.

JavaScript [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) provides weak keys and strong values.

`StrongWeakMap` allows for strong keys and weak values while providing the same API as [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).

## Install

```sh
npm install -S @cspell/strong-weak-map
```

## Usage

TypeScript Example: Simple text file reader.

```ts
import { StrongWeakMap } from '@cspell/strong-weak-map';
import { promises as fs } from 'fs';

const cache = new StrongWeakMap<string, Promise<string>>();

export function readTextFile(filename: string, encoding: BufferEncoding = 'utf8'): Promise<string> {
  const cached = cache.get(filename);
  if (cached) return cached;

  const content = fs.readFile(filename, encoding);

  cache.set(filename, content);

  return content;
}
```

The above example will reuse the promise as long as it has not been cleaned up by the Garbage Collector.

## API

See: [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)

<!--- @@inject: ../../static/footer.md --->

<br/>

---

<p align="center">Brought to you by<a href="https://streetsidesoftware.com" title="Street Side Software"><img width="16" alt="Street Side Software Logo" src="https://i.imgur.com/CyduuVY.png" /> Street Side Software</a></p>

<!--- @@inject-end: ../../static/footer.md --->

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