@neumatter/slot-map
v1.0.2
Published
Create private fields using a SlotMap. Similar to internal slots.
Downloads
15
Maintainers
Readme
SlotMap
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')