Save current BZZZ config-ui state before CHORUS branding update

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-08-19 00:19:00 +10:00
parent 6a6a49b7b1
commit c177363a19
16410 changed files with 1789161 additions and 230 deletions

View File

@@ -0,0 +1,20 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 150
[CHANGELOG.md]
indent_style = space
indent_size = 2
[*.json]
max_line_length = off
[Makefile]
max_line_length = off

View File

@@ -0,0 +1 @@
coverage/

View File

@@ -0,0 +1,20 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 24, "properties": "never" }],
"new-cap": [2, { "capIsNewExceptions": ["GetMethod"] }]
},
"overrides": [
{
"files": "test/**",
"rules": {
"max-lines-per-function": 0,
},
}
],
}

View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/es-to-primitive
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -0,0 +1,9 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}

View File

@@ -0,0 +1,101 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.3.0](https://github.com/ljharb/es-to-primitive/compare/v1.2.1...v1.3.0) - 2024-11-26
### Commits
- [actions] reuse common workflows [`bb72efc`](https://github.com/ljharb/es-to-primitive/commit/bb72efc7e04ae11b84e4aecf120a4e9063e34428)
- [Tests] use `es-value-fixtures` [`a912f7b`](https://github.com/ljharb/es-to-primitive/commit/a912f7b675333735c1c980cda88772ac1870395b)
- [Tests] migrate tests to Github Actions [`510baf0`](https://github.com/ljharb/es-to-primitive/commit/510baf092633a62d59866fbf56836ce42c717c70)
- [New] add types [`69ba1fd`](https://github.com/ljharb/es-to-primitive/commit/69ba1fdcac834b03698739990ba98fe6007024dc)
- [meta] remove unused Makefile [`4ea66e6`](https://github.com/ljharb/es-to-primitive/commit/4ea66e62ef4afa0102eb8335ba3e003e8332f664)
- [actions] use `node/install` instead of `node/run`; use `codecov` action [`3c31937`](https://github.com/ljharb/es-to-primitive/commit/3c31937119ca24fd6d00e362d6435a28cfe9e91c)
- [meta] do not publish github action workflow files [`389567e`](https://github.com/ljharb/es-to-primitive/commit/389567e8523b65b90b529f1029d215fd4f12ac14)
- [meta] use `npmignore` to autogenerate an npmignore file [`9f3aa76`](https://github.com/ljharb/es-to-primitive/commit/9f3aa7651791ab9386408035491a1ba4fec4c432)
- [actions] split out node 10-20, and 20+ [`c60d7d8`](https://github.com/ljharb/es-to-primitive/commit/c60d7d822a36880bce0535335c70fdc2a8da232d)
- [Tests] run `nyc` on all tests; use `tape` runner [`29cbb89`](https://github.com/ljharb/es-to-primitive/commit/29cbb89800b5cfef9bef3ae7e0e779c782e1bbb9)
- [meta] add `auto-changelog` [`ea744b2`](https://github.com/ljharb/es-to-primitive/commit/ea744b2a0bda788b0d957c1787e41434e98b0155)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `function.prototype.name`, `has-symbols`, `object-inspect`, `object-is`, `tape` [`e5c3c79`](https://github.com/ljharb/es-to-primitive/commit/e5c3c792f67685a9647e817e7582d4c76a876f69)
- [actions] add automatic rebasing / merge commit blocking [`a5a6f00`](https://github.com/ljharb/es-to-primitive/commit/a5a6f0066540c91c8aa45a4921f1cd2349f435ba)
- [Dev Deps] update `@ljharb/eslint-config`, `es-value-fixtures`, `function.prototype.name`, `npmignore`, `object-inspect`, `object-is`, `tape` [`7941fd5`](https://github.com/ljharb/es-to-primitive/commit/7941fd530fb3a73f923b76c739335ffc21793ad6)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `es-value-fixtures`, `foreach`, `object-inspect`, `tape` [`eb1c79c`](https://github.com/ljharb/es-to-primitive/commit/eb1c79c288c89154014634b94f64308344901eaf)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `function.prototype.name`, `object-inspect`, `safe-publish-latest`, `tape` [`249b42f`](https://github.com/ljharb/es-to-primitive/commit/249b42f1ce069ea78a032f10414d1c1c0b6c6345)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `function.prototype.name`, `object-inspect`, `object-is`, `tape` [`d57d5e9`](https://github.com/ljharb/es-to-primitive/commit/d57d5e9ea5ea4778f383e2f1aa637be0be80dd78)
- [actions] update codecov uploader [`003b62c`](https://github.com/ljharb/es-to-primitive/commit/003b62c483372d5eac38f51925b6cbdf5d7a0665)
- [actions] add "Allow Edits" workflow [`75ee990`](https://github.com/ljharb/es-to-primitive/commit/75ee99083626dc14558ae294c127e4aaf925d214)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `object-is`; add `safe-publish-latest` [`ba5da7b`](https://github.com/ljharb/es-to-primitive/commit/ba5da7bffd93c3cc2e079ad751a3e678333a973e)
- [readme] remove travis badge [`6f7aec7`](https://github.com/ljharb/es-to-primitive/commit/6f7aec78e4f1ebfca74c384a837063f4099e7b9b)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`3291fd5`](https://github.com/ljharb/es-to-primitive/commit/3291fd567695b45bddc58e5ec3da2dcce0e5ccc7)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `function.prototype.name`, `has-symbols`, `object-inspect` [`53007f2`](https://github.com/ljharb/es-to-primitive/commit/53007f25d1f26e301b4f41d070c423723bed1690)
- [actions] update checkout action [`69640db`](https://github.com/ljharb/es-to-primitive/commit/69640dbb9ddafe05527388fe72bda1aca08d07b5)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-is`, `tape`; add `aud` [`c9d644e`](https://github.com/ljharb/es-to-primitive/commit/c9d644ef3c6b2210e86ce2d3aa8e8b1668f6801d)
- [Tests] use `for-each` instead of `foreach` [`e9117bb`](https://github.com/ljharb/es-to-primitive/commit/e9117bb055417cb721dbf5dbe1d23b058a8241f2)
- [readme] add github actions/codecov badges [`53cd375`](https://github.com/ljharb/es-to-primitive/commit/53cd375ab22a25d4bada35000473e30c22ee2028)
- [Deps] update `is-callable`, `is-date-object`, `is-symbol` [`8116c68`](https://github.com/ljharb/es-to-primitive/commit/8116c68a8ba555f8daaf1d71a60c974d3439c94b)
- [Tests] fix test skipping for `Symbol.toPrimitive` [`e6268ef`](https://github.com/ljharb/es-to-primitive/commit/e6268ef31b34cb5263501ba9735ccce78a07e504)
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`da41c40`](https://github.com/ljharb/es-to-primitive/commit/da41c40399c2a574f74a59b85800d9934b91d49a)
- [Deps] update `is-callable`, `is-date-object` [`96fe13f`](https://github.com/ljharb/es-to-primitive/commit/96fe13ff3c486c7857c2ca69ac70161ef0e5b4a1)
- [Tests] replace `aud` with `npm audit` [`0b53154`](https://github.com/ljharb/es-to-primitive/commit/0b531546081427cb8a4fc06fde5540ba0b287b5b)
- [meta] use `prepublishOnly` script for npm 7+ [`9d7d485`](https://github.com/ljharb/es-to-primitive/commit/9d7d4856d4b5f28c68de2aba068522b9a85ee669)
- [Deps] update `is-callable` [`3c990b6`](https://github.com/ljharb/es-to-primitive/commit/3c990b646813e2470b19460e32801113f9acc13b)
- [Deps] update `is-callable` [`9bcfff2`](https://github.com/ljharb/es-to-primitive/commit/9bcfff276ce078034404b6b27e4f74beb530002c)
- [Deps] update `is-callable` [`1eb5478`](https://github.com/ljharb/es-to-primitive/commit/1eb5478e0c93b230b7bc67f9fef963d94a391117)
- [meta] only run `aud` on prod deps [`1fcd896`](https://github.com/ljharb/es-to-primitive/commit/1fcd89684a4351c15fec2cb289ecc331f917b80e)
- [Deps] update `is-symbol` [`7174a47`](https://github.com/ljharb/es-to-primitive/commit/7174a474f4f9f07319c81f046b10446caf9b3af0)
<!-- auto-changelog-above -->
1.2.1 / 2019-11-08
=================
* [readme] remove testling URLs
* [meta] add `funding` field
* [meta] create FUNDING.yml
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `covert`, `replace`, `semver`, `tape`, `function.prototype.name`
* [Tests] use shared travis-ci configs
* [Tests] Add es5 tests for `symbol` types (#45)
* [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops
* [Tests] remove `jscs`
1.2.0 / 2018-09-27
=================
* [New] create ES2015 entry point/property, to replace ES6
* [Fix] Ensure optional arguments are not part of the length (#29)
* [Deps] update `is-callable`
* [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`, `object-inspect`, `replace`
* [Tests] avoid util.inspect bug with `new Date(NaN)` on node v6.0 and v6.1.
* [Tests] up to `node` `v10.11`, `v9.11`, `v8.12`, `v6.14`, `v4.9`
1.1.1 / 2016-01-03
=================
* [Fix: ES5] fix coercion logic: ES5s ToPrimitive does not coerce any primitive value, regardless of hint (#2)
1.1.0 / 2015-12-27
=================
* [New] add `Symbol.toPrimitive` support
* [Deps] update `is-callable`, `is-date-object`
* [Dev Deps] update `eslint`, `tape`, `semver`, `jscs`, `covert`, `nsp`, `@ljharb/eslint-config`
* [Dev Deps] remove unused deps
* [Tests] up to `node` `v5.3`
* [Tests] fix npm upgrades on older node versions
* [Tests] fix testling
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
1.0.1 / 2016-01-03
=================
* [Fix: ES5] fix coercion logic: ES5s ToPrimitive does not coerce any primitive value, regardless of hint (#2)
* [Deps] update `is-callable`, `is-date-object`
* [Dev Deps] update `eslint`, `tape`, `semver`, `jscs`, `covert`, `nsp`, `@ljharb/eslint-config`
* [Dev Deps] remove unused deps
* [Tests] up to `node` `v5.3`
* [Tests] fix npm upgrades on older node versions
* [Tests] fix testling
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
1.0.0 / 2015-03-19
=================
* Initial release.

22
install/config-ui/node_modules/es-to-primitive/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Jordan Harband
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,52 @@
# es-to-primitive <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.
When different versions of the spec conflict, the default export will be the latest version of the abstract operation.
Alternative versions will also be available under an `es5`/`es2015` exported property if you require a specific version.
## Example
```js
var toPrimitive = require('es-to-primitive');
var assert = require('assert');
assert(toPrimitive(function () {}) === String(function () {}));
var date = new Date();
assert(toPrimitive(date) === String(date));
assert(toPrimitive({ valueOf: function () { return 3; } }) === 3);
assert(toPrimitive(['a', 'b', 3]) === String(['a', 'b', 3]));
var sym = Symbol();
assert(toPrimitive(Object(sym)) === sym);
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/es-to-primitive
[npm-version-svg]: https://versionbadg.es/ljharb/es-to-primitive.svg
[deps-svg]: https://david-dm.org/ljharb/es-to-primitive.svg
[deps-url]: https://david-dm.org/ljharb/es-to-primitive
[dev-deps-svg]: https://david-dm.org/ljharb/es-to-primitive/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/es-to-primitive#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/es-to-primitive.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/es-to-primitive.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/es-to-primitive.svg
[downloads-url]: https://npm-stat.com/charts.html?package=es-to-primitive
[codecov-image]: https://codecov.io/gh/ljharb/es-to-primitive/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/es-to-primitive/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/es-to-primitive
[actions-url]: https://github.com/ljharb/es-to-primitive/actions

View File

@@ -0,0 +1,5 @@
type primitive = null | undefined | string | symbol | number | boolean | bigint;
declare function ToPrimitive(input: unknown, hint?: StringConstructor | NumberConstructor): primitive;
export = ToPrimitive;

View File

@@ -0,0 +1,82 @@
'use strict';
var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
var isPrimitive = require('./helpers/isPrimitive');
var isCallable = require('is-callable');
var isDate = require('is-date-object');
var isSymbol = require('is-symbol');
/** @type {(O: { valueOf?: () => unknown, toString?: () => unknown }, hint: 'number' | 'string' | 'default') => null | undefined | string | symbol | number | boolean | bigint} */
var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) {
if (typeof O === 'undefined' || O === null) {
throw new TypeError('Cannot call method on ' + O);
}
if (typeof hint !== 'string' || (hint !== 'number' && hint !== 'string')) {
throw new TypeError('hint must be "string" or "number"');
}
/** @type {('toString' | 'valueOf')[]} */
var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var method, result, i;
for (i = 0; i < methodNames.length; ++i) {
method = O[methodNames[i]];
if (isCallable(method)) {
result = method.call(O);
if (isPrimitive(result)) {
return result;
}
}
}
throw new TypeError('No default value');
};
/** @type {<K extends PropertyKey>(O: Record<K, unknown>, P: K) => Function | undefined} */
var GetMethod = function GetMethod(O, P) {
var func = O[P];
if (func !== null && typeof func !== 'undefined') {
if (!isCallable(func)) {
throw new TypeError(func + ' returned for property ' + String(P) + ' of object ' + O + ' is not a function');
}
return func;
}
return void 0;
};
/** @type {import('./es2015')} */
// http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive
module.exports = function ToPrimitive(input) {
if (isPrimitive(input)) {
return input;
}
/** @type {'default' | 'string' | 'number'} */
var hint = 'default';
if (arguments.length > 1) {
if (arguments[1] === String) {
hint = 'string';
} else if (arguments[1] === Number) {
hint = 'number';
}
}
var exoticToPrim;
if (hasSymbols) {
if (Symbol.toPrimitive) {
// eslint-disable-next-line no-extra-parens
exoticToPrim = GetMethod(/** @type {Record<PropertyKey, unknown>} */ (input), Symbol.toPrimitive);
} else if (isSymbol(input)) {
exoticToPrim = Symbol.prototype.valueOf;
}
}
if (typeof exoticToPrim !== 'undefined') {
var result = exoticToPrim.call(input, hint);
if (isPrimitive(result)) {
return result;
}
throw new TypeError('unable to convert exotic object to primitive');
}
if (hint === 'default' && (isDate(input) || isSymbol(input))) {
hint = 'string';
}
// eslint-disable-next-line no-extra-parens
return ordinaryToPrimitive(/** @type {object} */ (input), hint === 'default' ? 'number' : hint);
};

View File

@@ -0,0 +1,3 @@
declare function ToPrimitive(input: unknown, hint?: StringConstructor | NumberConstructor): null | undefined | string | symbol | number | boolean | bigint;
export = ToPrimitive;

52
install/config-ui/node_modules/es-to-primitive/es5.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
'use strict';
var toStr = Object.prototype.toString;
var isPrimitive = require('./helpers/isPrimitive');
var isCallable = require('is-callable');
/** @type {{ [k in `[[${string}]]`]: (O: { toString?: unknown, valueOf?: unknown }, actualHint?: StringConstructor | NumberConstructor) => null | undefined | string | symbol | number | boolean | bigint; }} */
// http://ecma-international.org/ecma-262/5.1/#sec-8.12.8
var ES5internalSlots = {
'[[DefaultValue]]': function (O) {
var actualHint;
if (arguments.length > 1) {
actualHint = arguments[1];
} else {
actualHint = toStr.call(O) === '[object Date]' ? String : Number;
}
if (actualHint === String || actualHint === Number) {
/** @type {('toString' | 'valueOf')[]} */
var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString'];
var value, i;
for (i = 0; i < methods.length; ++i) {
var method = methods[i];
if (isCallable(O[method])) {
// eslint-disable-next-line no-extra-parens
value = /** @type {Function} */ (O[method])();
if (isPrimitive(value)) {
return value;
}
}
}
throw new TypeError('No default value');
}
throw new TypeError('invalid [[DefaultValue]] hint supplied');
}
};
/** @type {import('./es5')} */
// http://ecma-international.org/ecma-262/5.1/#sec-9.1
module.exports = function ToPrimitive(input) {
if (isPrimitive(input)) {
return input;
}
if (arguments.length > 1) {
// eslint-disable-next-line no-extra-parens
return ES5internalSlots['[[DefaultValue]]'](/** @type {object} */ (input), arguments[1]);
}
// eslint-disable-next-line no-extra-parens
return ES5internalSlots['[[DefaultValue]]'](/** @type {object} */ (input));
};

View File

@@ -0,0 +1,3 @@
import ES2015 from './es2015';
export = ES2015;

View File

@@ -0,0 +1,4 @@
'use strict';
/** @type {import('./es2015')} */
module.exports = require('./es2015');

View File

@@ -0,0 +1,6 @@
'use strict';
/** @type {(value: unknown) => value is null | undefined | string | symbol | number | boolean | bigint} */
module.exports = function isPrimitive(value) {
return value === null || (typeof value !== 'function' && typeof value !== 'object');
};

View File

@@ -0,0 +1,11 @@
import ES5 from './es5';
import ES6 from './es6';
import ES2015 from './es2015';
declare const ToPrimitive: typeof ES2015 & {
readonly ES5: typeof ES5;
/** @deprecated */
readonly ES6: typeof ES6;
readonly ES2015: typeof ES2015;
};
export = ToPrimitive;

View File

@@ -0,0 +1,21 @@
'use strict';
var ES5 = require('./es5');
var ES6 = require('./es6');
var ES2015 = require('./es2015');
if (Object.defineProperty) {
Object.defineProperty(ES2015, 'ES5', { enumerable: false, value: ES5 });
Object.defineProperty(ES2015, 'ES6', { enumerable: false, value: ES6 });
Object.defineProperty(ES2015, 'ES2015', { enumerable: false, value: ES2015 });
} else {
// @ts-expect-error TODO
ES2015.ES5 = ES5;
// @ts-expect-error TODO
ES2015.ES6 = ES6;
// @ts-expect-error TODO
ES2015.ES2015 = ES2015;
}
/** @type {import('.')} */
module.exports = ES2015;

View File

@@ -0,0 +1,97 @@
{
"name": "es-to-primitive",
"version": "1.3.0",
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"description": "ECMAScript “ToPrimitive” algorithm. Provides ES5 and ES2015 versions.",
"license": "MIT",
"main": "index.js",
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "npx npm@'>=10.2' audit --production",
"tests-only": "nyc tape 'test/**/*.js'",
"lint": "eslint --ext=js,mjs .",
"postlint": "tsc && attw -P",
"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)\")\""
},
"repository": {
"type": "git",
"url": "git://github.com/ljharb/es-to-primitive.git"
},
"keywords": [
"primitive",
"abstract",
"ecmascript",
"es5",
"es6",
"es2015",
"toPrimitive",
"coerce",
"type",
"object",
"string",
"number",
"boolean",
"symbol",
"null",
"undefined"
],
"dependencies": {
"is-callable": "^1.2.7",
"is-date-object": "^1.0.5",
"is-symbol": "^1.0.4"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.0",
"@ljharb/eslint-config": "^21.1.1",
"@ljharb/tsconfig": "^0.2.0",
"@types/for-each": "^0.3.3",
"@types/function.prototype.name": "^1.1.3",
"@types/is-callable": "^1.1.2",
"@types/is-date-object": "^1.0.4",
"@types/is-symbol": "^1.0.2",
"@types/object-inspect": "^1.13.0",
"@types/object-is": "^1.1.0",
"@types/tape": "^5.6.4",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"es-value-fixtures": "^1.5.0",
"eslint": "=8.8.0",
"for-each": "^0.3.3",
"function.prototype.name": "^1.1.6",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.3",
"object-is": "^1.1.6",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0",
"typescript": "next"
},
"testling": {
"files": "test/index.js"
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true,
"startingVersion": "1.2.2"
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}

View File

@@ -0,0 +1,140 @@
'use strict';
var test = require('tape');
var toPrimitive = require('../es2015');
var is = require('object-is');
var forEach = require('for-each');
var functionName = require('function.prototype.name');
var debug = require('object-inspect');
var v = require('es-value-fixtures');
/** @typedef {{ toString?: unknown, valueOf?: unknown, [Symbol.toPrimitive]?: unknown }} Coercible */
test('function properties', function (t) {
t.equal(toPrimitive.length, 1, 'length is 1');
t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive');
t.end();
});
test('primitives', function (t) {
forEach(v.primitives, function (i) {
t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value');
t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value');
t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value');
});
t.end();
});
test('Symbols', { skip: !v.hasSymbols }, function (t) {
forEach(v.symbols, function (sym) {
t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value');
t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value');
t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value');
});
var primitiveSym = Symbol('primitiveSym');
var objectSym = Object(primitiveSym);
t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym));
t.equal(toPrimitive(objectSym, String), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(primitiveSym));
t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym));
t.end();
});
test('Arrays', function (t) {
var arrays = [[], ['a', 'b'], [1, 2]];
forEach(arrays, function (arr) {
t.equal(toPrimitive(arr), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
t.equal(toPrimitive(arr, Number), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
});
t.end();
});
test('Dates', function (t) {
var dates = [new Date(), new Date(0), new Date(NaN)];
forEach(dates, function (date) {
t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date');
t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date');
t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date');
});
t.end();
});
test('Objects', function (t) {
t.equal(toPrimitive(v.coercibleObject), v.coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf');
t.equal(toPrimitive(v.coercibleObject, Number), v.coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf');
t.equal(toPrimitive(v.coercibleObject, String), v.coercibleObject.toString(), 'coercibleObject with hint String coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject), v.coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject, Number), v.coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject, String), v.coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to non-stringified toString');
t.equal(toPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString');
t.equal(toPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString');
t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString');
t.equal(toPrimitive(v.toStringOnlyObject), v.toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString');
t.equal(toPrimitive(v.toStringOnlyObject, Number), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString');
t.equal(toPrimitive(v.toStringOnlyObject, String), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns non-stringified toString');
t.equal(toPrimitive(v.valueOfOnlyObject), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, Number), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, String), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns non-stringified valueOf');
t.test('Symbol.toPrimitive', { skip: !v.hasSymbols || !Symbol.toPrimitive }, function (st) {
/** @type {Coercible} */
var overriddenObject = { toString: st.fail, valueOf: st.fail };
overriddenObject[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
return String(hint);
};
st.equal(toPrimitive(overriddenObject), 'default', 'object with Symbol.toPrimitive + no hint invokes that');
st.equal(toPrimitive(overriddenObject, Number), 'number', 'object with Symbol.toPrimitive + hint Number invokes that');
st.equal(toPrimitive(overriddenObject, String), 'string', 'object with Symbol.toPrimitive + hint String invokes that');
/** @type {Coercible} */
var nullToPrimitive = { toString: v.coercibleObject.toString, valueOf: v.coercibleObject.valueOf };
nullToPrimitive[Symbol.toPrimitive] = null;
st.equal(toPrimitive(nullToPrimitive), toPrimitive(v.coercibleObject), 'object with no hint + null Symbol.toPrimitive ignores it');
st.equal(toPrimitive(nullToPrimitive, Number), toPrimitive(v.coercibleObject, Number), 'object with hint Number + null Symbol.toPrimitive ignores it');
st.equal(toPrimitive(nullToPrimitive, String), toPrimitive(v.coercibleObject, String), 'object with hint String + null Symbol.toPrimitive ignores it');
st.test('exceptions', function (sst) {
/** @type {Coercible} */
var nonFunctionToPrimitive = { toString: sst.fail, valueOf: sst.fail };
nonFunctionToPrimitive[Symbol.toPrimitive] = {};
sst['throws'](toPrimitive.bind(null, nonFunctionToPrimitive), TypeError, 'Symbol.toPrimitive returning a non-function throws');
/** @type {Coercible} */
var uncoercibleToPrimitive = { toString: sst.fail, valueOf: sst.fail };
uncoercibleToPrimitive[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
return { toString: function () { return hint; } };
};
sst['throws'](toPrimitive.bind(null, uncoercibleToPrimitive), TypeError, 'Symbol.toPrimitive returning an object throws');
/** @type {Coercible} */
var throwingToPrimitive = { toString: sst.fail, valueOf: sst.fail };
throwingToPrimitive[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
throw new RangeError(hint);
};
sst['throws'](toPrimitive.bind(null, throwingToPrimitive), RangeError, 'Symbol.toPrimitive throwing throws');
sst.end();
});
st.end();
});
t.test('exceptions', function (st) {
st['throws'](toPrimitive.bind(null, v.uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError');
st.end();
});
t.end();
});

View File

@@ -0,0 +1,98 @@
'use strict';
var test = require('tape');
var toPrimitive = require('../es5');
var is = require('object-is');
var forEach = require('for-each');
var functionName = require('function.prototype.name');
var debug = require('object-inspect');
var v = require('es-value-fixtures');
test('function properties', function (t) {
t.equal(toPrimitive.length, 1, 'length is 1');
t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive');
t.end();
});
test('primitives', function (t) {
forEach(v.primitives, function (i) {
t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value');
t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value');
t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value');
});
t.end();
});
test('Symbols', { skip: !v.hasSymbols }, function (t) {
forEach(v.symbols, function (sym) {
t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value');
t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value');
t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value');
});
var primitiveSym = Symbol('primitiveSym');
var stringSym = Symbol.prototype.toString.call(primitiveSym);
var objectSym = Object(primitiveSym);
t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym));
// This is different from ES2015, as the ES5 algorithm doesn't account for the existence of Symbols:
t.equal(toPrimitive(objectSym, String), stringSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(stringSym));
t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym));
t.end();
});
test('Arrays', function (t) {
var arrays = [[], ['a', 'b'], [1, 2]];
forEach(arrays, function (arr) {
t.ok(is(toPrimitive(arr), arr.toString()), 'toPrimitive(' + debug(arr) + ') returns toString of the array');
t.equal(toPrimitive(arr, String), arr.toString(), 'toPrimitive(' + debug(arr) + ') returns toString of the array');
t.ok(is(toPrimitive(arr, Number), arr.toString()), 'toPrimitive(' + debug(arr) + ') returns toString of the array');
});
t.end();
});
test('Dates', function (t) {
var dates = [new Date(), new Date(0), new Date(NaN)];
forEach(dates, function (date) {
t.equal(toPrimitive(date), date.toString(), 'toPrimitive(' + debug(date) + ') returns toString of the date');
t.equal(toPrimitive(date, String), date.toString(), 'toPrimitive(' + debug(date) + ') returns toString of the date');
t.ok(is(toPrimitive(date, Number), date.valueOf()), 'toPrimitive(' + debug(date) + ') returns valueOf of the date');
});
t.end();
});
test('Objects', function (t) {
t.equal(toPrimitive(v.coercibleObject), v.coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf');
t.equal(toPrimitive(v.coercibleObject, String), v.coercibleObject.toString(), 'coercibleObject with hint String coerces to toString');
t.equal(toPrimitive(v.coercibleObject, Number), v.coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf');
t.equal(toPrimitive(v.coercibleFnObject), v.coercibleFnObject.toString(), 'coercibleFnObject coerces to toString');
t.equal(toPrimitive(v.coercibleFnObject, String), v.coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to toString');
t.equal(toPrimitive(v.coercibleFnObject, Number), v.coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to toString');
t.ok(is(toPrimitive({}), '[object Object]'), '{} with no hint coerces to Object#toString');
t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString');
t.ok(is(toPrimitive({}, Number), '[object Object]'), '{} with hint Number coerces to Object#toString');
t.equal(toPrimitive(v.toStringOnlyObject), v.toStringOnlyObject.toString(), 'toStringOnlyObject returns toString');
t.equal(toPrimitive(v.toStringOnlyObject, String), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns toString');
t.equal(toPrimitive(v.toStringOnlyObject, Number), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns toString');
t.equal(toPrimitive(v.valueOfOnlyObject), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, String), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, Number), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf');
t.test('exceptions', function (st) {
st['throws'](toPrimitive.bind(null, v.uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError');
st.end();
});
t.end();
});

View File

@@ -0,0 +1,140 @@
'use strict';
var test = require('tape');
var toPrimitive = require('../es6');
var is = require('object-is');
var forEach = require('for-each');
var functionName = require('function.prototype.name');
var debug = require('object-inspect');
var v = require('es-value-fixtures');
/** @typedef {{ toString?: unknown, valueOf?: unknown, [Symbol.toPrimitive]?: unknown }} Coercible */
test('function properties', function (t) {
t.equal(toPrimitive.length, 1, 'length is 1');
t.equal(functionName(toPrimitive), 'ToPrimitive', 'name is ToPrimitive');
t.end();
});
test('primitives', function (t) {
forEach(v.primitives, function (i) {
t.ok(is(toPrimitive(i), i), 'toPrimitive(' + debug(i) + ') returns the same value');
t.ok(is(toPrimitive(i, String), i), 'toPrimitive(' + debug(i) + ', String) returns the same value');
t.ok(is(toPrimitive(i, Number), i), 'toPrimitive(' + debug(i) + ', Number) returns the same value');
});
t.end();
});
test('Symbols', { skip: !v.hasSymbols }, function (t) {
forEach(v.symbols, function (sym) {
t.equal(toPrimitive(sym), sym, 'toPrimitive(' + debug(sym) + ') returns the same value');
t.equal(toPrimitive(sym, String), sym, 'toPrimitive(' + debug(sym) + ', String) returns the same value');
t.equal(toPrimitive(sym, Number), sym, 'toPrimitive(' + debug(sym) + ', Number) returns the same value');
});
var primitiveSym = Symbol('primitiveSym');
var objectSym = Object(primitiveSym);
t.equal(toPrimitive(objectSym), primitiveSym, 'toPrimitive(' + debug(objectSym) + ') returns ' + debug(primitiveSym));
t.equal(toPrimitive(objectSym, String), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', String) returns ' + debug(primitiveSym));
t.equal(toPrimitive(objectSym, Number), primitiveSym, 'toPrimitive(' + debug(objectSym) + ', Number) returns ' + debug(primitiveSym));
t.end();
});
test('Arrays', function (t) {
var arrays = [[], ['a', 'b'], [1, 2]];
forEach(arrays, function (arr) {
t.equal(toPrimitive(arr), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
t.equal(toPrimitive(arr, String), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
t.equal(toPrimitive(arr, Number), String(arr), 'toPrimitive(' + debug(arr) + ') returns the string version of the array');
});
t.end();
});
test('Dates', function (t) {
var dates = [new Date(), new Date(0), new Date(NaN)];
forEach(dates, function (date) {
t.equal(toPrimitive(date), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date');
t.equal(toPrimitive(date, String), String(date), 'toPrimitive(' + debug(date) + ') returns the string version of the date');
t.ok(is(toPrimitive(date, Number), Number(date)), 'toPrimitive(' + debug(date) + ') returns the number version of the date');
});
t.end();
});
test('Objects', function (t) {
t.equal(toPrimitive(v.coercibleObject), v.coercibleObject.valueOf(), 'coercibleObject with no hint coerces to valueOf');
t.equal(toPrimitive(v.coercibleObject, Number), v.coercibleObject.valueOf(), 'coercibleObject with hint Number coerces to valueOf');
t.equal(toPrimitive(v.coercibleObject, String), v.coercibleObject.toString(), 'coercibleObject with hint String coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject), v.coercibleFnObject.toString(), 'coercibleFnObject coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject, Number), v.coercibleFnObject.toString(), 'coercibleFnObject with hint Number coerces to non-stringified toString');
t.equal(toPrimitive(v.coercibleFnObject, String), v.coercibleFnObject.toString(), 'coercibleFnObject with hint String coerces to non-stringified toString');
t.equal(toPrimitive({}), '[object Object]', '{} with no hint coerces to Object#toString');
t.equal(toPrimitive({}, Number), '[object Object]', '{} with hint Number coerces to Object#toString');
t.equal(toPrimitive({}, String), '[object Object]', '{} with hint String coerces to Object#toString');
t.equal(toPrimitive(v.toStringOnlyObject), v.toStringOnlyObject.toString(), 'toStringOnlyObject returns non-stringified toString');
t.equal(toPrimitive(v.toStringOnlyObject, Number), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint Number returns non-stringified toString');
t.equal(toPrimitive(v.toStringOnlyObject, String), v.toStringOnlyObject.toString(), 'toStringOnlyObject with hint String returns non-stringified toString');
t.equal(toPrimitive(v.valueOfOnlyObject), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, Number), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint Number returns valueOf');
t.equal(toPrimitive(v.valueOfOnlyObject, String), v.valueOfOnlyObject.valueOf(), 'valueOfOnlyObject with hint String returns non-stringified valueOf');
t.test('Symbol.toPrimitive', { skip: !v.hasSymbols || !Symbol.toPrimitive }, function (st) {
/** @type {Coercible} */
var overriddenObject = { toString: st.fail, valueOf: st.fail };
overriddenObject[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
return String(hint);
};
st.equal(toPrimitive(overriddenObject), 'default', 'object with Symbol.toPrimitive + no hint invokes that');
st.equal(toPrimitive(overriddenObject, Number), 'number', 'object with Symbol.toPrimitive + hint Number invokes that');
st.equal(toPrimitive(overriddenObject, String), 'string', 'object with Symbol.toPrimitive + hint String invokes that');
/** @type {Coercible} */
var nullToPrimitive = { toString: v.coercibleObject.toString, valueOf: v.coercibleObject.valueOf };
nullToPrimitive[Symbol.toPrimitive] = null;
st.equal(toPrimitive(nullToPrimitive), toPrimitive(v.coercibleObject), 'object with no hint + null Symbol.toPrimitive ignores it');
st.equal(toPrimitive(nullToPrimitive, Number), toPrimitive(v.coercibleObject, Number), 'object with hint Number + null Symbol.toPrimitive ignores it');
st.equal(toPrimitive(nullToPrimitive, String), toPrimitive(v.coercibleObject, String), 'object with hint String + null Symbol.toPrimitive ignores it');
st.test('exceptions', function (sst) {
/** @type {Coercible} */
var nonFunctionToPrimitive = { toString: sst.fail, valueOf: sst.fail };
nonFunctionToPrimitive[Symbol.toPrimitive] = {};
sst['throws'](toPrimitive.bind(null, nonFunctionToPrimitive), TypeError, 'Symbol.toPrimitive returning a non-function throws');
/** @type {Coercible} */
var uncoercibleToPrimitive = { toString: sst.fail, valueOf: sst.fail };
uncoercibleToPrimitive[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
return { toString: function () { return hint; } };
};
sst['throws'](toPrimitive.bind(null, uncoercibleToPrimitive), TypeError, 'Symbol.toPrimitive returning an object throws');
/** @type {Coercible} */
var throwingToPrimitive = { toString: sst.fail, valueOf: sst.fail };
throwingToPrimitive[Symbol.toPrimitive] = /** @type {(hint: string) => unknown} */ function (hint) {
throw new RangeError(hint);
};
sst['throws'](toPrimitive.bind(null, throwingToPrimitive), RangeError, 'Symbol.toPrimitive throwing throws');
sst.end();
});
st.end();
});
t.test('exceptions', function (st) {
st['throws'](toPrimitive.bind(null, v.uncoercibleObject), TypeError, 'uncoercibleObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, Number), TypeError, 'uncoercibleObject with hint Number throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleObject, String), TypeError, 'uncoercibleObject with hint String throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject), TypeError, 'uncoercibleFnObject throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, Number), TypeError, 'uncoercibleFnObject with hint Number throws a TypeError');
st['throws'](toPrimitive.bind(null, v.uncoercibleFnObject, String), TypeError, 'uncoercibleFnObject with hint String throws a TypeError');
st.end();
});
t.end();
});

View File

@@ -0,0 +1,20 @@
'use strict';
var toPrimitive = require('../');
var ES5 = require('../es5');
var ES6 = require('../es6');
var ES2015 = require('../es2015');
var test = require('tape');
test('default export', function (t) {
t.equal(toPrimitive, ES2015, 'default export is ES2015');
t.equal(toPrimitive.ES5, ES5, 'ES5 property has ES5 method');
t.equal(toPrimitive.ES6, ES6, 'ES6 property has ES6 method');
t.equal(toPrimitive.ES2015, ES2015, 'ES2015 property has ES2015 method');
t.end();
});
require('./es5');
require('./es6');
require('./es2015');

View File

@@ -0,0 +1,9 @@
{
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "es2021",
},
"exclude": [
"coverage",
],
}