SlotMap
Create private fields using a SlotMap. Similar to internal slots.
Table of Contents
Install
npm i slot-map
Usage
SlotMap.get
:
static Gets or creates the SlotMap for the given object.
import SlotMap from 'slot-map'
const obj = {}
const slotMap = SlotMap.get(obj)
SlotMap.set
:
static Sets the SlotMap for the given object.
import SlotMap from 'slot-map'
const obj = {}
SlotMap.set(obj, slotMap)
SlotMap.setInternal
:
static Sets a property in the SlotMap for the given object.
import SlotMap from 'slot-map'
const obj = {}
SlotMap.setInternal(obj, 'id', '01234')
SlotMap.getInternal
:
static Gets a property in the SlotMap for the given object.
import SlotMap from 'slot-map'
const obj = {}
SlotMap.getInternal(obj, 'id')