known-symbols
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Known Symbols

A little library for working with well-known symbols.

Install

npm install --save known-symbols

Usage

import Known from 'known-symbols';

// Retrieve all the well-known symbols

const symbols = Known.getSymbols (); // [Symbol.asyncIterator, Symbol.hasInstance, Symbol.isConcatSpreadable, ...]

// Retrieve all the names of well-known symbols

const names = Known.getNames (); // ['asyncIterator', 'hasInstance', 'isConcatSpreadable', ...]

// Retrieve the name of a well-known symbol, given the symbol

const name = Known.getName ( Symbol.asyncIterator ); // 'asyncIterator'

// Retrieve the symbol of a well-known symbol, given the name

const symbol = Known.getSymbol ( 'asyncIterator' ); // Symbol.asyncIterator

// Check if a symbol is a well-known symbol

const isKnownSymbol = Known.hasSymbol ( Symbol.asyncIterator ); // true

// Check if a string is the name of a well-known symbol

const isKnownName = Known.hasName ( 'asyncIterator' ); // true

License

MIT © Fabio Spampinato

Package Sidebar

Install

npm i known-symbols

Weekly Downloads

1

Version

1.0.0

License

none

Unpacked Size

7 kB

Total Files

9

Last publish

Collaborators

  • fabiospampinato