Skip to content

Type-safe utilities for iterables and iterators in TypeScript and JavaScript.

License

Notifications You must be signed in to change notification settings

nberlette/iterable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@iter/monorepo @iter/able monorepo

TypeScript tools for iterables, iterators, and collections.

Compatible with Deno, Bun, Node, Cloudflare Workers, and more.


JSR NPM MIT

Packages

The packages currently published by this project are summarized below, with brief examples and install instructions.

All of our packages are published to JSR, a modern TypeScript-first registry with a focus on security, performance, and compatibility. Packages are published on JSR under the @iter/* scope, and mirrored on NPM for convenience under the @itter/* organization.

Tip

Click on the name of any package below to be taken to a dedicated README.md file, located in the corresponding subfolder of the ./packages directory. There you will find complete API documentation, in-depth install instructions, and real-world usage examples, and more.

This package provides an IterableWeakMap class that can be used as a drop-in replacement for the standard WeakMap class. With an iterable API that implements both the standard Map and WeakMap interfaces, it provides a familiar surface area that can be used in place of either of its native counterparts.

Installation

Deno

deno add jsr:@iter/weak-map

JSR

npx jsr add @iter/weak-map

NPM

npm install @itter/weak-map

Example Usage

import { IterableWeakMap } from "@iter/weak-map";

// drop-in replacement for WeakMap
const weakMap = new IterableWeakMap([
  [{ key: 42 }, "Hello, World!"],
  [{ key: 41 }, "Goodbye, World!"],
]);

// but with an iterable API similar to Map
for (const [key, value] of weakMap) {
  console.log(key, value);
}

// and all the methods you'd expect from a Map
weakMap.set({ key: 43 }, "How do we get the key with no reference?");

const likeThis = [...weakMap.keys()].pop();

Note

In the context of this project, the phrase "Supports Deno" includes both Deno Deploy and the Deno Runtime (also known as the "Deno CLI"), unless otherwise specified.

Note that not all runtime APIs are available in Deno Deploy that are available in the Deno CLI. If a package is not fully compatible with the Deno Deploy serverless (edge) runtime, it will be noted in the package's README.md file.


MIT © Nicholas Berlette. All rights reserved.

GitHub · Issues · JSR · NPM · Deno

About

Type-safe utilities for iterables and iterators in TypeScript and JavaScript.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published