Skip to content

Latest commit

 

History

History
43 lines (24 loc) · 1.12 KB

readme.md

File metadata and controls

43 lines (24 loc) · 1.12 KB

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 symbol of a well-known symbol, given the name

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

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

const name = Known.getName ( Symbol.asyncIterator ); // '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