pax_global_header00006660000000000000000000000064136153051240014512gustar00rootroot0000000000000052 comment=2f9d654c3bee087f0ea4d71303e12f365d305623 well-known-symbols-3.0.0/000077500000000000000000000000001361530512400152755ustar00rootroot00000000000000well-known-symbols-3.0.0/.github/000077500000000000000000000000001361530512400166355ustar00rootroot00000000000000well-known-symbols-3.0.0/.github/workflows/000077500000000000000000000000001361530512400206725ustar00rootroot00000000000000well-known-symbols-3.0.0/.github/workflows/ci.yml000066400000000000000000000007521361530512400220140ustar00rootroot00000000000000name: Test on: push: branches: - master pull_request: paths-ignore: - '*.md' jobs: nodejs: name: Node.js runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: [^10, ^12, ^13] steps: - uses: actions/checkout@v1 with: fetch-depth: 1 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install --no-audit - run: npm test well-known-symbols-3.0.0/.gitignore000066400000000000000000000000651361530512400172660ustar00rootroot00000000000000/node_modules .nyc_output coverage package-lock.json well-known-symbols-3.0.0/.npmrc000066400000000000000000000000231361530512400164100ustar00rootroot00000000000000package-lock=false well-known-symbols-3.0.0/LICENSE000066400000000000000000000014261361530512400163050ustar00rootroot00000000000000ISC License (ISC) Copyright (c) 2017 Mark Wubben (novemberborn.net) Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. well-known-symbols-3.0.0/README.md000066400000000000000000000011741361530512400165570ustar00rootroot00000000000000# well-known-symbols Check whether a symbol is [well-known](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Well-known_symbols). Requires Node.js 10 or above. Note that not all Node.js versions support the same well-known symbols. ## Installation ```console $ npm install --save well-known-symbols ``` ## Usage ```js const wellKnownSymbols = require('well-known-symbols') wellKnownSymbols.isWellKnown(Symbol.iterator) // true wellKnownSymbols.isWellKnown(Symbol()) // false wellKnownSymbols.getLabel(Symbol.iterator) // 'Symbol.iterator' wellKnownSymbols.getLabel(Symbol()) // undefined ``` well-known-symbols-3.0.0/index.d.ts000066400000000000000000000002301361530512400171710ustar00rootroot00000000000000declare const WellKnownSymbols: { getLabel (value: symbol): string | undefined, isWellKnown (value: symbol): boolean, } export = WellKnownSymbols; well-known-symbols-3.0.0/index.js000066400000000000000000000015101361530512400167370ustar00rootroot00000000000000'use strict' // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Well-known_symbols const WELL_KNOWN = new Map([ [Symbol.iterator, 'Symbol.iterator'], [Symbol.asyncIterator, 'Symbol.asyncIterator'], [Symbol.match, 'Symbol.match'], [Symbol.matchAll, 'Symbol.matchAll'], [Symbol.replace, 'Symbol.replace'], [Symbol.search, 'Symbol.search'], [Symbol.split, 'Symbol.split'], [Symbol.hasInstance, 'Symbol.hasInstance'], [Symbol.isConcatSpreadable, 'Symbol.isConcatSpreadable'], [Symbol.unscopables, 'Symbol.unscopables'], [Symbol.species, 'Symbol.species'], [Symbol.toPrimitive, 'Symbol.toPrimitive'], [Symbol.toStringTag, 'Symbol.toStringTag'] ].filter(entry => entry[0])) exports.isWellKnown = symbol => WELL_KNOWN.has(symbol) exports.getLabel = symbol => WELL_KNOWN.get(symbol) well-known-symbols-3.0.0/index.test-d.ts000066400000000000000000000002711361530512400201530ustar00rootroot00000000000000import { expectType } from 'tsd' import { getLabel, isWellKnown } from '.' expectType(getLabel(Symbol.iterator)) expectType(isWellKnown(Symbol.iterator)) well-known-symbols-3.0.0/package.json000066400000000000000000000017701361530512400175700ustar00rootroot00000000000000{ "name": "well-known-symbols", "version": "3.0.0", "description": "Check whether a symbol is well-known", "main": "index.js", "types": "index.d.ts", "files": [ "index.js", "index.d.ts" ], "engines": { "node": ">=10" }, "scripts": { "test": "standard && tsd && nyc ava" }, "repository": { "type": "git", "url": "git+https://github.com/novemberborn/well-known-symbols.git" }, "keywords": [ "symbols", "es6", "es7", "es8", "es2015", "es2016", "es2017", "es2018", "es2019", "es2020" ], "author": "Mark Wubben (https://novemberborn.net/)", "license": "ISC", "bugs": { "url": "https://github.com/novemberborn/well-known-symbols/issues" }, "homepage": "https://github.com/novemberborn/well-known-symbols#readme", "devDependencies": { "ava": "^3.1.0", "nyc": "^15.0.0", "standard": "^14.3.1", "tsd": "^0.11.0" }, "nyc": { "reporter": [ "html", "lcov", "text" ] } } well-known-symbols-3.0.0/test.js000066400000000000000000000016001361530512400166070ustar00rootroot00000000000000const test = require('ava') const { isWellKnown, getLabel } = require('.') const names = [ 'iterator', 'asyncIterator', 'match', 'replace', 'search', 'split', 'hasInstance', 'isConcatSpreadable', 'unscopables', 'species', 'toPrimitive', 'toStringTag' ] const wellKnown = (t, name, expected) => { t.is(isWellKnown(Symbol[name]), expected) } wellKnown.title = (_, name, expected) => `Symbol.${name} is ${expected ? 'well known' : 'not well known'} (on this platform)` const label = (t, name, expected) => { t.is(getLabel(Symbol[name]), expected) } label.title = (_, name, expected) => { return `Label of Symbol.${name} is ${expected === undefined ? 'undefined' : `'${expected}'`} (on this platform)` } for (const name of names) { test(wellKnown, name, Symbol[name] !== undefined) test(label, name, Symbol[name] === undefined ? undefined : `Symbol.${name}`) }