1.0.0 • Published 3 months ago

known-symbols v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

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

1.0.0

3 months ago