Skip to content
Spec-compliant shim for Symbol.prototype.description proposal.
JavaScript
Branch: master
Clone or download
Latest commit 014e4b9 Dec 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows [actions] add automatic rebasing / merge commit blocking Dec 13, 2019
helpers [Refactor] use `getSymbolDescription` and `getInferredName` helpers f… Oct 19, 2019
test [Refactor] use `getSymbolDescription` and `getInferredName` helpers f… Oct 19, 2019
.eslintrc [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`; add `saf… Oct 18, 2019
.gitignore Only apps should have lockfiles. Jul 25, 2017
.npmrc Only apps should have lockfiles. Jul 25, 2017
.travis.yml [Tests] use shared travis-ci configs Dec 13, 2019
CHANGELOG.md 1.0.2 Dec 13, 2019
LICENSE Initial commit Jul 25, 2017
README.md [readme] remove testling Dec 13, 2019
auto.js Flesh out es-shim-api requirements. Dec 1, 2017
implementation.js [Refactor] use `getSymbolDescription` and `getInferredName` helpers f… Oct 19, 2019
index.js Flesh out es-shim-api requirements. Dec 1, 2017
package.json
polyfill.js [Fix] `polyfill`: fix always-true logic Jun 16, 2018
shim.js [Refactor] use `getSymbolDescription` and `getInferredName` helpers f… Oct 19, 2019

README.md

Symbol.prototype.description Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

An ECMAScript spec-compliant Symbol.prototype.description shim. Invoke its "shim" method to shim Symbol.prototype.description if it is unavailable. Note: Symbol#description requires a true ES6 environment, specifically one with native Symbols.

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

Most common usage:

var description = require('symbol.prototype.description');

assert(description(Symbol('foo')) === 'foo');
assert(description(Symbol()) === undefined);
assert(description(Symbol(undefined)) === undefined);
assert(description(Symbol(null)) === 'null');

// note: this should be the empty string, but in many engines,
// it is impossible to distinguish Symbol() and Symbol('')
// without globally replacing `Symbol`
assert(description(Symbol('')) === undefined);

if (!Symbol.prototype.description) {
	description.shim();
}

assert(description(Symbol('foo')) === Symbol('foo').description);
assert(description(Symbol()) === Symbol().description);
assert(description(Symbol(undefined)) === Symbol(undefined).description);
assert(description(Symbol(null)) === Symbol(null).description);

assert(Symbol('').description === ''); // this works fine!

Tests

Simply clone the repo, npm install, and run npm test

You can’t perform that action at this time.