pax_global_header 0000666 0000000 0000000 00000000064 14004073707 0014514 g ustar 00root root 0000000 0000000 52 comment=94c565fba1d59f1f5dc510c66e9d3554240c7b14
internal-slot-1.0.3/ 0000775 0000000 0000000 00000000000 14004073707 0014310 5 ustar 00root root 0000000 0000000 internal-slot-1.0.3/.eslintignore 0000664 0000000 0000000 00000000012 14004073707 0017004 0 ustar 00root root 0000000 0000000 coverage/
internal-slot-1.0.3/.eslintrc 0000664 0000000 0000000 00000000322 14004073707 0016131 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"rules": {
"max-params": [2, 3],
"new-cap": [2, { "capIsNewExceptions": ["GetIntrinsic"] }],
"no-magic-numbers": 0,
"operator-linebreak": [2, "before"],
},
}
internal-slot-1.0.3/.github/ 0000775 0000000 0000000 00000000000 14004073707 0015650 5 ustar 00root root 0000000 0000000 internal-slot-1.0.3/.github/FUNDING.yml 0000664 0000000 0000000 00000001057 14004073707 0017470 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/internal-slot
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with a single custom sponsorship URL
internal-slot-1.0.3/.github/workflows/ 0000775 0000000 0000000 00000000000 14004073707 0017705 5 ustar 00root root 0000000 0000000 internal-slot-1.0.3/.github/workflows/node-4+.yml 0000664 0000000 0000000 00000002450 14004073707 0021572 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '>=4'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
node:
name: 'node 4+'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
internal-slot-1.0.3/.github/workflows/node-iojs.yml 0000664 0000000 0000000 00000002636 14004073707 0022326 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js (io.js)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
minors: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: 'iojs'
latest:
needs: [matrix]
name: 'latest minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
skip-ls-check: true
minors:
needs: [matrix, latest]
name: 'non-latest minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
skip-ls-check: true
node:
name: 'io.js'
needs: [latest, minors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
internal-slot-1.0.3/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000001067 14004073707 0023045 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run pretest'
with:
node-version: 'lts/*'
command: 'pretest'
posttest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run posttest'
with:
node-version: 'lts/*'
command: 'posttest'
internal-slot-1.0.3/.github/workflows/node-zero.yml 0000664 0000000 0000000 00000003040 14004073707 0022327 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js (0.x)'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
stable: ${{ steps.set-matrix.outputs.requireds }}
unstable: ${{ steps.set-matrix.outputs.optionals }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
preset: '0.x'
stable:
needs: [matrix]
name: 'stable minors'
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.stable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
unstable:
needs: [matrix, stable]
name: 'unstable minors'
continue-on-error: true
if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.unstable) }}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
with:
node-version: ${{ matrix.node-version }}
command: 'tests-only'
cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
skip-ls-check: true
node:
name: 'node 0.x'
needs: [stable, unstable]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
internal-slot-1.0.3/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000401 14004073707 0021664 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
internal-slot-1.0.3/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000301 14004073707 0024320 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
internal-slot-1.0.3/.gitignore 0000664 0000000 0000000 00000001745 14004073707 0016307 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
internal-slot-1.0.3/.npmignore 0000664 0000000 0000000 00000001770 14004073707 0016314 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
.github/workflows
internal-slot-1.0.3/.npmrc 0000664 0000000 0000000 00000000067 14004073707 0015433 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
internal-slot-1.0.3/.nycrc 0000664 0000000 0000000 00000000330 14004073707 0015423 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}
internal-slot-1.0.3/CHANGELOG.md 0000664 0000000 0000000 00000012156 14004073707 0016126 0 ustar 00root root 0000000 0000000 ### Changelog
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### [v1.0.3](https://github.com/ljharb/internal-slot/compare/v1.0.2...v1.0.3)
> 26 January 2021
- [Tests] use shared travis-ci configs [`0ef2263`](https://github.com/ljharb/internal-slot/commit/0ef22634fa2269d9df0d784aca3c5748e8eabd3b)
- [Tests] migrate tests to Github Actions [`6253915`](https://github.com/ljharb/internal-slot/commit/6253915d28721df2eda5630849bc6b57647e3ee2)
- [meta] do not publish github action workflow files [`ef94e55`](https://github.com/ljharb/internal-slot/commit/ef94e555727ed6a649ef64010904fe89a468d459)
- [Tests] run `nyc` on all tests; use `tape` runner [`917d6ca`](https://github.com/ljharb/internal-slot/commit/917d6ca630cdcd6b4da9a2c300c6a3abb6e724fe)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`8dcb6fe`](https://github.com/ljharb/internal-slot/commit/8dcb6fe01d6a45e1af17a9dace95ca47c99b4328)
- [actions] add "Allow Edits" workflow [`7aa3e86`](https://github.com/ljharb/internal-slot/commit/7aa3e86edb0149fd882717481885760aeb28474e)
- [Refactor] use `get-intrinsic` instead of `es-abstract`; update `side-channel` [`11ad17d`](https://github.com/ljharb/internal-slot/commit/11ad17d4255adcbc55fd4eca0bf6733bac59f1bf)
- [readme] remove travis badge [`5b75452`](https://github.com/ljharb/internal-slot/commit/5b754523aa07e8f67d0135df75059a18047292bb)
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`d531688`](https://github.com/ljharb/internal-slot/commit/d5316880956b4dd83e6b6c9ab48fdd8171a4a268)
- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`c76fa91`](https://github.com/ljharb/internal-slot/commit/c76fa91a7e623a738e22332bee4e985aea41122e)
- [Dev Deps] update `eslint`, `tape` [`e733ccd`](https://github.com/ljharb/internal-slot/commit/e733ccd68e81c72ef2e02726e001895053de7887)
- [Dev Deps] update `auto-changelog`; add `aud` [`df20bf5`](https://github.com/ljharb/internal-slot/commit/df20bf5d3943a533c20799d8cc1449997e85d53b)
- [meta] fix autochangelog [`e89e6f1`](https://github.com/ljharb/internal-slot/commit/e89e6f1ff9f10f386e6400b586db78ad9c0f1309)
- [Tests] only audit prod deps [`71317b9`](https://github.com/ljharb/internal-slot/commit/71317b95ec6bbd9877807da0c0316ee9f5f30fab)
- [Deps] update `es-abstract` [`c17ccf4`](https://github.com/ljharb/internal-slot/commit/c17ccf45f4cb0d3b7a1536e9cd3a7ff9a7dafd21)
- [Dev Deps] update `tape` [`d81ae03`](https://github.com/ljharb/internal-slot/commit/d81ae030a0e8f58cee00f752601ce60405a93d78)
- [Deps] update `es-abstract` [`b56303b`](https://github.com/ljharb/internal-slot/commit/b56303b4c3af7a510f9f51860895a46fd2e14752)
- [Deps] update `es-abstract` [`9996d1c`](https://github.com/ljharb/internal-slot/commit/9996d1cf3507750c7a6845a2fb0d0f849ea898a1)
#### [v1.0.2](https://github.com/ljharb/internal-slot/compare/v1.0.1...v1.0.2)
> 20 December 2019
- [Deps] update `es-abstract`, `side-channel` [`5c9df03`](https://github.com/ljharb/internal-slot/commit/5c9df03a25518f5c482cff4e1447a26fa071df9a)
- [Dev Deps] update `@ljharb/eslint-config`, `tape` [`7820f98`](https://github.com/ljharb/internal-slot/commit/7820f984e523a64ddf3068c4e5631abf61eb1ea4)
#### [v1.0.1](https://github.com/ljharb/internal-slot/compare/v1.0.0...v1.0.1)
> 1 December 2019
- [Refactor] use `side-channel` package [`d38639f`](https://github.com/ljharb/internal-slot/commit/d38639f0a3cdb5090711179d0e78df857ecbd5d3)
- [actions] add automatic rebasing / merge commit blocking [`74267e6`](https://github.com/ljharb/internal-slot/commit/74267e6e591e18ba39186cb99139d3fd7a757c9f)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `auto-changelog`, `object-inspect`, `safe-publish-latest` [`b042eef`](https://github.com/ljharb/internal-slot/commit/b042eefc067b830bbd370833f7f21754e802b0b2)
- [Deps] update `es-abstract` [`98cf4e8`](https://github.com/ljharb/internal-slot/commit/98cf4e86c1bfe99eda7b11a8ea70394368f33e4f)
#### v1.0.0
> 20 October 2019
- Tests [`b50fa41`](https://github.com/ljharb/internal-slot/commit/b50fa41b6f47aba39ac4cb733658580974a0b00a)
- implementation [`c5a59f3`](https://github.com/ljharb/internal-slot/commit/c5a59f3753677f81aa12a0226d3b1187846d06dd)
- Initial commit [`15ebe4d`](https://github.com/ljharb/internal-slot/commit/15ebe4dc6d46885f67969d64c9c3e705780963f8)
- readme [`382a3f5`](https://github.com/ljharb/internal-slot/commit/382a3f53d8975e6488373a0fc2abcdc7c4c44247)
- npm init [`d5e7c97`](https://github.com/ljharb/internal-slot/commit/d5e7c977ef694e89c245fd11165f63c06a7a5040)
- [meta] add FUNDING.yml [`685b608`](https://github.com/ljharb/internal-slot/commit/685b6087613f6735f4411a558500d92f8a3ec3f2)
- [meta] add `auto-changelog`, `safe-publish-latest` [`f8fdf1c`](https://github.com/ljharb/internal-slot/commit/f8fdf1c3f0c592f71746da6d7f8bea18f8946dda)
- [Tests] add `npm run lint` [`baaaa09`](https://github.com/ljharb/internal-slot/commit/baaaa09ab6e5bc5fcc0e7c76e10c55aa18f4ca7e)
- Only apps should have lockfiles [`dfa7efa`](https://github.com/ljharb/internal-slot/commit/dfa7efa3d5cd23261cb75c2adab6ee3c06790fee)
internal-slot-1.0.3/LICENSE 0000664 0000000 0000000 00000002057 14004073707 0015321 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2019 Jordan Harband
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
internal-slot-1.0.3/README.md 0000664 0000000 0000000 00000003570 14004073707 0015574 0 ustar 00root root 0000000 0000000 # internal-slot [![Version Badge][npm-version-svg]][package-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
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
```js
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](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
[package-url]: https://npmjs.org/package/internal-slot
[npm-version-svg]: https://versionbadg.es/ljharb/internal-slot.svg
[deps-svg]: https://david-dm.org/ljharb/internal-slot.svg
[deps-url]: https://david-dm.org/ljharb/internal-slot
[dev-deps-svg]: https://david-dm.org/ljharb/internal-slot/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/internal-slot#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/internal-slot.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/internal-slot.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/internal-slot.svg
[downloads-url]: https://npm-stat.com/charts.html?package=internal-slot
internal-slot-1.0.3/index.js 0000664 0000000 0000000 00000002740 14004073707 0015760 0 ustar 00root root 0000000 0000000 'use strict';
var GetIntrinsic = require('get-intrinsic');
var has = require('has');
var channel = require('side-channel')();
var $TypeError = GetIntrinsic('%TypeError%');
var SLOT = {
assert: function (O, slot) {
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
throw new $TypeError('`O` is not an object');
}
if (typeof slot !== 'string') {
throw new $TypeError('`slot` must be a string');
}
channel.assert(O);
},
get: function (O, slot) {
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
throw new $TypeError('`O` is not an object');
}
if (typeof slot !== 'string') {
throw new $TypeError('`slot` must be a string');
}
var slots = channel.get(O);
return slots && slots['$' + slot];
},
has: function (O, slot) {
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
throw new $TypeError('`O` is not an object');
}
if (typeof slot !== 'string') {
throw new $TypeError('`slot` must be a string');
}
var slots = channel.get(O);
return !!slots && has(slots, '$' + slot);
},
set: function (O, slot, V) {
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
throw new $TypeError('`O` is not an object');
}
if (typeof slot !== 'string') {
throw new $TypeError('`slot` must be a string');
}
var slots = channel.get(O);
if (!slots) {
slots = {};
channel.set(O, slots);
}
slots['$' + slot] = V;
}
};
if (Object.freeze) {
Object.freeze(SLOT);
}
module.exports = SLOT;
internal-slot-1.0.3/package.json 0000664 0000000 0000000 00000002775 14004073707 0016611 0 ustar 00root root 0000000 0000000 {
"name": "internal-slot",
"version": "1.0.3",
"description": "ES spec-like internal slots",
"main": "index.js",
"scripts": {
"prepublish": "safe-publish-latest",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
"pretest": "npm run lint",
"lint": "eslint .",
"tests-only": "nyc tape 'test/**/*.js'",
"test": "npm run tests-only",
"posttest": "aud --production"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/internal-slot.git"
},
"keywords": [
"internal",
"slot",
"internal slot",
"ecmascript",
"es",
"spec",
"private",
"data",
"private data",
"weakmap"
],
"author": "Jordan Harband ",
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/internal-slot/issues"
},
"homepage": "https://github.com/ljharb/internal-slot#readme",
"engines": {
"node": ">= 0.4"
},
"devDependencies": {
"@ljharb/eslint-config": "^17.5.0",
"aud": "^1.1.3",
"auto-changelog": "^2.2.1",
"eslint": "^7.18.0",
"foreach": "^2.0.5",
"nyc": "^10.3.2",
"object-inspect": "^1.9.0",
"safe-publish-latest": "^1.1.4",
"tape": "^5.1.1"
},
"dependencies": {
"get-intrinsic": "^1.1.0",
"has": "^1.0.3",
"side-channel": "^1.0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false
}
}
internal-slot-1.0.3/test/ 0000775 0000000 0000000 00000000000 14004073707 0015267 5 ustar 00root root 0000000 0000000 internal-slot-1.0.3/test/index.js 0000664 0000000 0000000 00000005556 14004073707 0016747 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var inspect = require('object-inspect');
var forEach = require('foreach');
var SLOT = require('../');
test('assert', function (t) {
forEach([null, undefined, true, false, 'foo', '', 42, 0], function (primitive) {
t['throws'](
function () { SLOT.assert(primitive, ''); },
TypeError,
inspect(primitive) + ' is not an Object'
);
});
forEach([null, undefined, true, false, 42, 0, {}, [], function () {}, /a/g], function (nonString) {
t['throws'](
function () { SLOT.assert({}, nonString); },
TypeError,
inspect(nonString) + ' is not a String'
);
});
t['throws'](
function () { SLOT.assert({}, 'whatever'); },
TypeError,
'nonexistent slot throws'
);
var o = {};
SLOT.set(o, 'x');
t.doesNotThrow(function () { SLOT.assert(o, 'x'); }, 'existent slot noops');
t.end();
});
test('has', function (t) {
forEach([null, undefined, true, false, 'foo', '', 42, 0], function (primitive) {
t['throws'](
function () { SLOT.has(primitive, ''); },
TypeError,
inspect(primitive) + ' is not an Object'
);
});
forEach([null, undefined, true, false, 42, 0, {}, [], function () {}, /a/g], function (nonString) {
t['throws'](
function () { SLOT.has({}, nonString); },
TypeError,
inspect(nonString) + ' is not a String'
);
});
var o = {};
t.equal(SLOT.has(o, 'nonexistent'), false, 'nonexistent slot yields false');
SLOT.set(o, 'foo');
t.equal(SLOT.has(o, 'foo'), true, 'existent slot yields true');
t.end();
});
test('get', function (t) {
forEach([null, undefined, true, false, 'foo', '', 42, 0], function (primitive) {
t['throws'](
function () { SLOT.get(primitive, ''); },
TypeError,
inspect(primitive) + ' is not an Object'
);
});
forEach([null, undefined, true, false, 42, 0, {}, [], function () {}, /a/g], function (nonString) {
t['throws'](
function () { SLOT.get({}, nonString); },
TypeError,
inspect(nonString) + ' is not a String'
);
});
var o = {};
t.equal(SLOT.get(o, 'nonexistent'), undefined, 'nonexistent slot is undefined');
var v = {};
SLOT.set(o, 'f', v);
t.equal(SLOT.get(o, 'f'), v, '"get" retrieves value set by "set"');
t.end();
});
test('set', function (t) {
forEach([null, undefined, true, false, 'foo', '', 42, 0], function (primitive) {
t['throws'](
function () { SLOT.set(primitive, ''); },
TypeError,
inspect(primitive) + ' is not an Object'
);
});
forEach([null, undefined, true, false, 42, 0, {}, [], function () {}, /a/g], function (nonString) {
t['throws'](
function () { SLOT.set({}, nonString); },
TypeError,
inspect(nonString) + ' is not a String'
);
});
var o = function () {};
t.equal(SLOT.get(o, 'f'), undefined, 'slot not set');
SLOT.set(o, 'f', 42);
t.equal(SLOT.get(o, 'f'), 42, 'slot was set');
SLOT.set(o, 'f', Infinity);
t.equal(SLOT.get(o, 'f'), Infinity, 'slot was set again');
t.end();
});