Package detail

symbol.prototype.description

es-shims6.8mMIT1.0.7

Spec-compliant shim for Symbol.prototype.description proposal.

polyfill, shim, es, shim

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.0.7 - 2024-12-18

Commits

  • [Robustness] use gopd and es-object-atoms babe493
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, auto-changelog, hasown, tape 4ecdf7b
  • [Deps] update call-bind, has-symbols, object.getownpropertydescriptors 3f32d5d
  • [Tests] replace aud with npm audit fc695b1
  • [Dev Deps] add missing peer dep 0101aa6

v1.0.6 - 2024-02-15

Commits

  • [actions] reuse common workflows 92fa371
  • [Fix] behave properly in a pre-Symbol environment d61003b
  • [meta] use npmignore to autogenerate an npmignore file 7ba5498
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape b49e7eb
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, reflect.ownkeys, tape e6351a6
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud ,npmignore, reflect.ownkeys, tape 409cc9b
  • [actions] update rebase action to use reusable workflow 5059d72
  • [actions] update codecov uploader 1e98508
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, reflect.ownkeys, tape 67b55d3
  • [Deps] update call-bind, get-symbol-description, object.getownpropertydescriptors 19c078d
  • [readme] add github actions/codecov badges 79fa955
  • [Dev Deps] update @ljharb/eslint-config, @es-shims/api, reflect.ownkeys cd0fa9d
  • [Deps] update has-symbol, object.getownpropertydescriptors 462aace
  • [actions] update workflows 75f45ff
  • [Deps] update object.getownpropertydescriptors 643f896
  • [Deps] update object.getownpropertydescriptors c6b9eba

v1.0.5 - 2021-08-17

Commits

  • [actions] use node/install instead of node/run; use codecov action 071b81c
  • [Refactor] use get-symbol-description, extracted from es-abstract 158e940
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape 8ba38ec
  • [actions] restore 0.x test config, from 071b81c d0562a9
  • [Deps] update es-abstract, has-symbols 4be56f3
  • [Dev Deps] update eslint, tape 184c012
  • [meta] use prepublishOnly script for npm 7+ e93c72f
  • [meta] add sideEffects flag 57faa96

v1.0.4 - 2021-02-21

Commits

  • [meta] do not publish github action workflow files c95b746
  • [readme] fix repo URLs; remove travis badge 91f9c78
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, has-strict-mode, reflect-ownkeys, tape c14b5eb
  • [actions] update workflows 828203c
  • [Deps] update call-bind, es-abstract, object.getownpropertydescriptors a5816d2
  • [Tests] increase coverage 73d9e5b

v1.0.3 - 2020-11-23

Fixed

  • [Fix] ensure Symbol shim retains the same own properties as the original #13

Commits

  • [Tests] migrate tests to Github Actions e9a2754
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape d5cff61
  • [Tests] add implementation test; use tape runner 9a0afe5
  • [Tests] run nyc on all tests a33e2d6
  • [actions] add "Allow Edits" workflow b5f001e
  • [Deps] update es-abstract; use call-bind where applicable fe59e37
  • [Dev Deps] update eslint, aud, auto-changelog ee0c319
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 66d8264
  • [Deps] update es-abstract fc88f15
  • [Tests] fix failing tests 86825ca
  • [Dev Deps] update auto-changelog; add aud 94de63f
  • [meta] fix auto-changelog npmrc settings 4c09543
  • [Deps] update es-abstract 0a85899
  • [actions] switch Automatic Rebase workflow to pull_request_target event cf95a5c
  • [Dev Deps] update auto-changelog 38e903a
  • [Tests] only audit prod deps 66fc2ad
  • [Deps] update es-abstract 4d9967e
  • [Dev Deps] update tape 749632c

v1.0.2 - 2019-12-13

Commits

  • [Tests] use shared travis-ci configs 0dbbf50
  • [actions] add automatic rebasing / merge commit blocking 82a587a
  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog, safe-publish-latest 61fdc06
  • [Deps] update es-abstract, has-symbols 2e1377f
  • [readme] remove testling bd843f6
  • [meta] add funding field 057b03f

v1.0.1 - 2019-10-18

Fixed

  • [Fix] polyfill: fix always-true logic #3

Commits

  • [Tests] up to node v12.12, v11.15, v10.16, v8.16, v6.17 66278dd
  • [Tests] up to node v10.4, v9.11, v8.11, v6.14, v4.9 8bdca03
  • [Refactor] use getSymbolDescription and getInferredName helpers from es-abstract d6b2c51
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape; add safe-publish-latest ea4841b
  • [meta] add auto-changelog 415dcaf
  • [Dev Deps] update eslint, nsp, tape 25d2c71
  • [Tests] use npx aud instead of nsp or npm audit with hoops 32f79e9

v1.0.0 - 2018-01-23

Merged

  • [Fix] use function name inference and computed properties to distinguish Symbol() from Symbol(‘’), when available #2

Fixed

  • [Fix] use function name inference and computed properties to distinguish Symbol() from Symbol(‘’), when available. #1

Commits

  • [Tests] add travis-ci and npm run security b889123
  • Implementation. 5bafd04
  • Tests 96aee94
  • Initial commit fff1a67
  • Read me 3d21280
  • [Tests] up to node v9.2, v8.9, v6.12; use nvm install-latest-npm; pin included builds to LTSr c6d1807
  • [Tests] add npm run lint 1e4562c
  • package.json 6d53036
  • [Fix] only shim global Symbol when needed 10f4fa2
  • Flesh out es-shim-api requirements. 6bf128a
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, eslint, nsp, tape 9651fb6
  • Rename and move the repo. e136d90
  • Only apps should have lockfiles. 74239df
  • [Dev Deps] update @es-shims/api, eslint e3c8d64