symbol.prototype.description
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -8,2 +8,23 @@ # Changelog | ||
## [v1.0.6](https://github.com/es-shims/Symbol.prototype.description/compare/v1.0.5...v1.0.6) - 2024-02-15 | ||
### Commits | ||
- [actions] reuse common workflows [`92fa371`](https://github.com/es-shims/Symbol.prototype.description/commit/92fa371012bfd0c69fb431113573dde36921aee9) | ||
- [Fix] behave properly in a pre-Symbol environment [`d61003b`](https://github.com/es-shims/Symbol.prototype.description/commit/d61003b2a3c9260d628104de5b31091de66e13a6) | ||
- [meta] use `npmignore` to autogenerate an npmignore file [`7ba5498`](https://github.com/es-shims/Symbol.prototype.description/commit/7ba5498eadb8dc26eeb8d7ca13a2cef3a56ebecf) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `safe-publish-latest`, `tape` [`b49e7eb`](https://github.com/es-shims/Symbol.prototype.description/commit/b49e7eb0d5767e0b687c62b80e92bd85d50607e7) | ||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `reflect.ownkeys`, `tape` [`e6351a6`](https://github.com/es-shims/Symbol.prototype.description/commit/e6351a6b69594cad20646011c4f2a1067a3012da) | ||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud` ,`npmignore`, `reflect.ownkeys`, `tape` [`409cc9b`](https://github.com/es-shims/Symbol.prototype.description/commit/409cc9b295520c354278277e449ec9561bf96380) | ||
- [actions] update rebase action to use reusable workflow [`5059d72`](https://github.com/es-shims/Symbol.prototype.description/commit/5059d72971cccba579cc3ee02482f074ab2a1d6f) | ||
- [actions] update codecov uploader [`1e98508`](https://github.com/es-shims/Symbol.prototype.description/commit/1e985080b8a111ab10e71caf12627c8c847cb6f5) | ||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `reflect.ownkeys`, `tape` [`67b55d3`](https://github.com/es-shims/Symbol.prototype.description/commit/67b55d3031bb039fc5a1a43d53c09dbf0f727bcd) | ||
- [Deps] update `call-bind`, `get-symbol-description`, `object.getownpropertydescriptors` [`19c078d`](https://github.com/es-shims/Symbol.prototype.description/commit/19c078dc5b6d83741573f44b03da748768be7e99) | ||
- [readme] add github actions/codecov badges [`79fa955`](https://github.com/es-shims/Symbol.prototype.description/commit/79fa9555018a2ddefcab18e86a0e1949ac997f68) | ||
- [Dev Deps] update `@ljharb/eslint-config`, `@es-shims/api`, `reflect.ownkeys` [`cd0fa9d`](https://github.com/es-shims/Symbol.prototype.description/commit/cd0fa9d850f7a1e2bb910e9c8023e2fef322a51c) | ||
- [Deps] update `has-symbol`, `object.getownpropertydescriptors` [`462aace`](https://github.com/es-shims/Symbol.prototype.description/commit/462aace317aabd057e03d4e3e366631bedecc7d2) | ||
- [actions] update workflows [`75f45ff`](https://github.com/es-shims/Symbol.prototype.description/commit/75f45ff6e47d7d294eee8cc202ff18bdfb2d9103) | ||
- [Deps] update `object.getownpropertydescriptors` [`643f896`](https://github.com/es-shims/Symbol.prototype.description/commit/643f896c7132be9e6172dac4888c9e75c1e969d0) | ||
- [Deps] update `object.getownpropertydescriptors` [`c6b9eba`](https://github.com/es-shims/Symbol.prototype.description/commit/c6b9eba1046acd35768cc7e65e0f193589629520) | ||
## [v1.0.5](https://github.com/es-shims/Symbol.prototype.description/compare/v1.0.4...v1.0.5) - 2021-08-17 | ||
@@ -10,0 +31,0 @@ |
'use strict'; | ||
var $TypeError = require('es-errors/type'); | ||
var getSymbolDescription = require('get-symbol-description'); | ||
module.exports = function description() { | ||
if (this == null) { // eslint-disable-line eqeqeq | ||
throw new $TypeError('`this` value must be object-coercible'); | ||
} | ||
return getSymbolDescription(this); | ||
}; |
{ | ||
"name": "symbol.prototype.description", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Spec-compliant shim for Symbol.prototype.description proposal.", | ||
@@ -8,7 +8,7 @@ "main": "index.js", | ||
"scripts": { | ||
"version": "auto-changelog && git add CHANGELOG.md", | ||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"", | ||
"prepack": "npmignore --auto --commentLines=autogenerated", | ||
"prepublish": "not-in-publish || npm run prepublishOnly", | ||
"prepublishOnly": "safe-publish-latest", | ||
"lint": "eslint .", | ||
"prelint": "evalmd README.md", | ||
"lint": "eslint --ext=js,mjs .", | ||
"postlint": "es-shim-api --bound --skip-shim-returns-polyfill", | ||
@@ -18,3 +18,5 @@ "tests-only": "nyc tape 'test/**/*.js'", | ||
"test": "npm run tests-only", | ||
"posttest": "npx aud --production" | ||
"posttest": "aud --production", | ||
"version": "auto-changelog && git add CHANGELOG.md", | ||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" | ||
}, | ||
@@ -44,21 +46,26 @@ "repository": { | ||
"dependencies": { | ||
"call-bind": "^1.0.2", | ||
"get-symbol-description": "^1.0.0", | ||
"has-symbols": "^1.0.2", | ||
"object.getownpropertydescriptors": "^2.1.2" | ||
"call-bind": "^1.0.7", | ||
"es-errors": "^1.3.0", | ||
"get-symbol-description": "^1.0.2", | ||
"has-symbols": "^1.0.3", | ||
"object.getownpropertydescriptors": "^2.1.7" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^17.6.0", | ||
"aud": "^1.1.5", | ||
"auto-changelog": "^2.3.0", | ||
"eslint": "^7.32.0", | ||
"@es-shims/api": "^2.4.2", | ||
"@ljharb/eslint-config": "^21.1.0", | ||
"aud": "^2.0.4", | ||
"auto-changelog": "^2.4.0", | ||
"eslint": "=8.8.0", | ||
"evalmd": "^0.0.19", | ||
"has-strict-mode": "^1.0.1", | ||
"hasown": "^2.0.1", | ||
"in-publish": "^2.0.1", | ||
"npmignore": "^0.3.1", | ||
"nyc": "^10.3.2", | ||
"reflect.ownkeys": "^1.0.2", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.3.1" | ||
"reflect.ownkeys": "^1.1.4", | ||
"safe-publish-latest": "^2.0.0", | ||
"tape": "^5.7.5" | ||
}, | ||
"engines": { | ||
"node": ">= 0.11.15" | ||
"node": ">= 0.4" | ||
}, | ||
@@ -72,3 +79,8 @@ "auto-changelog": { | ||
"hideCredit": true | ||
}, | ||
"publishConfig": { | ||
"ignore": [ | ||
".github/workflows" | ||
] | ||
} | ||
} |
@@ -10,3 +10,3 @@ 'use strict'; | ||
if (!hasSymbols || typeof gOPD !== 'function') { | ||
return null; | ||
return implementation; | ||
} | ||
@@ -13,0 +13,0 @@ |
# Symbol.prototype.description <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
[![dependency status][deps-svg]][deps-url] | ||
[![dev dependency status][dev-deps-svg]][dev-deps-url] | ||
[![github actions][actions-image]][actions-url] | ||
[![coverage][codecov-image]][codecov-url] | ||
[![License][license-image]][license-url] | ||
@@ -11,5 +11,5 @@ [![Downloads][downloads-image]][downloads-url] | ||
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. | ||
*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](https://github.com/es-shims/api) interface. It works in an ES6-supported environment and complies with the [spec](https://github.com/michaelficarra/Symbol-description-proposal/). | ||
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES6-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-symbol.prototype.description). | ||
@@ -19,2 +19,3 @@ Most common usage: | ||
var description = require('symbol.prototype.description'); | ||
var assert = require('assert'); | ||
@@ -26,8 +27,8 @@ assert(description(Symbol('foo')) === 'foo'); | ||
// 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 (!('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); | ||
if (!Symbol.prototype.description) { | ||
description.shim(); | ||
@@ -58,1 +59,5 @@ } | ||
[downloads-url]: https://npm-stat.com/charts.html?package=symbol.prototype.description | ||
[codecov-image]: https://codecov.io/gh/es-shims/Symbol.prototype.description/branch/main/graphs/badge.svg | ||
[codecov-url]: https://app.codecov.io/gh/es-shims/Symbol.prototype.description/ | ||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Symbol.prototype.description | ||
[actions-url]: https://github.com/es-shims/Symbol.prototype.description/actions |
@@ -12,4 +12,4 @@ 'use strict'; | ||
/* eslint no-useless-call: 0 */ | ||
st.throws(function () { implementation.call(undefined); }, TypeError, 'undefined is not an object'); | ||
st.throws(function () { implementation.call(null); }, TypeError, 'null is not an object'); | ||
st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object'); | ||
st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object'); | ||
st.end(); | ||
@@ -16,0 +16,0 @@ }); |
'use strict'; | ||
var hasSymbols = require('has-symbols')(); | ||
var test = require('tape'); | ||
@@ -10,10 +9,5 @@ | ||
test('as a function', function (t) { | ||
if (!hasSymbols) { | ||
t.fail('Symbols not supported in this environment'); | ||
return t.end(); | ||
} | ||
t.test('bad array/this value', function (st) { | ||
st.throws(function () { description(undefined); }, TypeError, 'undefined is not an object'); | ||
st.throws(function () { description(null); }, TypeError, 'null is not an object'); | ||
st['throws'](function () { description(undefined); }, TypeError, 'undefined is not an object'); | ||
st['throws'](function () { description(null); }, TypeError, 'null is not an object'); | ||
st.end(); | ||
@@ -20,0 +14,0 @@ }); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var has = require('has'); | ||
var hasOwn = require('hasown'); | ||
var keys = require('reflect.ownkeys'); | ||
@@ -18,3 +18,3 @@ var hasSymbols = require('has-symbols')(); | ||
if (!hasSymbols) { | ||
t.fail('Symbols not supported in this environment'); | ||
t.comment('Symbols not supported in this environment'); | ||
return t.end(); | ||
@@ -44,3 +44,3 @@ } | ||
if (p !== 'length' && p !== 'arguments' && p !== 'caller' && p !== 'callee') { | ||
st.ok(has(Symbol, p), 'has own property: ' + p); | ||
st.ok(hasOwn(Symbol, p), 'has own property: ' + p); | ||
} | ||
@@ -54,4 +54,4 @@ } | ||
t.test('bad object value', { skip: !supportsStrictMode }, function (st) { | ||
st.throws(function () { return Object.values(undefined); }, TypeError, 'undefined is not an object'); | ||
st.throws(function () { return Object.values(null); }, TypeError, 'null is not an object'); | ||
st['throws'](function () { return Object.values(undefined); }, TypeError, 'undefined is not an object'); | ||
st['throws'](function () { return Object.values(null); }, TypeError, 'null is not an object'); | ||
st.end(); | ||
@@ -58,0 +58,0 @@ }); |
@@ -7,2 +7,12 @@ 'use strict'; | ||
module.exports = function (description, t) { | ||
t.test('Symbols not supported', { skip: hasSymbols }, function (st) { | ||
st['throws']( | ||
function () { description('foo'); }, | ||
SyntaxError, | ||
'throws when Symbols not supported' | ||
); | ||
st.end(); | ||
}); | ||
t.test('Symbol description', { skip: !hasSymbols }, function (st) { | ||
@@ -9,0 +19,0 @@ st.equal(description(Symbol()), undefined, 'Symbol() description is undefined'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29496
214
60
5
14
17
+ Addedes-errors@^1.3.0
Updatedcall-bind@^1.0.7
Updatedhas-symbols@^1.0.3