@neumatter/slot-map
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

SlotMap

JavaScript Style Guide

Create private fields using a SlotMap. Similar to internal slots.


Table of Contents


Install

npm i slot-map

Usage

static SlotMap.get:

Gets or creates the SlotMap for the given object.

import SlotMap from 'slot-map'

const obj = {}
const slotMap = SlotMap.get(obj)

static SlotMap.set:

Sets the SlotMap for the given object.

import SlotMap from 'slot-map'

const obj = {}
SlotMap.set(obj, slotMap)

static SlotMap.setInternal:

Sets a property in the SlotMap for the given object.

import SlotMap from 'slot-map'

const obj = {}
SlotMap.setInternal(obj, 'id', '01234')

static SlotMap.getInternal:

Gets a property in the SlotMap for the given object.

import SlotMap from 'slot-map'

const obj = {}
SlotMap.getInternal(obj, 'id')

Package Sidebar

Install

npm i @neumatter/slot-map

Weekly Downloads

3

Version

1.0.2

License

none

Unpacked Size

8.97 kB

Total Files

4

Last publish

Collaborators

  • clyng57