Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

internal-slot

ljharb135.2mMIT1.1.0TypeScript support: included

ES spec-like internal slots

internal, slot, internal slot, ecmascript, es, spec, private, data, private data, weakmap

readme

internal-slot Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Truly private storage, akin to the JS spec’s concept of internal slots.

Uses a WeakMap when available; a Map when not; and a regular object in even older engines. Performance and garbage collection behavior will reflect the environment’s capabilities accordingly.

Example

var SLOT = require('internal-slot');
var assert = require('assert');

var o = {};

assert.throws(function () { SLOT.assert(o, 'foo'); });

assert.equal(SLOT.has(o, 'foo'), false);
assert.equal(SLOT.get(o, 'foo'), undefined);

SLOT.set(o, 'foo', 42);

assert.equal(SLOT.has(o, 'foo'), true);
assert.equal(SLOT.get(o, 'foo'), 42);

assert.doesNotThrow(function () { SLOT.assert(o, 'foo'); });

Tests

Simply clone the repo, npm install, and run npm test

Security

Please email @ljharb or see https://tidelift.com/security if you have a potential security vulnerability to report.

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v1.1.0

13 December 2024

  • [New] add types 295d25d
  • [actions] split out node 10-20, and 20+ 9c9a2ab
  • [Dev Deps] update @ljharb/eslint-config, auto-changelog, object-inspect, tape 9c5621b
  • [Deps] update hasown, side-channel 5281391
  • [Tests] replace aud with npm audit 64ce191
  • [Dev Deps] add missing peer dep d500343

v1.0.7

5 February 2024

  • [Dev Deps] update aud, npmignore, tape 89c88c1
  • [Refactor] use es-errors, so things that only need those do not need get-intrinsic b437631

v1.0.6

20 October 2023

  • [Dev Deps] update @ljharb/eslint-config, aud, object-inspect, tape 4d568d2
  • [Refactor] use hasown instead of has f946e94
  • [Deps] update get-intrinsic 1bbc885
  • [meta] remove unused .eslintignore 6fdde1a

v1.0.5

9 February 2023

  • [Dev Deps] update @ljharb/eslint-config, aud, object-inspect, tape e427703
  • [Deps] update get-intrinsic aa652f0
  • [Fix] improve assertion message 8df86e3

v1.0.4

13 December 2022

  • [actions] reuse common workflows 82a1aee
  • [meta] use npmignore to autogenerate an npmignore file 56f7e71
  • [actions] use node/install instead of node/run; use codecov action e25ff67
  • [actions] update rebase action to use reusable workflow 227e81e
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, foreach, object-inspect, tape fc9f319
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, object-inspect, safe-publish-latest, tape 0a72a0f
  • [actions] update codecov uploader e2b993f
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, tape 8f0ab80
  • [actions] update checkout action 8da4b91
  • [Dev Deps] update eslint, @ljharb/eslint-config, @safe-publish-latest, tape 7ab37aa
  • [readme] add github actions/codecov badges 71234be
  • [Fix] assert: throw on a nonexistent slot even when an object already has other slots 12580bd
  • [Tests] use for-each instead of foreach 7229df0
  • [meta] use prepublishOnly script for npm 7+ 8728872
  • [Deps] update get-intrinsic 1b7088f
  • [Deps] update get-intrinsic 063621e

v1.0.3

26 January 2021

  • [Tests] use shared travis-ci configs 0ef2263
  • [Tests] migrate tests to Github Actions 6253915
  • [meta] do not publish github action workflow files ef94e55
  • [Tests] run nyc on all tests; use tape runner 917d6ca
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, object-inspect, tape 8dcb6fe
  • [actions] add "Allow Edits" workflow 7aa3e86
  • [Refactor] use get-intrinsic instead of es-abstract; update side-channel 11ad17d
  • [readme] remove travis badge 5b75452
  • [actions] switch Automatic Rebase workflow to pull_request_target event d531688
  • [Dev Deps] update @ljharb/eslint-config, tape c76fa91
  • [Dev Deps] update eslint, tape e733ccd
  • [Dev Deps] update auto-changelog; add aud df20bf5
  • [meta] fix autochangelog e89e6f1
  • [Tests] only audit prod deps 71317b9
  • [Deps] update es-abstract c17ccf4
  • [Dev Deps] update tape d81ae03
  • [Deps] update es-abstract b56303b
  • [Deps] update es-abstract 9996d1c

v1.0.2

20 December 2019

  • [Deps] update es-abstract, side-channel 5c9df03
  • [Dev Deps] update @ljharb/eslint-config, tape 7820f98

v1.0.1

1 December 2019

  • [Refactor] use side-channel package d38639f
  • [actions] add automatic rebasing / merge commit blocking 74267e6
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, object-inspect, safe-publish-latest b042eef
  • [Deps] update es-abstract 98cf4e8

v1.0.0

20 October 2019