You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@solid-primitives/map

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/map

The Map & WeakMap data structures as a reactive signals.

0.7.2
latest
Source
npmnpm
Version published
Maintainers
3
Created
Source

Solid Primitives Map

@solid-primitives/map

size version stage

The reactive versions of Map & WeakMap built-in data structures.

  • ReactiveMap - A reactive Map.
  • ReactiveWeakMap - A reactive WeakMap.

Installation

npm install @solid-primitives/map
# or
yarn add @solid-primitives/map
# or
pnpm add @solid-primitives/map

ReactiveMap and ReactiveWeakMap

A reactive version of Map/WeakMap data structure. All the reads (e.g. get or has) are signals, and all the writes (e.g. delete or set) will cause updates to appropriate signals.

How to use it

Import

import { ReactiveMap } from "@solid-primitives/map";
// or
import { ReactiveWeakMap } from "@solid-primitives/map";

Basic usage

The usage is almost the same as the original Javascript structures.

const userPoints = new ReactiveMap<User, number>();
// reads can be listened to reactively
createEffect(() => {
  userPoints.get(user1); // => T: number | undefined (reactive)
  userPoints.has(user1); // => T: boolean (reactive)
  // ReactiveWeakMap won't have .size or any methods that loop over the values
  userPoints.size; // => T: number (reactive)
});
// apply changes
userPoints.set(user1, 100);
userPoints.delete(user2);
userPoints.set(user1, { foo: "bar" });

Constructor arguments

ReactiveMap's and ReactiveWeakMap's constructor one optional argument that is the initial entries of the map.

const map = new ReactiveMap([
  ["foo", [1, 2, 3]],
  ["bar", [3, 4, 5]],
]);

Values are shallowly wrapped

Treat the values of ReactiveMap and ReactiveMap as individual signals, to cause updates, they have to be set through the .set() method, no mutations.

const map = new ReactiveMap<string, { age: number }>();
map.set("John", { age: 34 });

// this won't cause any updates:
map.get("John").age = 35;

// this will:
map.set("John", { age: 35 });

Changelog

See CHANGELOG.md

Keywords

map

FAQs

Package last updated on 29 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.