pax_global_header00006660000000000000000000000064141070332000014500gustar00rootroot0000000000000052 comment=6579bf3c250bc1cf12fec4900956ac7f08f34a41 get-symbol-description-1.0.0/000077500000000000000000000000001410703320000161015ustar00rootroot00000000000000get-symbol-description-1.0.0/.eslintignore000066400000000000000000000000121410703320000205750ustar00rootroot00000000000000coverage/ get-symbol-description-1.0.0/.eslintrc000066400000000000000000000002341410703320000177240ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "id-length": 0, "new-cap": [2, { "capIsNewExceptions": [ "GetIntrinsic", ], }], }, } get-symbol-description-1.0.0/.github/000077500000000000000000000000001410703320000174415ustar00rootroot00000000000000get-symbol-description-1.0.0/.github/FUNDING.yml000066400000000000000000000011151410703320000212540ustar00rootroot00000000000000# 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/symbol-description 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 up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] get-symbol-description-1.0.0/.github/workflows/000077500000000000000000000000001410703320000214765ustar00rootroot00000000000000get-symbol-description-1.0.0/.github/workflows/node-4+.yml000066400000000000000000000030111410703320000233550ustar00rootroot00000000000000name: '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: fail-fast: false matrix: ${{ fromJson(needs.matrix.outputs.latest) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} - run: npm run tests-only - uses: codecov/codecov-action@v1 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: fail-fast: false matrix: ${{ fromJson(needs.matrix.outputs.minors) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} - run: npm run tests-only - uses: codecov/codecov-action@v1 node: name: 'node 4+' needs: [latest, minors] runs-on: ubuntu-latest steps: - run: 'echo tests completed' get-symbol-description-1.0.0/.github/workflows/node-iojs.yml000066400000000000000000000032271410703320000241140ustar00rootroot00000000000000name: '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: versionsAsRoot: true preset: 'iojs' latest: needs: [matrix] name: 'latest minors' runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} skip-ls-check: true - run: npm run tests-only - uses: codecov/codecov-action@v1 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: fail-fast: false matrix: node-version: ${{ fromJson(needs.matrix.outputs.minors) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} skip-ls-check: true - run: npm run tests-only - uses: codecov/codecov-action@v1 node: name: 'io.js' needs: [latest, minors] runs-on: ubuntu-latest steps: - run: 'echo tests completed' get-symbol-description-1.0.0/.github/workflows/node-pretest.yml000066400000000000000000000011021410703320000246240ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: pretest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install lts/* && npm install' with: node-version: 'lts/*' - run: npm run pretest posttest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install lts/* && npm install' with: node-version: 'lts/*' - run: npm run posttest get-symbol-description-1.0.0/.github/workflows/node-zero.yml000066400000000000000000000035751410703320000241350ustar00rootroot00000000000000name: '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: versionsAsRoot: true preset: '0.x' stable: needs: [matrix] name: 'stable minors' runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: ${{ fromJson(needs.matrix.outputs.stable) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} skip-ls-check: true - run: npm run tests-only - uses: codecov/codecov-action@v1 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: fail-fast: false matrix: node-version: ${{ fromJson(needs.matrix.outputs.unstable) }} steps: - uses: actions/checkout@v2 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' with: node-version: ${{ matrix.node-version }} cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }} skip-ls-check: true - run: npm run tests-only - uses: codecov/codecov-action@v1 node: name: 'node 0.x' needs: [stable, unstable] runs-on: ubuntu-latest steps: - run: 'echo tests completed' get-symbol-description-1.0.0/.github/workflows/rebase.yml000066400000000000000000000004011410703320000234550ustar00rootroot00000000000000name: 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 }} get-symbol-description-1.0.0/.github/workflows/require-allow-edits.yml000066400000000000000000000003011410703320000261110ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main get-symbol-description-1.0.0/.gitignore000066400000000000000000000032351410703320000200740ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # 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 *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://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/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock get-symbol-description-1.0.0/.npmignore000066400000000000000000000033011410703320000200750ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # 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 *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://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/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock # github actions .github/workflows get-symbol-description-1.0.0/.npmrc000066400000000000000000000000671410703320000172240ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s get-symbol-description-1.0.0/.nycrc000066400000000000000000000002131410703320000172140ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "exclude": [ "coverage", "test" ] } get-symbol-description-1.0.0/CHANGELOG.md000066400000000000000000000017701410703320000177170ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## v1.0.0 - 2021-08-17 ### Commits - Initial commit: pulled from es-abstract [`6e34a05`](https://github.com/inspect-js/get-symbol-description/commit/6e34a05ef10ce8620078cf4cecbe276c1fc1ae77) - Initial commit [`3862092`](https://github.com/inspect-js/get-symbol-description/commit/3862092248d8ffa071ec90ec39d73e8be14ba6f1) - [meta] do not publish github action workflow files [`9d1e2b9`](https://github.com/inspect-js/get-symbol-description/commit/9d1e2b94dd97664da5d0666985a3695c23f45865) - npm init [`5051b32`](https://github.com/inspect-js/get-symbol-description/commit/5051b3221829f364c44b4d5e9a0c35aab3247f6a) - Only apps should have lockfiles [`b866d1c`](https://github.com/inspect-js/get-symbol-description/commit/b866d1c4b4029277618d968cfb3cbe00f012d1a7) get-symbol-description-1.0.0/LICENSE000066400000000000000000000020531410703320000171060ustar00rootroot00000000000000MIT License Copyright (c) 2021 Inspect JS 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. get-symbol-description-1.0.0/README.md000066400000000000000000000037671410703320000173750ustar00rootroot00000000000000# get-symbol-description [![Version Badge][2]][1] [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][5]][6] [![dev dependency status][7]][8] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][11]][1] Gets the description of a Symbol. Handles `Symbol()` vs `Symbol('')` properly when possible. ## Example ```js var getSymbolDescription = require('get-symbol-description'); var assert = require('assert'); assert(getSymbolDescription(Symbol()) === undefined); assert(getSymbolDescription(Symbol('')) === ''); // or `undefined`, if in an engine that lacks name inference from concise method assert(getSymbolDescription(Symbol('foo')) === 'foo'); assert(getSymbolDescription(Symbol.iterator) === 'Symbol.iterator'); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [1]: https://npmjs.org/package/get-symbol-description [2]: https://versionbadg.es/inspect-js/get-symbol-description.svg [5]: https://david-dm.org/inspect-js/get-symbol-description.svg [6]: https://david-dm.org/inspect-js/get-symbol-description [7]: https://david-dm.org/inspect-js/get-symbol-description/dev-status.svg [8]: https://david-dm.org/inspect-js/get-symbol-description#info=devDependencies [11]: https://nodei.co/npm/get-symbol-description.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/get-symbol-description.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/get-symbol-description.svg [downloads-url]: https://npm-stat.com/charts.html?package=get-symbol-description [codecov-image]: https://codecov.io/gh/inspect-js/get-symbol-description/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/get-symbol-description/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/get-symbol-description [actions-url]: https://github.com/inspect-js/get-symbol-description/actions get-symbol-description-1.0.0/getInferredName.js000066400000000000000000000004371410703320000215020ustar00rootroot00000000000000'use strict'; var getInferredName; try { // eslint-disable-next-line no-new-func getInferredName = Function('s', 'return { [s]() {} }[s].name;'); } catch (e) {} var inferred = function () {}; module.exports = getInferredName && inferred.name === 'inferred' ? getInferredName : null; get-symbol-description-1.0.0/index.js000066400000000000000000000022511410703320000175460ustar00rootroot00000000000000'use strict'; var GetIntrinsic = require('get-intrinsic'); var callBound = require('call-bind/callBound'); var $SyntaxError = GetIntrinsic('%SyntaxError%'); var getGlobalSymbolDescription = GetIntrinsic('%Symbol.keyFor%', true); var thisSymbolValue = callBound('%Symbol.prototype.valueOf%', true); var symToStr = callBound('Symbol.prototype.toString', true); var getInferredName = require('./getInferredName'); /* eslint-disable consistent-return */ module.exports = callBound('%Symbol.prototype.description%', true) || function getSymbolDescription(symbol) { if (!thisSymbolValue) { throw new $SyntaxError('Symbols are not supported in this environment'); } // will throw if not a symbol primitive or wrapper object var sym = thisSymbolValue(symbol); if (getInferredName) { var name = getInferredName(sym); if (name === '') { return; } return name.slice(1, -1); // name.slice('['.length, -']'.length); } var desc; if (getGlobalSymbolDescription) { desc = getGlobalSymbolDescription(sym); if (typeof desc === 'string') { return desc; } } desc = symToStr(sym).slice(7, -1); // str.slice('Symbol('.length, -')'.length); if (desc) { return desc; } }; get-symbol-description-1.0.0/package.json000066400000000000000000000037001410703320000203670ustar00rootroot00000000000000{ "name": "get-symbol-description", "version": "1.0.0", "description": "Gets the description of a Symbol. Handles `Symbol()` vs `Symbol('')` properly when possible.", "main": "index.js", "exports": { ".": "./index.js", "./getInferredName": "./getInferredName.js", "./package.json": "./package.json" }, "scripts": { "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "lint": "eslint --ext=.js,.mjs .", "postlint": "evalmd README.md", "pretest": "npm run lint", "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "aud --production", "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)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/inspect-js/get-symbol-description.git" }, "keywords": [ "symbol", "ecmascript", "javascript", "description" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/inspect-js/get-symbol-description/issues" }, "homepage": "https://github.com/inspect-js/get-symbol-description#readme", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.1.1" }, "devDependencies": { "@ljharb/eslint-config": "^17.6.0", "aud": "^1.1.5", "auto-changelog": "^2.3.0", "es-value-fixtures": "^1.2.1", "eslint": "^7.32.0", "evalmd": "^0.0.19", "foreach": "^2.0.5", "has": "^1.0.3", "nyc": "^10.3.2", "object-inspect": "^1.11.0", "safe-publish-latest": "^1.1.4", "tape": "^5.3.1" }, "engines": { "node": ">= 0.4" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true } } get-symbol-description-1.0.0/test/000077500000000000000000000000001410703320000170605ustar00rootroot00000000000000get-symbol-description-1.0.0/test/index.js000066400000000000000000000033731410703320000205330ustar00rootroot00000000000000'use strict'; var test = require('tape'); var debug = require('object-inspect'); var forEach = require('foreach'); var has = require('has'); var v = require('es-value-fixtures'); var getSymbolDescription = require('../'); var getInferredName = require('../getInferredName'); test('getSymbolDescription', function (t) { t.test('no symbols', { skip: v.hasSymbols }, function (st) { st['throws']( getSymbolDescription, SyntaxError, 'requires Symbol support' ); st.end(); }); forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) { t['throws']( function () { getSymbolDescription(nonSymbol); }, v.hasSymbols ? TypeError : SyntaxError, debug(nonSymbol) + ' is not a Symbol' ); }); t.test('with symbols', { skip: !v.hasSymbols }, function (st) { forEach( [ [Symbol(), undefined], [Symbol(undefined), undefined], [Symbol(null), 'null'], [Symbol.iterator, 'Symbol.iterator'], [Symbol('foo'), 'foo'] ], function (pair) { var sym = pair[0]; var desc = pair[1]; st.equal(getSymbolDescription(sym), desc, debug(sym) + ' description is ' + debug(desc)); } ); st.test('only possible when inference or native `Symbol.prototype.description` is supported', { skip: !getInferredName && !has(Symbol.prototype, 'description') }, function (s2t) { s2t.equal(getSymbolDescription(Symbol('')), '', 'Symbol("") description is ""'); s2t.end(); }); st.test('only possible when global symbols are supported', { skip: !has(Symbol, 'for') || !has(Symbol, 'keyFor') }, function (s2t) { // eslint-disable-next-line no-restricted-properties s2t.equal(getSymbolDescription(Symbol['for']('')), '', 'Symbol.for("") description is ""'); s2t.end(); }); st.end(); }); t.end(); });