1.0.2 • Published 1 year ago

@neumatter/slot-map v1.0.2

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

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')