symbol.prototype.description
Spec-compliant shim for Symbol.prototype.description proposal.
Last updated 4 years ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install symbol.prototype.description 
SYNC missed versions from official npm registry.

Symbol.prototype.description Version Badge

github actions coverage 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 (eg, node >= v11.15.0)

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');
var assert = require('assert');

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

if (!('description' in Symbol.prototype)) {
	// 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);

	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

Current Tags

  • 1.0.6                                ...           latest (10 months ago)

7 Versions

  • 1.0.6                                ...           10 months ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (10)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE