well-known-symbols

An ESnext spec-compliant shim/polyfill/replacement for all Well-Known Symbols that works in any environment with Symbols.


Keywords
javascript, ecmascript, polyfill, shim, well-known, symbol, Symbol.asyncIterator, asyncIterator, Symbol.hasInstance, hasInstance, Symbol.isConcatSpreadable, isConcatSpreadable, Symbol.iterator, iterator, Symbol.match, match, Symbol.matchAll, matchAll, Symbol.replace, replace, Symbol.search, search, Symbol.species, species, Symbol.split, split, Symbol.toPrimitive, toPrimitive, Symbol.toStringTag, toStringTag, Symbol.unscopables, unscopables
License
MIT
Install
npm install well-known-symbols@4.0.0

Documentation

well-known-symbols Version Badge

github actions coverage License Downloads

npm badge

An ESnext spec-compliant shim/polyfill/replacement for all Well-Known Symbols that works in any environment with Symbols.

New Well-Known Symbols will be added after they reach stage 3.

This package implements the es-shim API “multi” interface. It works in an ES3-supported environment and complies with the spec.

Note: functionality provided by this package prior to v4 can be found in:

Getting started

npm install --save well-known-symbols

Usage/Examples

const assert = require('assert');

require('well-known-symbols/auto');

assert.equal(typeof Symbol.asyncIterator, 'symbol');
assert.equal(typeof Symbol.hasInstance, 'symbol');
assert.equal(typeof Symbol.isConcatSpreadable, 'symbol');
assert.equal(typeof Symbol.iterator, 'symbol');
assert.equal(typeof Symbol.match, 'symbol');
assert.equal(typeof Symbol.matchAll, 'symbol');
assert.equal(typeof Symbol.replace, 'symbol');
assert.equal(typeof Symbol.search, 'symbol');
assert.equal(typeof Symbol.species, 'symbol');
assert.equal(typeof Symbol.split, 'symbol');
assert.equal(typeof Symbol.toPrimitive, 'symbol');
assert.equal(typeof Symbol.toStringTag, 'symbol');
assert.equal(typeof Symbol.unscopables, 'symbol');

Tests

Clone the repo, npm install, and run npm test