diff --git a/.eslintrc.json b/.eslintrc.json index d3004e45..4b9180a7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,9 +5,7 @@ "ecmaVersion": 8 }, "env": { - "es6": true, - "node": true, - "browser": true + "es6": true }, "rules": { "no-cond-assign": 0, diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d79abcc2..7e5ee593 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -4,9 +4,9 @@ name: Node.js CI on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node-version: [12.x] + node-version: [14.x] steps: - uses: actions/checkout@v2 @@ -26,5 +26,5 @@ jobs: - run: yarn --frozen-lockfile - run: | echo ::add-matcher::.github/eslint.json - yarn run eslint src --format=compact + yarn run eslint src test --format=compact - run: yarn test diff --git a/LICENSE b/LICENSE index 894ddc65..b0145150 100644 --- a/LICENSE +++ b/LICENSE @@ -1,27 +1,13 @@ -Copyright 2010-2020 Mike Bostock -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the author nor the names of contributors may be used to - endorse or promote products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright 2010-2021 Mike Bostock + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/README.md b/README.md index 72b8a0a5..474a39d8 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,23 @@ And finally **iteration methods** that apply functions to elements in the array: ## Installing -If you use NPM, `npm install d3-array`. Otherwise, download the [latest release](https://github.com/d3/d3-array/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-array.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: +If you use npm, `npm install d3-array`. You can also download the [latest release on GitHub](https://github.com/d3/d3-array/releases/latest). For vanilla HTML in modern browsers, import d3-array from Skypack: ```html - + +``` + +For legacy environments, you can load d3-array’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported: + +```html + ``` diff --git a/d3-array.sublime-project b/d3-array.sublime-project deleted file mode 100644 index 772dfa53..00000000 --- a/d3-array.sublime-project +++ /dev/null @@ -1,17 +0,0 @@ -{ - "folders": [ - { - "path": ".", - "file_exclude_patterns": ["*.sublime-workspace"], - "folder_exclude_patterns": ["dist"] - } - ], - "build_systems": [ - { - "name": "yarn test", - "cmd": ["yarn", "test"], - "file_regex": "\\((...*?):([0-9]*):([0-9]*)\\)", - "working_dir": "$project_path" - } - ] -} diff --git a/package.json b/package.json index 9cd53ff7..bf0c9c4a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,11 @@ "name": "d3-array", "version": "2.12.1", "description": "Array manipulation, ordering, searching, summarizing, etc.", + "homepage": "https://d3js.org/d3-array/", + "repository": { + "type": "git", + "url": "https://github.com/d3/d3-array.git" + }, "keywords": [ "d3", "d3-module", @@ -13,41 +18,43 @@ "sort", "array" ], - "homepage": "https://d3js.org/d3-array/", - "license": "BSD-3-Clause", + "license": "ISC", "author": { "name": "Mike Bostock", "url": "http://bost.ocks.org/mike" }, - "main": "dist/d3-array.js", - "unpkg": "dist/d3-array.min.js", - "module": "src/index.js", - "repository": { - "type": "git", - "url": "https://github.com/d3/d3-array.git" - }, + "type": "module", "files": [ "dist/**/*.js", "src/**/*.js" ], - "scripts": { - "pretest": "rollup -c", - "test": "./test/run.sh", - "prepublishOnly": "rm -rf dist && yarn test", - "postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js" + "module": "src/index.js", + "main": "src/index.js", + "jsdelivr": "dist/d3-array.min.js", + "unpkg": "dist/d3-array.min.js", + "exports": { + "umd": "./dist/d3-array.min.js", + "default": "./src/index.js" }, "sideEffects": false, + "dependencies": { + "internmap": "1 - 2" + }, "devDependencies": { - "@rollup/plugin-node-resolve": "11", - "d3-random": "2", + "@rollup/plugin-node-resolve": "13", + "d3-random": "2 - 3", "eslint": "7", "jsdom": "16", + "mocha": "8", "rollup": "2", - "rollup-plugin-terser": "7", - "tape": "4", - "tape-await": "0.1" + "rollup-plugin-terser": "7" }, - "dependencies": { - "internmap": "^1.0.0" + "scripts": { + "test": "mocha 'test/**/*-test.js' && eslint src test", + "prepublishOnly": "rm -rf dist && yarn test && rollup -c", + "postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -" + }, + "engines": { + "node": ">=12" } } diff --git a/test/.eslintrc.json b/test/.eslintrc.json new file mode 100644 index 00000000..2be71407 --- /dev/null +++ b/test/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 8 + }, + "env": { + "es6": true, + "mocha": true + }, + "rules": { + "no-sparse-arrays": 0 + } +} diff --git a/test/OneTimeNumber.js b/test/OneTimeNumber.js index 26532836..7d311533 100644 --- a/test/OneTimeNumber.js +++ b/test/OneTimeNumber.js @@ -1,6 +1,4 @@ -module.exports = OneTimeNumber; - -function OneTimeNumber(value) { +export function OneTimeNumber(value) { this.value = value; } diff --git a/test/ascending-test.js b/test/ascending-test.js index 78ddeb76..e9e05e36 100644 --- a/test/ascending-test.js +++ b/test/ascending-test.js @@ -1,30 +1,28 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {ascending} from "../src/index.js"; -require("./isNaN"); - -tape("ascending(a, b) returns a negative number if a < b", (test) => { - test.ok(d3.ascending(0, 1) < 0); - test.ok(d3.ascending("a", "b") < 0); +it("ascending(a, b) returns a negative number if a < b", () => { + assert(ascending(0, 1) < 0); + assert(ascending("a", "b") < 0); }); -tape("ascending(a, b) returns a positive number if a > b", (test) => { - test.ok(d3.ascending(1, 0) > 0); - test.ok(d3.ascending("b", "a") > 0); +it("ascending(a, b) returns a positive number if a > b", () => { + assert(ascending(1, 0) > 0); + assert(ascending("b", "a") > 0); }); -tape("ascending(a, b) returns zero if a >= b and a <= b", (test) => { - test.equal(d3.ascending(0, 0), 0); - test.equal(d3.ascending("a", "a"), 0); - test.equal(d3.ascending("0", 0), 0); - test.equal(d3.ascending(0, "0"), 0); +it("ascending(a, b) returns zero if a >= b and a <= b", () => { + assert.strictEqual(ascending(0, 0), 0); + assert.strictEqual(ascending("a", "a"), 0); + assert.strictEqual(ascending("0", 0), 0); + assert.strictEqual(ascending(0, "0"), 0); }); -tape("ascending(a, b) returns NaN if a and b are not comparable", (test) => { - test.isNaN(d3.ascending(0, undefined)); - test.isNaN(d3.ascending(undefined, 0)); - test.isNaN(d3.ascending(undefined, undefined)); - test.isNaN(d3.ascending(0, NaN)); - test.isNaN(d3.ascending(NaN, 0)); - test.isNaN(d3.ascending(NaN, NaN)); +it("ascending(a, b) returns NaN if a and b are not comparable", () => { + assert(isNaN(ascending(0, undefined))); + assert(isNaN(ascending(undefined, 0))); + assert(isNaN(ascending(undefined, undefined))); + assert(isNaN(ascending(0, NaN))); + assert(isNaN(ascending(NaN, 0))); + assert(isNaN(ascending(NaN, NaN))); }); diff --git a/test/asserts.js b/test/asserts.js new file mode 100644 index 00000000..9c2222cf --- /dev/null +++ b/test/asserts.js @@ -0,0 +1,12 @@ +import assert from "assert"; + +export function assertSetEqual(A, B) { + assert(setEqual(A, B)); +} + +function setEqual(A, B) { + if (!(A instanceof Set)) throw new Error("not a set"); + for (const a of A) if (!B.has(a)) return false; + for (const b of B) if (!A.has(b)) return false; + return true; +} diff --git a/test/bin-test.js b/test/bin-test.js index f79deab7..57eb0246 100644 --- a/test/bin-test.js +++ b/test/bin-test.js @@ -1,139 +1,139 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {bin, extent, histogram, thresholdSturges} from "../src/index.js"; -tape("histogram is a deprecated alias for bin", (test) => { - test.strictEqual(d3.histogram, d3.bin); +it("histogram is a deprecated alias for bin", () => { + assert.strictEqual(histogram, bin); }); -tape("bin() returns a default bin generator", (test) => { - const h = d3.bin(); - test.equal(h.value()(42), 42); - test.equal(h.domain(), d3.extent); - test.deepEqual(h.thresholds(), d3.thresholdSturges); +it("bin() returns a default bin generator", () => { + const h = bin(); + assert.strictEqual(h.value()(42), 42); + assert.strictEqual(h.domain(), extent); + assert.deepStrictEqual(h.thresholds(), thresholdSturges); }); -tape("bin(data) computes bins of the specified array of data", (test) => { - const h = d3.bin(); - test.deepEqual(h([0, 0, 0, 10, 20, 20]), [ - bin([0, 0, 0], 0, 5), - bin([], 5, 10), - bin([10], 10, 15), - bin([], 15, 20), - bin([20, 20], 20, 25) +it("bin(data) computes bins of the specified array of data", () => { + const h = bin(); + assert.deepStrictEqual(h([0, 0, 0, 10, 20, 20]), [ + box([0, 0, 0], 0, 5), + box([], 5, 10), + box([10], 10, 15), + box([], 15, 20), + box([20, 20], 20, 25) ]); }); -tape("bin(iterable) is equivalent to bin(array)", (test) => { - const h = d3.bin(); - test.deepEqual(h(iterable([0, 0, 0, 10, 20, 20])), [ - bin([0, 0, 0], 0, 5), - bin([], 5, 10), - bin([10], 10, 15), - bin([], 15, 20), - bin([20, 20], 20, 25) +it("bin(iterable) is equivalent to bin(array)", () => { + const h = bin(); + assert.deepStrictEqual(h(iterable([0, 0, 0, 10, 20, 20])), [ + box([0, 0, 0], 0, 5), + box([], 5, 10), + box([10], 10, 15), + box([], 15, 20), + box([20, 20], 20, 25) ]); }); -tape("bin.value(number) sets the constant value", (test) => { - const h = d3.bin().value(12); // Pointless, but for consistency. - test.deepEqual(h([0, 0, 0, 1, 2, 2]), [ - bin([0, 0, 0, 1, 2, 2], 12, 12), +it("bin.value(number) sets the constant value", () => { + const h = bin().value(12); // Pointless, but for consistency. + assert.deepStrictEqual(h([0, 0, 0, 1, 2, 2]), [ + box([0, 0, 0, 1, 2, 2], 12, 12), ]); }); -tape("bin.value(function) sets the value accessor", (test) => { - const h = d3.bin().value((d) => d.value); +it("bin.value(function) sets the value accessor", () => { + const h = bin().value((d) => d.value); const a = {value: 0}; const b = {value: 10}; const c = {value: 20}; - test.deepEqual(h([a, a, a, b, c, c]), [ - bin([a, a, a], 0, 5), - bin([], 5, 10), - bin([b], 10, 15), - bin([], 15, 20), - bin([c, c], 20, 25) + assert.deepStrictEqual(h([a, a, a, b, c, c]), [ + box([a, a, a], 0, 5), + box([], 5, 10), + box([b], 10, 15), + box([], 15, 20), + box([c, c], 20, 25) ]); }); -tape("bin.domain(array) sets the domain", (test) => { - const h = d3.bin().domain([0, 20]); - test.deepEqual(h.domain()(), [0, 20]); - test.deepEqual(h([1, 2, 2, 10, 18, 18]), [ - bin([1, 2, 2], 0, 5), - bin([], 5, 10), - bin([10], 10, 15), - bin([18, 18], 15, 20) +it("bin.domain(array) sets the domain", () => { + const h = bin().domain([0, 20]); + assert.deepStrictEqual(h.domain()(), [0, 20]); + assert.deepStrictEqual(h([1, 2, 2, 10, 18, 18]), [ + box([1, 2, 2], 0, 5), + box([], 5, 10), + box([10], 10, 15), + box([18, 18], 15, 20) ]); }); -tape("bin.domain(function) sets the domain accessor", (test) => { +it("bin.domain(function) sets the domain accessor", () => { let actual; const values = [1, 2, 2, 10, 18, 18]; const domain = (values) => { actual = values; return [0, 20]; }; - const h = d3.bin().domain(domain); - test.equal(h.domain(), domain); - test.deepEqual(h(values), [ - bin([1, 2, 2], 0, 5), - bin([], 5, 10), - bin([10], 10, 15), - bin([18, 18], 15, 20) + const h = bin().domain(domain); + assert.strictEqual(h.domain(), domain); + assert.deepStrictEqual(h(values), [ + box([1, 2, 2], 0, 5), + box([], 5, 10), + box([10], 10, 15), + box([18, 18], 15, 20) ]); - test.deepEqual(actual, values); + assert.deepStrictEqual(actual, values); }); -tape("bin.thresholds(number) sets the approximate number of bin thresholds", (test) => { - const h = d3.bin().thresholds(3); - test.deepEqual(h([0, 0, 0, 10, 30, 30]), [ - bin([0, 0, 0], 0, 10), - bin([10], 10, 20), - bin([], 20, 30), - bin([30, 30], 30, 40) +it("bin.thresholds(number) sets the approximate number of bin thresholds", () => { + const h = bin().thresholds(3); + assert.deepStrictEqual(h([0, 0, 0, 10, 30, 30]), [ + box([0, 0, 0], 0, 10), + box([10], 10, 20), + box([], 20, 30), + box([30, 30], 30, 40) ]); }); -tape("bin.thresholds(array) sets the bin thresholds", (test) => { - const h = d3.bin().thresholds([10, 20]); - test.deepEqual(h([0, 0, 0, 10, 30, 30]), [ - bin([0, 0, 0], 0, 10), - bin([10], 10, 20), - bin([30, 30], 20, 30) +it("bin.thresholds(array) sets the bin thresholds", () => { + const h = bin().thresholds([10, 20]); + assert.deepStrictEqual(h([0, 0, 0, 10, 30, 30]), [ + box([0, 0, 0], 0, 10), + box([10], 10, 20), + box([30, 30], 20, 30) ]); }); -tape("bin.thresholds(array) ignores thresholds outside the domain", (test) => { - const h = d3.bin().thresholds([0, 1, 2, 3, 4]); - test.deepEqual(h([0, 1, 2, 3]), [ - bin([0], 0, 1), - bin([1], 1, 2), - bin([2], 2, 3), - bin([3], 3, 3) +it("bin.thresholds(array) ignores thresholds outside the domain", () => { + const h = bin().thresholds([0, 1, 2, 3, 4]); + assert.deepStrictEqual(h([0, 1, 2, 3]), [ + box([0], 0, 1), + box([1], 1, 2), + box([2], 2, 3), + box([3], 3, 3) ]); }); -tape("bin.thresholds(function) sets the bin thresholds accessor", (test) => { +it("bin.thresholds(function) sets the bin thresholds accessor", () => { let actual; const values = [0, 0, 0, 10, 30, 30]; - const h = d3.bin().thresholds((values, x0, x1) => { actual = [values, x0, x1]; return [10, 20]; }); - test.deepEqual(h(values), [ - bin([0, 0, 0], 0, 10), - bin([10], 10, 20), - bin([30, 30], 20, 30) + const h = bin().thresholds((values, x0, x1) => { actual = [values, x0, x1]; return [10, 20]; }); + assert.deepStrictEqual(h(values), [ + box([0, 0, 0], 0, 10), + box([10], 10, 20), + box([30, 30], 20, 30) ]); - test.deepEqual(actual, [values, 0, 30]); - test.deepEqual(h.thresholds(() => 5)(values), [ - bin([0, 0, 0], 0, 5), - bin([], 5, 10), - bin([10], 10, 15), - bin([], 15, 20), - bin([], 20, 25), - bin([], 25, 30), - bin([30, 30], 30, 35) + assert.deepStrictEqual(actual, [values, 0, 30]); + assert.deepStrictEqual(h.thresholds(() => 5)(values), [ + box([0, 0, 0], 0, 5), + box([], 5, 10), + box([10], 10, 15), + box([], 15, 20), + box([], 20, 25), + box([], 25, 30), + box([30, 30], 30, 35) ]); }); -tape("bin(data) uses nice thresholds", (test) => { - const h = d3.bin().domain([0, 1]).thresholds(5); - test.deepEqual(h([]).map(b => [b.x0, b.x1]), [ +it("bin(data) uses nice thresholds", () => { + const h = bin().domain([0, 1]).thresholds(5); + assert.deepStrictEqual(h([]).map(b => [b.x0, b.x1]), [ [0.0, 0.2], [0.2, 0.4], [0.4, 0.6], @@ -142,33 +142,33 @@ tape("bin(data) uses nice thresholds", (test) => { ]); }); -tape("bin()() returns bins whose rightmost bin is not too wide", (test) => { - const h = d3.bin(); - test.deepEqual(h([9.8, 10, 11, 12, 13, 13.2]), [ - bin([9.8], 9, 10), - bin([10], 10, 11), - bin([11], 11, 12), - bin([12], 12, 13), - bin([13, 13.2], 13, 14) +it("bin()() returns bins whose rightmost bin is not too wide", () => { + const h = bin(); + assert.deepStrictEqual(h([9.8, 10, 11, 12, 13, 13.2]), [ + box([9.8], 9, 10), + box([10], 10, 11), + box([11], 11, 12), + box([12], 12, 13), + box([13, 13.2], 13, 14) ]); }); -tape("bin(data) coerces values to numbers as expected", (test) => { - const h = d3.bin().thresholds(10); - test.deepEqual(h(["1", "2", "3", "4", "5"]), [ - bin(["1"], 1, 1.5), - bin([], 1.5, 2), - bin(["2"], 2, 2.5), - bin([], 2.5, 3), - bin(["3"], 3, 3.5), - bin([], 3.5, 4), - bin(["4"], 4, 4.5), - bin([], 4.5, 5), - bin(["5"], 5, 5.5) +it("bin(data) coerces values to numbers as expected", () => { + const h = bin().thresholds(10); + assert.deepStrictEqual(h(["1", "2", "3", "4", "5"]), [ + box(["1"], 1, 1.5), + box([], 1.5, 2), + box(["2"], 2, 2.5), + box([], 2.5, 3), + box(["3"], 3, 3.5), + box([], 3.5, 4), + box(["4"], 4, 4.5), + box([], 4.5, 5), + box(["5"], 5, 5.5) ]); }); -function bin(bin, x0, x1) { +function box(bin, x0, x1) { bin.x0 = x0; bin.x1 = x1; return bin; diff --git a/test/bisect-test.js b/test/bisect-test.js index 1e3561ec..c431dab9 100644 --- a/test/bisect-test.js +++ b/test/bisect-test.js @@ -1,66 +1,66 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {bisect, bisectLeft, bisectRight} from "../src/index.js"; -tape("bisect is an alias for bisectRight", (test) => { - test.equal(d3.bisect, d3.bisectRight); +it("bisect is an alias for bisectRight", () => { + assert.strictEqual(bisect, bisectRight); }); -tape("bisectLeft(array, value) returns the index of an exact match", (test) => { +it("bisectLeft(array, value) returns the index of an exact match", () => { const numbers = [1, 2, 3]; - test.equal(d3.bisectLeft(numbers, 1), 0); - test.equal(d3.bisectLeft(numbers, 2), 1); - test.equal(d3.bisectLeft(numbers, 3), 2); + assert.strictEqual(bisectLeft(numbers, 1), 0); + assert.strictEqual(bisectLeft(numbers, 2), 1); + assert.strictEqual(bisectLeft(numbers, 3), 2); }); -tape("bisectLeft(array, value) returns the index of the first match", (test) => { +it("bisectLeft(array, value) returns the index of the first match", () => { const numbers = [1, 2, 2, 3]; - test.equal(d3.bisectLeft(numbers, 1), 0); - test.equal(d3.bisectLeft(numbers, 2), 1); - test.equal(d3.bisectLeft(numbers, 3), 3); + assert.strictEqual(bisectLeft(numbers, 1), 0); + assert.strictEqual(bisectLeft(numbers, 2), 1); + assert.strictEqual(bisectLeft(numbers, 3), 3); }); -tape("bisectLeft(empty, value) returns zero", (test) => { - test.equal(d3.bisectLeft([], 1), 0); +it("bisectLeft(empty, value) returns zero", () => { + assert.strictEqual(bisectLeft([], 1), 0); }); -tape("bisectLeft(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisectLeft(array, value) returns the insertion point of a non-exact match", () => { const numbers = [1, 2, 3]; - test.equal(d3.bisectLeft(numbers, 0.5), 0); - test.equal(d3.bisectLeft(numbers, 1.5), 1); - test.equal(d3.bisectLeft(numbers, 2.5), 2); - test.equal(d3.bisectLeft(numbers, 3.5), 3); + assert.strictEqual(bisectLeft(numbers, 0.5), 0); + assert.strictEqual(bisectLeft(numbers, 1.5), 1); + assert.strictEqual(bisectLeft(numbers, 2.5), 2); + assert.strictEqual(bisectLeft(numbers, 3.5), 3); }); -tape("bisectLeft(array, value) has undefined behavior if the search value is unorderable", (test) => { +it("bisectLeft(array, value) has undefined behavior if the search value is unorderable", () => { const numbers = [1, 2, 3]; - d3.bisectLeft(numbers, new Date(NaN)); // who knows what this will return! - d3.bisectLeft(numbers, undefined); - d3.bisectLeft(numbers, NaN); + bisectLeft(numbers, new Date(NaN)); // who knows what this will return! + bisectLeft(numbers, undefined); + bisectLeft(numbers, NaN); }); -tape("bisectLeft(array, value, lo) observes the specified lower bound", (test) => { +it("bisectLeft(array, value, lo) observes the specified lower bound", () => { const numbers = [1, 2, 3, 4, 5]; - test.equal(d3.bisectLeft(numbers, 0, 2), 2); - test.equal(d3.bisectLeft(numbers, 1, 2), 2); - test.equal(d3.bisectLeft(numbers, 2, 2), 2); - test.equal(d3.bisectLeft(numbers, 3, 2), 2); - test.equal(d3.bisectLeft(numbers, 4, 2), 3); - test.equal(d3.bisectLeft(numbers, 5, 2), 4); - test.equal(d3.bisectLeft(numbers, 6, 2), 5); + assert.strictEqual(bisectLeft(numbers, 0, 2), 2); + assert.strictEqual(bisectLeft(numbers, 1, 2), 2); + assert.strictEqual(bisectLeft(numbers, 2, 2), 2); + assert.strictEqual(bisectLeft(numbers, 3, 2), 2); + assert.strictEqual(bisectLeft(numbers, 4, 2), 3); + assert.strictEqual(bisectLeft(numbers, 5, 2), 4); + assert.strictEqual(bisectLeft(numbers, 6, 2), 5); }); -tape("bisectLeft(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisectLeft(array, value, lo, hi) observes the specified bounds", () => { const numbers = [1, 2, 3, 4, 5]; - test.equal(d3.bisectLeft(numbers, 0, 2, 3), 2); - test.equal(d3.bisectLeft(numbers, 1, 2, 3), 2); - test.equal(d3.bisectLeft(numbers, 2, 2, 3), 2); - test.equal(d3.bisectLeft(numbers, 3, 2, 3), 2); - test.equal(d3.bisectLeft(numbers, 4, 2, 3), 3); - test.equal(d3.bisectLeft(numbers, 5, 2, 3), 3); - test.equal(d3.bisectLeft(numbers, 6, 2, 3), 3); + assert.strictEqual(bisectLeft(numbers, 0, 2, 3), 2); + assert.strictEqual(bisectLeft(numbers, 1, 2, 3), 2); + assert.strictEqual(bisectLeft(numbers, 2, 2, 3), 2); + assert.strictEqual(bisectLeft(numbers, 3, 2, 3), 2); + assert.strictEqual(bisectLeft(numbers, 4, 2, 3), 3); + assert.strictEqual(bisectLeft(numbers, 5, 2, 3), 3); + assert.strictEqual(bisectLeft(numbers, 6, 2, 3), 3); }); -tape("bisectLeft(array, value) handles large sparse d3", (test) => { +it("bisectLeft(array, value) handles large sparse d3", () => { const numbers = []; let i = 1 << 30; numbers[i++] = 1; @@ -68,64 +68,64 @@ tape("bisectLeft(array, value) handles large sparse d3", (test) => { numbers[i++] = 3; numbers[i++] = 4; numbers[i++] = 5; - test.equal(d3.bisectLeft(numbers, 0, i - 5, i), i - 5); - test.equal(d3.bisectLeft(numbers, 1, i - 5, i), i - 5); - test.equal(d3.bisectLeft(numbers, 2, i - 5, i), i - 4); - test.equal(d3.bisectLeft(numbers, 3, i - 5, i), i - 3); - test.equal(d3.bisectLeft(numbers, 4, i - 5, i), i - 2); - test.equal(d3.bisectLeft(numbers, 5, i - 5, i), i - 1); - test.equal(d3.bisectLeft(numbers, 6, i - 5, i), i - 0); + assert.strictEqual(bisectLeft(numbers, 0, i - 5, i), i - 5); + assert.strictEqual(bisectLeft(numbers, 1, i - 5, i), i - 5); + assert.strictEqual(bisectLeft(numbers, 2, i - 5, i), i - 4); + assert.strictEqual(bisectLeft(numbers, 3, i - 5, i), i - 3); + assert.strictEqual(bisectLeft(numbers, 4, i - 5, i), i - 2); + assert.strictEqual(bisectLeft(numbers, 5, i - 5, i), i - 1); + assert.strictEqual(bisectLeft(numbers, 6, i - 5, i), i - 0); }); -tape("bisectRight(array, value) returns the index after an exact match", (test) => { +it("bisectRight(array, value) returns the index after an exact match", () => { const numbers = [1, 2, 3]; - test.equal(d3.bisectRight(numbers, 1), 1); - test.equal(d3.bisectRight(numbers, 2), 2); - test.equal(d3.bisectRight(numbers, 3), 3); + assert.strictEqual(bisectRight(numbers, 1), 1); + assert.strictEqual(bisectRight(numbers, 2), 2); + assert.strictEqual(bisectRight(numbers, 3), 3); }); -tape("bisectRight(array, value) returns the index after the last match", (test) => { +it("bisectRight(array, value) returns the index after the last match", () => { const numbers = [1, 2, 2, 3]; - test.equal(d3.bisectRight(numbers, 1), 1); - test.equal(d3.bisectRight(numbers, 2), 3); - test.equal(d3.bisectRight(numbers, 3), 4); + assert.strictEqual(bisectRight(numbers, 1), 1); + assert.strictEqual(bisectRight(numbers, 2), 3); + assert.strictEqual(bisectRight(numbers, 3), 4); }); -tape("bisectRight(empty, value) returns zero", (test) => { - test.equal(d3.bisectRight([], 1), 0); +it("bisectRight(empty, value) returns zero", () => { + assert.strictEqual(bisectRight([], 1), 0); }); -tape("bisectRight(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisectRight(array, value) returns the insertion point of a non-exact match", () => { const numbers = [1, 2, 3]; - test.equal(d3.bisectRight(numbers, 0.5), 0); - test.equal(d3.bisectRight(numbers, 1.5), 1); - test.equal(d3.bisectRight(numbers, 2.5), 2); - test.equal(d3.bisectRight(numbers, 3.5), 3); + assert.strictEqual(bisectRight(numbers, 0.5), 0); + assert.strictEqual(bisectRight(numbers, 1.5), 1); + assert.strictEqual(bisectRight(numbers, 2.5), 2); + assert.strictEqual(bisectRight(numbers, 3.5), 3); }); -tape("bisectRight(array, value, lo) observes the specified lower bound", (test) => { +it("bisectRight(array, value, lo) observes the specified lower bound", () => { const numbers = [1, 2, 3, 4, 5]; - test.equal(d3.bisectRight(numbers, 0, 2), 2); - test.equal(d3.bisectRight(numbers, 1, 2), 2); - test.equal(d3.bisectRight(numbers, 2, 2), 2); - test.equal(d3.bisectRight(numbers, 3, 2), 3); - test.equal(d3.bisectRight(numbers, 4, 2), 4); - test.equal(d3.bisectRight(numbers, 5, 2), 5); - test.equal(d3.bisectRight(numbers, 6, 2), 5); + assert.strictEqual(bisectRight(numbers, 0, 2), 2); + assert.strictEqual(bisectRight(numbers, 1, 2), 2); + assert.strictEqual(bisectRight(numbers, 2, 2), 2); + assert.strictEqual(bisectRight(numbers, 3, 2), 3); + assert.strictEqual(bisectRight(numbers, 4, 2), 4); + assert.strictEqual(bisectRight(numbers, 5, 2), 5); + assert.strictEqual(bisectRight(numbers, 6, 2), 5); }); -tape("bisectRight(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisectRight(array, value, lo, hi) observes the specified bounds", () => { const numbers = [1, 2, 3, 4, 5]; - test.equal(d3.bisectRight(numbers, 0, 2, 3), 2); - test.equal(d3.bisectRight(numbers, 1, 2, 3), 2); - test.equal(d3.bisectRight(numbers, 2, 2, 3), 2); - test.equal(d3.bisectRight(numbers, 3, 2, 3), 3); - test.equal(d3.bisectRight(numbers, 4, 2, 3), 3); - test.equal(d3.bisectRight(numbers, 5, 2, 3), 3); - test.equal(d3.bisectRight(numbers, 6, 2, 3), 3); + assert.strictEqual(bisectRight(numbers, 0, 2, 3), 2); + assert.strictEqual(bisectRight(numbers, 1, 2, 3), 2); + assert.strictEqual(bisectRight(numbers, 2, 2, 3), 2); + assert.strictEqual(bisectRight(numbers, 3, 2, 3), 3); + assert.strictEqual(bisectRight(numbers, 4, 2, 3), 3); + assert.strictEqual(bisectRight(numbers, 5, 2, 3), 3); + assert.strictEqual(bisectRight(numbers, 6, 2, 3), 3); }); -tape("bisectRight(array, value) handles large sparse d3", (test) => { +it("bisectRight(array, value) handles large sparse d3", () => { const numbers = []; let i = 1 << 30; numbers[i++] = 1; @@ -133,11 +133,11 @@ tape("bisectRight(array, value) handles large sparse d3", (test) => { numbers[i++] = 3; numbers[i++] = 4; numbers[i++] = 5; - test.equal(d3.bisectRight(numbers, 0, i - 5, i), i - 5); - test.equal(d3.bisectRight(numbers, 1, i - 5, i), i - 4); - test.equal(d3.bisectRight(numbers, 2, i - 5, i), i - 3); - test.equal(d3.bisectRight(numbers, 3, i - 5, i), i - 2); - test.equal(d3.bisectRight(numbers, 4, i - 5, i), i - 1); - test.equal(d3.bisectRight(numbers, 5, i - 5, i), i - 0); - test.equal(d3.bisectRight(numbers, 6, i - 5, i), i - 0); + assert.strictEqual(bisectRight(numbers, 0, i - 5, i), i - 5); + assert.strictEqual(bisectRight(numbers, 1, i - 5, i), i - 4); + assert.strictEqual(bisectRight(numbers, 2, i - 5, i), i - 3); + assert.strictEqual(bisectRight(numbers, 3, i - 5, i), i - 2); + assert.strictEqual(bisectRight(numbers, 4, i - 5, i), i - 1); + assert.strictEqual(bisectRight(numbers, 5, i - 5, i), i - 0); + assert.strictEqual(bisectRight(numbers, 6, i - 5, i), i - 0); }); diff --git a/test/bisector-test.js b/test/bisector-test.js index 1b93b486..e773746e 100644 --- a/test/bisector-test.js +++ b/test/bisector-test.js @@ -1,338 +1,338 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {ascending, bisector} from "../src/index.js"; -tape("bisector(comparator).left(array, value) returns the index of an exact match", (test) => { +it("bisector(comparator).left(array, value) returns the index of an exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; - test.equal(bisectLeft(boxes, box(1)), 0); - test.equal(bisectLeft(boxes, box(2)), 1); - test.equal(bisectLeft(boxes, box(3)), 2); + const bisectLeft = bisector(ascendingBox).left; + assert.strictEqual(bisectLeft(boxes, box(1)), 0); + assert.strictEqual(bisectLeft(boxes, box(2)), 1); + assert.strictEqual(bisectLeft(boxes, box(3)), 2); }); -tape("bisector(comparator).left(array, value) returns the index of the first match", (test) => { +it("bisector(comparator).left(array, value) returns the index of the first match", () => { const boxes = [1, 2, 2, 3].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; - test.equal(bisectLeft(boxes, box(1)), 0); - test.equal(bisectLeft(boxes, box(2)), 1); - test.equal(bisectLeft(boxes, box(3)), 3); + const bisectLeft = bisector(ascendingBox).left; + assert.strictEqual(bisectLeft(boxes, box(1)), 0); + assert.strictEqual(bisectLeft(boxes, box(2)), 1); + assert.strictEqual(bisectLeft(boxes, box(3)), 3); }); -tape("bisector(comparator).left(empty, value) returns zero", (test) => { - test.equal(d3.bisector(() => { throw new Error(); }).left([], 1), 0); +it("bisector(comparator).left(empty, value) returns zero", () => { + assert.strictEqual(bisector(() => { throw new Error(); }).left([], 1), 0); }); -tape("bisector(comparator).left(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisector(comparator).left(array, value) returns the insertion point of a non-exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; - test.equal(bisectLeft(boxes, box(0.5)), 0); - test.equal(bisectLeft(boxes, box(1.5)), 1); - test.equal(bisectLeft(boxes, box(2.5)), 2); - test.equal(bisectLeft(boxes, box(3.5)), 3); + const bisectLeft = bisector(ascendingBox).left; + assert.strictEqual(bisectLeft(boxes, box(0.5)), 0); + assert.strictEqual(bisectLeft(boxes, box(1.5)), 1); + assert.strictEqual(bisectLeft(boxes, box(2.5)), 2); + assert.strictEqual(bisectLeft(boxes, box(3.5)), 3); }); -tape("bisector(comparator).left(array, value) has undefined behavior if the search value is unorderable", (test) => { +it("bisector(comparator).left(array, value) has undefined behavior if the search value is unorderable", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; + const bisectLeft = bisector(ascendingBox).left; bisectLeft(boxes, box(new Date(NaN))); // who knows what this will return! bisectLeft(boxes, box(undefined)); bisectLeft(boxes, box(NaN)); }); -tape("bisector(comparator).left(array, value, lo) observes the specified lower bound", (test) => { +it("bisector(comparator).left(array, value, lo) observes the specified lower bound", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; - test.equal(bisectLeft(boxes, box(0), 2), 2); - test.equal(bisectLeft(boxes, box(1), 2), 2); - test.equal(bisectLeft(boxes, box(2), 2), 2); - test.equal(bisectLeft(boxes, box(3), 2), 2); - test.equal(bisectLeft(boxes, box(4), 2), 3); - test.equal(bisectLeft(boxes, box(5), 2), 4); - test.equal(bisectLeft(boxes, box(6), 2), 5); + const bisectLeft = bisector(ascendingBox).left; + assert.strictEqual(bisectLeft(boxes, box(0), 2), 2); + assert.strictEqual(bisectLeft(boxes, box(1), 2), 2); + assert.strictEqual(bisectLeft(boxes, box(2), 2), 2); + assert.strictEqual(bisectLeft(boxes, box(3), 2), 2); + assert.strictEqual(bisectLeft(boxes, box(4), 2), 3); + assert.strictEqual(bisectLeft(boxes, box(5), 2), 4); + assert.strictEqual(bisectLeft(boxes, box(6), 2), 5); }); -tape("bisector(comparator).left(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisector(comparator).left(array, value, lo, hi) observes the specified bounds", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectLeft = d3.bisector(ascendingBox).left; - test.equal(bisectLeft(boxes, box(0), 2, 3), 2); - test.equal(bisectLeft(boxes, box(1), 2, 3), 2); - test.equal(bisectLeft(boxes, box(2), 2, 3), 2); - test.equal(bisectLeft(boxes, box(3), 2, 3), 2); - test.equal(bisectLeft(boxes, box(4), 2, 3), 3); - test.equal(bisectLeft(boxes, box(5), 2, 3), 3); - test.equal(bisectLeft(boxes, box(6), 2, 3), 3); + const bisectLeft = bisector(ascendingBox).left; + assert.strictEqual(bisectLeft(boxes, box(0), 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, box(1), 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, box(2), 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, box(3), 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, box(4), 2, 3), 3); + assert.strictEqual(bisectLeft(boxes, box(5), 2, 3), 3); + assert.strictEqual(bisectLeft(boxes, box(6), 2, 3), 3); }); -tape("bisector(comparator).left(array, value) handles large sparse d3", (test) => { +it("bisector(comparator).left(array, value) handles large sparse d3", () => { const boxes = []; - const bisectLeft = d3.bisector(ascendingBox).left; + const bisectLeft = bisector(ascendingBox).left; let i = 1 << 30; boxes[i++] = box(1); boxes[i++] = box(2); boxes[i++] = box(3); boxes[i++] = box(4); boxes[i++] = box(5); - test.equal(bisectLeft(boxes, box(0), i - 5, i), i - 5); - test.equal(bisectLeft(boxes, box(1), i - 5, i), i - 5); - test.equal(bisectLeft(boxes, box(2), i - 5, i), i - 4); - test.equal(bisectLeft(boxes, box(3), i - 5, i), i - 3); - test.equal(bisectLeft(boxes, box(4), i - 5, i), i - 2); - test.equal(bisectLeft(boxes, box(5), i - 5, i), i - 1); - test.equal(bisectLeft(boxes, box(6), i - 5, i), i - 0); + assert.strictEqual(bisectLeft(boxes, box(0), i - 5, i), i - 5); + assert.strictEqual(bisectLeft(boxes, box(1), i - 5, i), i - 5); + assert.strictEqual(bisectLeft(boxes, box(2), i - 5, i), i - 4); + assert.strictEqual(bisectLeft(boxes, box(3), i - 5, i), i - 3); + assert.strictEqual(bisectLeft(boxes, box(4), i - 5, i), i - 2); + assert.strictEqual(bisectLeft(boxes, box(5), i - 5, i), i - 1); + assert.strictEqual(bisectLeft(boxes, box(6), i - 5, i), i - 0); }); -tape("bisector(comparator).right(array, value) returns the index after an exact match", (test) => { +it("bisector(comparator).right(array, value) returns the index after an exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectRight = d3.bisector(ascendingBox).right; - test.equal(bisectRight(boxes, box(1)), 1); - test.equal(bisectRight(boxes, box(2)), 2); - test.equal(bisectRight(boxes, box(3)), 3); + const bisectRight = bisector(ascendingBox).right; + assert.strictEqual(bisectRight(boxes, box(1)), 1); + assert.strictEqual(bisectRight(boxes, box(2)), 2); + assert.strictEqual(bisectRight(boxes, box(3)), 3); }); -tape("bisector(comparator).right(array, value) returns the index after the last match", (test) => { +it("bisector(comparator).right(array, value) returns the index after the last match", () => { const boxes = [1, 2, 2, 3].map(box); - const bisectRight = d3.bisector(ascendingBox).right; - test.equal(bisectRight(boxes, box(1)), 1); - test.equal(bisectRight(boxes, box(2)), 3); - test.equal(bisectRight(boxes, box(3)), 4); + const bisectRight = bisector(ascendingBox).right; + assert.strictEqual(bisectRight(boxes, box(1)), 1); + assert.strictEqual(bisectRight(boxes, box(2)), 3); + assert.strictEqual(bisectRight(boxes, box(3)), 4); }); -tape("bisector(comparator).right(empty, value) returns zero", (test) => { - test.equal(d3.bisector(() => { throw new Error(); }).right([], 1), 0); +it("bisector(comparator).right(empty, value) returns zero", () => { + assert.strictEqual(bisector(() => { throw new Error(); }).right([], 1), 0); }); -tape("bisector(comparator).right(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisector(comparator).right(array, value) returns the insertion point of a non-exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectRight = d3.bisector(ascendingBox).right; - test.equal(bisectRight(boxes, box(0.5)), 0); - test.equal(bisectRight(boxes, box(1.5)), 1); - test.equal(bisectRight(boxes, box(2.5)), 2); - test.equal(bisectRight(boxes, box(3.5)), 3); + const bisectRight = bisector(ascendingBox).right; + assert.strictEqual(bisectRight(boxes, box(0.5)), 0); + assert.strictEqual(bisectRight(boxes, box(1.5)), 1); + assert.strictEqual(bisectRight(boxes, box(2.5)), 2); + assert.strictEqual(bisectRight(boxes, box(3.5)), 3); }); -tape("bisector(comparator).right(array, value, lo) observes the specified lower bound", (test) => { +it("bisector(comparator).right(array, value, lo) observes the specified lower bound", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectRight = d3.bisector(ascendingBox).right; - test.equal(bisectRight(boxes, box(0), 2), 2); - test.equal(bisectRight(boxes, box(1), 2), 2); - test.equal(bisectRight(boxes, box(2), 2), 2); - test.equal(bisectRight(boxes, box(3), 2), 3); - test.equal(bisectRight(boxes, box(4), 2), 4); - test.equal(bisectRight(boxes, box(5), 2), 5); - test.equal(bisectRight(boxes, box(6), 2), 5); + const bisectRight = bisector(ascendingBox).right; + assert.strictEqual(bisectRight(boxes, box(0), 2), 2); + assert.strictEqual(bisectRight(boxes, box(1), 2), 2); + assert.strictEqual(bisectRight(boxes, box(2), 2), 2); + assert.strictEqual(bisectRight(boxes, box(3), 2), 3); + assert.strictEqual(bisectRight(boxes, box(4), 2), 4); + assert.strictEqual(bisectRight(boxes, box(5), 2), 5); + assert.strictEqual(bisectRight(boxes, box(6), 2), 5); }); -tape("bisector(comparator).right(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisector(comparator).right(array, value, lo, hi) observes the specified bounds", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectRight = d3.bisector(ascendingBox).right; - test.equal(bisectRight(boxes, box(0), 2, 3), 2); - test.equal(bisectRight(boxes, box(1), 2, 3), 2); - test.equal(bisectRight(boxes, box(2), 2, 3), 2); - test.equal(bisectRight(boxes, box(3), 2, 3), 3); - test.equal(bisectRight(boxes, box(4), 2, 3), 3); - test.equal(bisectRight(boxes, box(5), 2, 3), 3); - test.equal(bisectRight(boxes, box(6), 2, 3), 3); + const bisectRight = bisector(ascendingBox).right; + assert.strictEqual(bisectRight(boxes, box(0), 2, 3), 2); + assert.strictEqual(bisectRight(boxes, box(1), 2, 3), 2); + assert.strictEqual(bisectRight(boxes, box(2), 2, 3), 2); + assert.strictEqual(bisectRight(boxes, box(3), 2, 3), 3); + assert.strictEqual(bisectRight(boxes, box(4), 2, 3), 3); + assert.strictEqual(bisectRight(boxes, box(5), 2, 3), 3); + assert.strictEqual(bisectRight(boxes, box(6), 2, 3), 3); }); -tape("bisector(comparator).right(array, value) handles large sparse d3", (test) => { +it("bisector(comparator).right(array, value) handles large sparse d3", () => { const boxes = []; - const bisectRight = d3.bisector(ascendingBox).right; + const bisectRight = bisector(ascendingBox).right; let i = 1 << 30; boxes[i++] = box(1); boxes[i++] = box(2); boxes[i++] = box(3); boxes[i++] = box(4); boxes[i++] = box(5); - test.equal(bisectRight(boxes, box(0), i - 5, i), i - 5); - test.equal(bisectRight(boxes, box(1), i - 5, i), i - 4); - test.equal(bisectRight(boxes, box(2), i - 5, i), i - 3); - test.equal(bisectRight(boxes, box(3), i - 5, i), i - 2); - test.equal(bisectRight(boxes, box(4), i - 5, i), i - 1); - test.equal(bisectRight(boxes, box(5), i - 5, i), i - 0); - test.equal(bisectRight(boxes, box(6), i - 5, i), i - 0); + assert.strictEqual(bisectRight(boxes, box(0), i - 5, i), i - 5); + assert.strictEqual(bisectRight(boxes, box(1), i - 5, i), i - 4); + assert.strictEqual(bisectRight(boxes, box(2), i - 5, i), i - 3); + assert.strictEqual(bisectRight(boxes, box(3), i - 5, i), i - 2); + assert.strictEqual(bisectRight(boxes, box(4), i - 5, i), i - 1); + assert.strictEqual(bisectRight(boxes, box(5), i - 5, i), i - 0); + assert.strictEqual(bisectRight(boxes, box(6), i - 5, i), i - 0); }); -tape("bisector(accessor).left(array, value) returns the index of an exact match", (test) => { +it("bisector(accessor).left(array, value) returns the index of an exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(unbox).left; - test.equal(bisectLeft(boxes, 1), 0); - test.equal(bisectLeft(boxes, 2), 1); - test.equal(bisectLeft(boxes, 3), 2); + const bisectLeft = bisector(unbox).left; + assert.strictEqual(bisectLeft(boxes, 1), 0); + assert.strictEqual(bisectLeft(boxes, 2), 1); + assert.strictEqual(bisectLeft(boxes, 3), 2); }); -tape("bisector(accessor).left(array, value) returns the index of the first match", (test) => { +it("bisector(accessor).left(array, value) returns the index of the first match", () => { const boxes = [1, 2, 2, 3].map(box); - const bisectLeft = d3.bisector(unbox).left; - test.equal(bisectLeft(boxes, 1), 0); - test.equal(bisectLeft(boxes, 2), 1); - test.equal(bisectLeft(boxes, 3), 3); + const bisectLeft = bisector(unbox).left; + assert.strictEqual(bisectLeft(boxes, 1), 0); + assert.strictEqual(bisectLeft(boxes, 2), 1); + assert.strictEqual(bisectLeft(boxes, 3), 3); }); -tape("bisector(accessor).left(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisector(accessor).left(array, value) returns the insertion point of a non-exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(unbox).left; - test.equal(bisectLeft(boxes, 0.5), 0); - test.equal(bisectLeft(boxes, 1.5), 1); - test.equal(bisectLeft(boxes, 2.5), 2); - test.equal(bisectLeft(boxes, 3.5), 3); + const bisectLeft = bisector(unbox).left; + assert.strictEqual(bisectLeft(boxes, 0.5), 0); + assert.strictEqual(bisectLeft(boxes, 1.5), 1); + assert.strictEqual(bisectLeft(boxes, 2.5), 2); + assert.strictEqual(bisectLeft(boxes, 3.5), 3); }); -tape("bisector(accessor).left(array, value) has undefined behavior if the search value is unorderable", (test) => { +it("bisector(accessor).left(array, value) has undefined behavior if the search value is unorderable", () => { const boxes = [1, 2, 3].map(box); - const bisectLeft = d3.bisector(unbox).left; + const bisectLeft = bisector(unbox).left; bisectLeft(boxes, new Date(NaN)); // who knows what this will return! bisectLeft(boxes, undefined); bisectLeft(boxes, NaN); }); -tape("bisector(accessor).left(array, value, lo) observes the specified lower bound", (test) => { +it("bisector(accessor).left(array, value, lo) observes the specified lower bound", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectLeft = d3.bisector(unbox).left; - test.equal(bisectLeft(boxes, 0, 2), 2); - test.equal(bisectLeft(boxes, 1, 2), 2); - test.equal(bisectLeft(boxes, 2, 2), 2); - test.equal(bisectLeft(boxes, 3, 2), 2); - test.equal(bisectLeft(boxes, 4, 2), 3); - test.equal(bisectLeft(boxes, 5, 2), 4); - test.equal(bisectLeft(boxes, 6, 2), 5); + const bisectLeft = bisector(unbox).left; + assert.strictEqual(bisectLeft(boxes, 0, 2), 2); + assert.strictEqual(bisectLeft(boxes, 1, 2), 2); + assert.strictEqual(bisectLeft(boxes, 2, 2), 2); + assert.strictEqual(bisectLeft(boxes, 3, 2), 2); + assert.strictEqual(bisectLeft(boxes, 4, 2), 3); + assert.strictEqual(bisectLeft(boxes, 5, 2), 4); + assert.strictEqual(bisectLeft(boxes, 6, 2), 5); }); -tape("bisector(accessor).left(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisector(accessor).left(array, value, lo, hi) observes the specified bounds", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectLeft = d3.bisector(unbox).left; - test.equal(bisectLeft(boxes, 0, 2, 3), 2); - test.equal(bisectLeft(boxes, 1, 2, 3), 2); - test.equal(bisectLeft(boxes, 2, 2, 3), 2); - test.equal(bisectLeft(boxes, 3, 2, 3), 2); - test.equal(bisectLeft(boxes, 4, 2, 3), 3); - test.equal(bisectLeft(boxes, 5, 2, 3), 3); - test.equal(bisectLeft(boxes, 6, 2, 3), 3); + const bisectLeft = bisector(unbox).left; + assert.strictEqual(bisectLeft(boxes, 0, 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, 1, 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, 2, 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, 3, 2, 3), 2); + assert.strictEqual(bisectLeft(boxes, 4, 2, 3), 3); + assert.strictEqual(bisectLeft(boxes, 5, 2, 3), 3); + assert.strictEqual(bisectLeft(boxes, 6, 2, 3), 3); }); -tape("bisector(accessor).left(array, value) handles large sparse d3", (test) => { +it("bisector(accessor).left(array, value) handles large sparse d3", () => { const boxes = []; - const bisectLeft = d3.bisector(unbox).left; + const bisectLeft = bisector(unbox).left; let i = 1 << 30; boxes[i++] = box(1); boxes[i++] = box(2); boxes[i++] = box(3); boxes[i++] = box(4); boxes[i++] = box(5); - test.equal(bisectLeft(boxes, 0, i - 5, i), i - 5); - test.equal(bisectLeft(boxes, 1, i - 5, i), i - 5); - test.equal(bisectLeft(boxes, 2, i - 5, i), i - 4); - test.equal(bisectLeft(boxes, 3, i - 5, i), i - 3); - test.equal(bisectLeft(boxes, 4, i - 5, i), i - 2); - test.equal(bisectLeft(boxes, 5, i - 5, i), i - 1); - test.equal(bisectLeft(boxes, 6, i - 5, i), i - 0); + assert.strictEqual(bisectLeft(boxes, 0, i - 5, i), i - 5); + assert.strictEqual(bisectLeft(boxes, 1, i - 5, i), i - 5); + assert.strictEqual(bisectLeft(boxes, 2, i - 5, i), i - 4); + assert.strictEqual(bisectLeft(boxes, 3, i - 5, i), i - 3); + assert.strictEqual(bisectLeft(boxes, 4, i - 5, i), i - 2); + assert.strictEqual(bisectLeft(boxes, 5, i - 5, i), i - 1); + assert.strictEqual(bisectLeft(boxes, 6, i - 5, i), i - 0); }); -tape("bisector(accessor).right(array, value) returns the index after an exact match", (test) => { +it("bisector(accessor).right(array, value) returns the index after an exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectRight = d3.bisector(unbox).right; - test.equal(bisectRight(boxes, 1), 1); - test.equal(bisectRight(boxes, 2), 2); - test.equal(bisectRight(boxes, 3), 3); + const bisectRight = bisector(unbox).right; + assert.strictEqual(bisectRight(boxes, 1), 1); + assert.strictEqual(bisectRight(boxes, 2), 2); + assert.strictEqual(bisectRight(boxes, 3), 3); }); -tape("bisector(accessor).right(array, value) returns the index after the last match", (test) => { +it("bisector(accessor).right(array, value) returns the index after the last match", () => { const boxes = [1, 2, 2, 3].map(box); - const bisectRight = d3.bisector(unbox).right; - test.equal(bisectRight(boxes, 1), 1); - test.equal(bisectRight(boxes, 2), 3); - test.equal(bisectRight(boxes, 3), 4); + const bisectRight = bisector(unbox).right; + assert.strictEqual(bisectRight(boxes, 1), 1); + assert.strictEqual(bisectRight(boxes, 2), 3); + assert.strictEqual(bisectRight(boxes, 3), 4); }); -tape("bisector(accessor).right(array, value) returns the insertion point of a non-exact match", (test) => { +it("bisector(accessor).right(array, value) returns the insertion point of a non-exact match", () => { const boxes = [1, 2, 3].map(box); - const bisectRight = d3.bisector(unbox).right; - test.equal(bisectRight(boxes, 0.5), 0); - test.equal(bisectRight(boxes, 1.5), 1); - test.equal(bisectRight(boxes, 2.5), 2); - test.equal(bisectRight(boxes, 3.5), 3); + const bisectRight = bisector(unbox).right; + assert.strictEqual(bisectRight(boxes, 0.5), 0); + assert.strictEqual(bisectRight(boxes, 1.5), 1); + assert.strictEqual(bisectRight(boxes, 2.5), 2); + assert.strictEqual(bisectRight(boxes, 3.5), 3); }); -tape("bisector(accessor).right(array, value, lo) observes the specified lower bound", (test) => { +it("bisector(accessor).right(array, value, lo) observes the specified lower bound", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectRight = d3.bisector(unbox).right; - test.equal(bisectRight(boxes, 0, 2), 2); - test.equal(bisectRight(boxes, 1, 2), 2); - test.equal(bisectRight(boxes, 2, 2), 2); - test.equal(bisectRight(boxes, 3, 2), 3); - test.equal(bisectRight(boxes, 4, 2), 4); - test.equal(bisectRight(boxes, 5, 2), 5); - test.equal(bisectRight(boxes, 6, 2), 5); + const bisectRight = bisector(unbox).right; + assert.strictEqual(bisectRight(boxes, 0, 2), 2); + assert.strictEqual(bisectRight(boxes, 1, 2), 2); + assert.strictEqual(bisectRight(boxes, 2, 2), 2); + assert.strictEqual(bisectRight(boxes, 3, 2), 3); + assert.strictEqual(bisectRight(boxes, 4, 2), 4); + assert.strictEqual(bisectRight(boxes, 5, 2), 5); + assert.strictEqual(bisectRight(boxes, 6, 2), 5); }); -tape("bisector(accessor).right(array, value, lo, hi) observes the specified bounds", (test) => { +it("bisector(accessor).right(array, value, lo, hi) observes the specified bounds", () => { const boxes = [1, 2, 3, 4, 5].map(box); - const bisectRight = d3.bisector(unbox).right; - test.equal(bisectRight(boxes, 0, 2, 3), 2); - test.equal(bisectRight(boxes, 1, 2, 3), 2); - test.equal(bisectRight(boxes, 2, 2, 3), 2); - test.equal(bisectRight(boxes, 3, 2, 3), 3); - test.equal(bisectRight(boxes, 4, 2, 3), 3); - test.equal(bisectRight(boxes, 5, 2, 3), 3); - test.equal(bisectRight(boxes, 6, 2, 3), 3); + const bisectRight = bisector(unbox).right; + assert.strictEqual(bisectRight(boxes, 0, 2, 3), 2); + assert.strictEqual(bisectRight(boxes, 1, 2, 3), 2); + assert.strictEqual(bisectRight(boxes, 2, 2, 3), 2); + assert.strictEqual(bisectRight(boxes, 3, 2, 3), 3); + assert.strictEqual(bisectRight(boxes, 4, 2, 3), 3); + assert.strictEqual(bisectRight(boxes, 5, 2, 3), 3); + assert.strictEqual(bisectRight(boxes, 6, 2, 3), 3); }); -tape("bisector(accessor).right(array, value) handles large sparse d3", (test) => { +it("bisector(accessor).right(array, value) handles large sparse d3", () => { const boxes = []; - const bisectRight = d3.bisector(unbox).right; + const bisectRight = bisector(unbox).right; let i = 1 << 30; boxes[i++] = box(1); boxes[i++] = box(2); boxes[i++] = box(3); boxes[i++] = box(4); boxes[i++] = box(5); - test.equal(bisectRight(boxes, 0, i - 5, i), i - 5); - test.equal(bisectRight(boxes, 1, i - 5, i), i - 4); - test.equal(bisectRight(boxes, 2, i - 5, i), i - 3); - test.equal(bisectRight(boxes, 3, i - 5, i), i - 2); - test.equal(bisectRight(boxes, 4, i - 5, i), i - 1); - test.equal(bisectRight(boxes, 5, i - 5, i), i - 0); - test.equal(bisectRight(boxes, 6, i - 5, i), i - 0); + assert.strictEqual(bisectRight(boxes, 0, i - 5, i), i - 5); + assert.strictEqual(bisectRight(boxes, 1, i - 5, i), i - 4); + assert.strictEqual(bisectRight(boxes, 2, i - 5, i), i - 3); + assert.strictEqual(bisectRight(boxes, 3, i - 5, i), i - 2); + assert.strictEqual(bisectRight(boxes, 4, i - 5, i), i - 1); + assert.strictEqual(bisectRight(boxes, 5, i - 5, i), i - 0); + assert.strictEqual(bisectRight(boxes, 6, i - 5, i), i - 0); }); -tape("bisector(accessor).center(array, value) returns the closest index", (test) => { +it("bisector(accessor).center(array, value) returns the closest index", () => { const data = [0, 1, 2, 3, 4]; - const bisectCenter = d3.bisector(d => +d).center; - test.equal(bisectCenter(data, 2), 2); - test.equal(bisectCenter(data, 2.2), 2); - test.equal(bisectCenter(data, 2.6), 3); - test.equal(bisectCenter(data, 3), 3); - test.equal(bisectCenter(data, 4), 4); - test.equal(bisectCenter(data, 4.5), 4); + const bisectCenter = bisector(d => +d).center; + assert.strictEqual(bisectCenter(data, 2), 2); + assert.strictEqual(bisectCenter(data, 2.2), 2); + assert.strictEqual(bisectCenter(data, 2.6), 3); + assert.strictEqual(bisectCenter(data, 3), 3); + assert.strictEqual(bisectCenter(data, 4), 4); + assert.strictEqual(bisectCenter(data, 4.5), 4); }); -tape("bisector(comparator).center(array, value) returns the closest index", (test) => { +it("bisector(comparator).center(array, value) returns the closest index", () => { const data = [0, 1, 2, 3, 4]; - const bisectCenter = d3.bisector((d, x) => +d - x).center; - test.equal(bisectCenter(data, 2), 2); - test.equal(bisectCenter(data, 2.2), 2); - test.equal(bisectCenter(data, 2.6), 3); - test.equal(bisectCenter(data, 3), 3); + const bisectCenter = bisector((d, x) => +d - x).center; + assert.strictEqual(bisectCenter(data, 2), 2); + assert.strictEqual(bisectCenter(data, 2.2), 2); + assert.strictEqual(bisectCenter(data, 2.6), 3); + assert.strictEqual(bisectCenter(data, 3), 3); }); -tape("bisector(comparator).center(empty, value) returns zero", (test) => { - test.equal(d3.bisector(() => { throw new Error(); }).center([], 1), 0); +it("bisector(comparator).center(empty, value) returns zero", () => { + assert.strictEqual(bisector(() => { throw new Error(); }).center([], 1), 0); }); -tape("bisector(ascending).center(array, value) returns the left value", (test) => { +it("bisector(ascending).center(array, value) returns the left value", () => { const data = [0, 1, 2, 3, 4]; - const bisectCenter = d3.bisector(d3.ascending).center; - test.equal(bisectCenter(data, 2.0), 2); - test.equal(bisectCenter(data, 2.2), 3); - test.equal(bisectCenter(data, 2.6), 3); - test.equal(bisectCenter(data, 3.0), 3); + const bisectCenter = bisector(ascending).center; + assert.strictEqual(bisectCenter(data, 2.0), 2); + assert.strictEqual(bisectCenter(data, 2.2), 3); + assert.strictEqual(bisectCenter(data, 2.6), 3); + assert.strictEqual(bisectCenter(data, 3.0), 3); }); -tape("bisector(ordinalAccessor).center(array, value) returns the left value", (test) => { +it("bisector(ordinalAccessor).center(array, value) returns the left value", () => { const data = ["aa", "bb", "cc", "dd", "ee"]; - const bisectCenter = d3.bisector(d => d).center; - test.equal(bisectCenter(data, "cc"), 2); - test.equal(bisectCenter(data, "ce"), 3); - test.equal(bisectCenter(data, "cf"), 3); - test.equal(bisectCenter(data, "dd"), 3); + const bisectCenter = bisector(d => d).center; + assert.strictEqual(bisectCenter(data, "cc"), 2); + assert.strictEqual(bisectCenter(data, "ce"), 3); + assert.strictEqual(bisectCenter(data, "cf"), 3); + assert.strictEqual(bisectCenter(data, "dd"), 3); }); function box(value) { @@ -344,5 +344,5 @@ function unbox(box) { } function ascendingBox(a, b) { - return d3.ascending(a.value, b.value); + return ascending(a.value, b.value); } diff --git a/test/count-test.js b/test/count-test.js index e438bf24..8ed1b5bd 100644 --- a/test/count-test.js +++ b/test/count-test.js @@ -1,23 +1,23 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {count} from "../src/index.js"; -tape("count() accepts an iterable", (test) => { - test.deepEqual(d3.count([1, 2]), 2); - test.deepEqual(d3.count(new Set([1, 2])), 2); - test.deepEqual(d3.count(generate(1, 2)), 2); +it("count() accepts an iterable", () => { + assert.deepStrictEqual(count([1, 2]), 2); + assert.deepStrictEqual(count(new Set([1, 2])), 2); + assert.deepStrictEqual(count(generate(1, 2)), 2); }); -tape("count() ignores NaN, null", (test) => { - test.deepEqual(d3.count([NaN, null, 0, 1]), 2); +it("count() ignores NaN, null", () => { + assert.deepStrictEqual(count([NaN, null, 0, 1]), 2); }); -tape("count() coerces to a number", (test) => { - test.deepEqual(d3.count(["1", " 2", "Fred"]), 2); +it("count() coerces to a number", () => { + assert.deepStrictEqual(count(["1", " 2", "Fred"]), 2); }); -tape("count() accepts an accessor", (test) => { - test.deepEqual(d3.count([{v:NaN}, {}, {v:0}, {v:1}], d => d.v), 2); - test.deepEqual(d3.count([{n: "Alice", age: NaN}, {n: "Bob", age: 18}, {n: "Other"}], d => d.age), 1); +it("count() accepts an accessor", () => { + assert.deepStrictEqual(count([{v:NaN}, {}, {v:0}, {v:1}], d => d.v), 2); + assert.deepStrictEqual(count([{n: "Alice", age: NaN}, {n: "Bob", age: 18}, {n: "Other"}], d => d.age), 1); }); function* generate(...values) { diff --git a/test/cross-test.js b/test/cross-test.js index 382f3616..abe79fbc 100644 --- a/test/cross-test.js +++ b/test/cross-test.js @@ -1,39 +1,39 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {cross} from "../src/index.js"; -tape("cross() returns an empty array", (test) => { - test.deepEqual(d3.cross(), []); +it("cross() returns an empty array", () => { + assert.deepStrictEqual(cross(), []); }); -tape("cross([]) returns an empty array", (test) => { - test.deepEqual(d3.cross([]), []); +it("cross([]) returns an empty array", () => { + assert.deepStrictEqual(cross([]), []); }); -tape("cross([1, 2], []) returns an empty array", (test) => { - test.deepEqual(d3.cross([1, 2], []), []); +it("cross([1, 2], []) returns an empty array", () => { + assert.deepStrictEqual(cross([1, 2], []), []); }); -tape("cross({length: weird}) returns an empty array", (test) => { - test.deepEqual(d3.cross({length: NaN}), []); - test.deepEqual(d3.cross({length: 0.5}), []); - test.deepEqual(d3.cross({length: -1}), []); - test.deepEqual(d3.cross({length: undefined}), []); +it("cross({length: weird}) returns an empty array", () => { + assert.deepStrictEqual(cross({length: NaN}), []); + assert.deepStrictEqual(cross({length: 0.5}), []); + assert.deepStrictEqual(cross({length: -1}), []); + assert.deepStrictEqual(cross({length: undefined}), []); }); -tape("cross(...strings) returns the expected result", (test) => { - test.deepEqual(d3.cross("foo", "bar", (a, b) => a + b), ["fb", "fa", "fr", "ob", "oa", "or", "ob", "oa", "or"]); +it("cross(...strings) returns the expected result", () => { + assert.deepStrictEqual(cross("foo", "bar", (a, b) => a + b), ["fb", "fa", "fr", "ob", "oa", "or", "ob", "oa", "or"]); }); -tape("cross(a) returns the expected result", (test) => { - test.deepEqual(d3.cross([1, 2]), [[1], [2]]); +it("cross(a) returns the expected result", () => { + assert.deepStrictEqual(cross([1, 2]), [[1], [2]]); }); -tape("cross(a, b) returns Cartesian product a×b", (test) => { - test.deepEqual(d3.cross([1, 2], ["x", "y"]), [[1, "x"], [1, "y"], [2, "x"], [2, "y"]]); +it("cross(a, b) returns Cartesian product a×b", () => { + assert.deepStrictEqual(cross([1, 2], ["x", "y"]), [[1, "x"], [1, "y"], [2, "x"], [2, "y"]]); }); -tape("cross(a, b, c) returns Cartesian product a×b×c", (test) => { - test.deepEqual(d3.cross([1, 2], [3, 4], [5, 6, 7]), [ +it("cross(a, b, c) returns Cartesian product a×b×c", () => { + assert.deepStrictEqual(cross([1, 2], [3, 4], [5, 6, 7]), [ [1, 3, 5], [1, 3, 6], [1, 3, 7], @@ -49,16 +49,16 @@ tape("cross(a, b, c) returns Cartesian product a×b×c", (test) => { ]); }); -tape("cross(a, b, f) invokes the specified function for each pair", (test) => { - test.deepEqual(d3.cross([1, 2], ["x", "y"], (a, b) => a + b), ["1x", "1y", "2x", "2y"]); +it("cross(a, b, f) invokes the specified function for each pair", () => { + assert.deepStrictEqual(cross([1, 2], ["x", "y"], (a, b) => a + b), ["1x", "1y", "2x", "2y"]); }); -tape("cross(a, b, c, f) invokes the specified function for each triple", (test) => { - test.deepEqual(d3.cross([1, 2], [3, 4], [5, 6, 7], (a, b, c) => a + b + c), [9, 10, 11, 10, 11, 12, 10, 11, 12, 11, 12, 13]); +it("cross(a, b, c, f) invokes the specified function for each triple", () => { + assert.deepStrictEqual(cross([1, 2], [3, 4], [5, 6, 7], (a, b, c) => a + b + c), [9, 10, 11, 10, 11, 12, 10, 11, 12, 11, 12, 13]); }); -tape("cross(a, b) returns Cartesian product a×b of generators", (test) => { - test.deepEqual(d3.cross(generate(1, 2), generate("x", "y")), [[1, "x"], [1, "y"], [2, "x"], [2, "y"]]); +it("cross(a, b) returns Cartesian product a×b of generators", () => { + assert.deepStrictEqual(cross(generate(1, 2), generate("x", "y")), [[1, "x"], [1, "y"], [2, "x"], [2, "y"]]); }); function* generate(...values) { diff --git a/test/cumsum-test.js b/test/cumsum-test.js index 1e650530..6286f805 100644 --- a/test/cumsum-test.js +++ b/test/cumsum-test.js @@ -1,87 +1,87 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {cumsum} from "../src/index.js"; -tape("cumsum(array) returns the cumulative sum of the specified numbers", (test) => { - test.deepEqual(d3.cumsum([1]), [1]); - test.deepEqual(d3.cumsum([5, 1, 2, 3, 4]), [5, 6, 8, 11, 15]); - test.deepEqual(d3.cumsum([20, 3]), [20, 23]); - test.deepEqual(d3.cumsum([3, 20]), [3, 23]); +it("cumsum(array) returns the cumulative sum of the specified numbers", () => { + assert.deepStrictEqual(Array.from(cumsum([1])), [1]); + assert.deepStrictEqual(Array.from(cumsum([5, 1, 2, 3, 4])), [5, 6, 8, 11, 15]); + assert.deepStrictEqual(Array.from(cumsum([20, 3])), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum([3, 20])), [3, 23]); }); -tape("cumsum(array) observes values that can be coerced to numbers", (test) => { - test.deepEqual(d3.cumsum(["20", "3"]), [20, 23]); - test.deepEqual(d3.cumsum(["3", "20"]), [3, 23]); - test.deepEqual(d3.cumsum(["3", 20]), [3, 23]); - test.deepEqual(d3.cumsum([20, "3"]), [20, 23]); - test.deepEqual(d3.cumsum([3, "20"]), [3, 23]); - test.deepEqual(d3.cumsum(["20", 3]), [20, 23]); +it("cumsum(array) observes values that can be coerced to numbers", () => { + assert.deepStrictEqual(Array.from(cumsum(["20", "3"])), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum(["3", "20"])), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum(["3", 20])), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum([20, "3"])), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum([3, "20"])), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum(["20", 3])), [20, 23]); }); -tape("cumsum(array) ignores non-numeric values", (test) => { - test.deepEqual(d3.cumsum(["a", "b", "c"]), [0, 0, 0]); - test.deepEqual(d3.cumsum(["a", 1, "2"]), [0, 1, 3]); +it("cumsum(array) ignores non-numeric values", () => { + assert.deepStrictEqual(Array.from(cumsum(["a", "b", "c"])), [0, 0, 0]); + assert.deepStrictEqual(Array.from(cumsum(["a", 1, "2"])), [0, 1, 3]); }); -tape("cumsum(array) ignores null, undefined and NaN", (test) => { - test.deepEqual(d3.cumsum([NaN, 1, 2, 3, 4, 5]), [0, 1, 3, 6, 10, 15]); - test.deepEqual(d3.cumsum([1, 2, 3, 4, 5, NaN]), [1, 3, 6, 10, 15, 15]); - test.deepEqual(d3.cumsum([10, null, 3, undefined, 5, NaN]), [10, 10, 13, 13, 18, 18]); +it("cumsum(array) ignores null, undefined and NaN", () => { + assert.deepStrictEqual(Array.from(cumsum([NaN, 1, 2, 3, 4, 5])), [0, 1, 3, 6, 10, 15]); + assert.deepStrictEqual(Array.from(cumsum([1, 2, 3, 4, 5, NaN])), [1, 3, 6, 10, 15, 15]); + assert.deepStrictEqual(Array.from(cumsum([10, null, 3, undefined, 5, NaN])), [10, 10, 13, 13, 18, 18]); }); -tape("cumsum(array) returns zeros if there are no numbers", (test) => { - test.deepEqual(d3.cumsum([]), []); - test.deepEqual(d3.cumsum([NaN]), [0]); - test.deepEqual(d3.cumsum([undefined]), [0]); - test.deepEqual(d3.cumsum([undefined, NaN]), [0, 0]); - test.deepEqual(d3.cumsum([undefined, NaN, {}]), [0, 0, 0]); +it("cumsum(array) returns zeros if there are no numbers", () => { + assert.deepStrictEqual(Array.from(cumsum([])), []); + assert.deepStrictEqual(Array.from(cumsum([NaN])), [0]); + assert.deepStrictEqual(Array.from(cumsum([undefined])), [0]); + assert.deepStrictEqual(Array.from(cumsum([undefined, NaN])), [0, 0]); + assert.deepStrictEqual(Array.from(cumsum([undefined, NaN, {}])), [0, 0, 0]); }); -tape("cumsum(array, f) returns the cumsum of the specified numbers", (test) => { - test.deepEqual(d3.cumsum([1].map(box), unbox), [1]); - test.deepEqual(d3.cumsum([5, 1, 2, 3, 4].map(box), unbox), [5, 6, 8, 11, 15]); - test.deepEqual(d3.cumsum([20, 3].map(box), unbox), [20, 23]); - test.deepEqual(d3.cumsum([3, 20].map(box), unbox), [3, 23]); +it("cumsum(array, f) returns the cumsum of the specified numbers", () => { + assert.deepStrictEqual(Array.from(cumsum([1].map(box), unbox)), [1]); + assert.deepStrictEqual(Array.from(cumsum([5, 1, 2, 3, 4].map(box), unbox)), [5, 6, 8, 11, 15]); + assert.deepStrictEqual(Array.from(cumsum([20, 3].map(box), unbox)), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum([3, 20].map(box), unbox)), [3, 23]); }); -tape("cumsum(array, f) observes values that can be coerced to numbers", (test) => { - test.deepEqual(d3.cumsum(["20", "3"].map(box), unbox), [20, 23]); - test.deepEqual(d3.cumsum(["3", "20"].map(box), unbox), [3, 23]); - test.deepEqual(d3.cumsum(["3", 20].map(box), unbox), [3, 23]); - test.deepEqual(d3.cumsum([20, "3"].map(box), unbox), [20, 23]); - test.deepEqual(d3.cumsum([3, "20"].map(box), unbox), [3, 23]); - test.deepEqual(d3.cumsum(["20", 3].map(box), unbox), [20, 23]); +it("cumsum(array, f) observes values that can be coerced to numbers", () => { + assert.deepStrictEqual(Array.from(cumsum(["20", "3"].map(box), unbox)), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum(["3", "20"].map(box), unbox)), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum(["3", 20].map(box), unbox)), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum([20, "3"].map(box), unbox)), [20, 23]); + assert.deepStrictEqual(Array.from(cumsum([3, "20"].map(box), unbox)), [3, 23]); + assert.deepStrictEqual(Array.from(cumsum(["20", 3].map(box), unbox)), [20, 23]); }); -tape("cumsum(array, f) ignores non-numeric values", (test) => { - test.deepEqual(d3.cumsum(["a", "b", "c"].map(box), unbox), [0, 0, 0]); - test.deepEqual(d3.cumsum(["a", 1, "2"].map(box), unbox), [0, 1, 3]); +it("cumsum(array, f) ignores non-numeric values", () => { + assert.deepStrictEqual(Array.from(cumsum(["a", "b", "c"].map(box), unbox)), [0, 0, 0]); + assert.deepStrictEqual(Array.from(cumsum(["a", 1, "2"].map(box), unbox)), [0, 1, 3]); }); -tape("cumsum(array, f) ignores null, undefined and NaN", (test) => { - test.deepEqual(d3.cumsum([NaN, 1, 2, 3, 4, 5].map(box), unbox), [0, 1, 3, 6, 10, 15]); - test.deepEqual(d3.cumsum([1, 2, 3, 4, 5, NaN].map(box), unbox), [1, 3, 6, 10, 15, 15]); - test.deepEqual(d3.cumsum([10, null, 3, undefined, 5, NaN].map(box), unbox), [10, 10, 13, 13, 18, 18]); +it("cumsum(array, f) ignores null, undefined and NaN", () => { + assert.deepStrictEqual(Array.from(cumsum([NaN, 1, 2, 3, 4, 5].map(box), unbox)), [0, 1, 3, 6, 10, 15]); + assert.deepStrictEqual(Array.from(cumsum([1, 2, 3, 4, 5, NaN].map(box), unbox)), [1, 3, 6, 10, 15, 15]); + assert.deepStrictEqual(Array.from(cumsum([10, null, 3, undefined, 5, NaN].map(box), unbox)), [10, 10, 13, 13, 18, 18]); }); -tape("cumsum(array, f) returns zeros if there are no numbers", (test) => { - test.deepEqual(d3.cumsum([].map(box), unbox), []); - test.deepEqual(d3.cumsum([NaN].map(box), unbox), [0]); - test.deepEqual(d3.cumsum([undefined].map(box), unbox), [0]); - test.deepEqual(d3.cumsum([undefined, NaN].map(box), unbox), [0, 0]); - test.deepEqual(d3.cumsum([undefined, NaN, {}].map(box), unbox), [0, 0, 0]); +it("cumsum(array, f) returns zeros if there are no numbers", () => { + assert.deepStrictEqual(Array.from(cumsum([].map(box), unbox)), []); + assert.deepStrictEqual(Array.from(cumsum([NaN].map(box), unbox)), [0]); + assert.deepStrictEqual(Array.from(cumsum([undefined].map(box), unbox)), [0]); + assert.deepStrictEqual(Array.from(cumsum([undefined, NaN].map(box), unbox)), [0, 0]); + assert.deepStrictEqual(Array.from(cumsum([undefined, NaN, {}].map(box), unbox)), [0, 0, 0]); }); -tape("cumsum(array, f) passes the accessor d, i, and array", (test) => { +it("cumsum(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.cumsum(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + cumsum(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("cumsum(array, f) uses the global context", (test) => { +it("cumsum(array, f) uses the undefined context", () => { const results = []; - d3.cumsum([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + cumsum([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/descending-test.js b/test/descending-test.js index 3fb2173d..f10903bc 100644 --- a/test/descending-test.js +++ b/test/descending-test.js @@ -1,30 +1,28 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {descending} from "../src/index.js"; -require("./isNaN"); - -tape("descending(a, b) returns a positive number if a < b", (test) => { - test.ok(d3.descending(0, 1) > 0); - test.ok(d3.descending("a", "b") > 0); +it("descending(a, b) returns a positive number if a < b", () => { + assert(descending(0, 1) > 0); + assert(descending("a", "b") > 0); }); -tape("descending(a, b) returns a negative number if a > b", (test) => { - test.ok(d3.descending(1, 0) < 0); - test.ok(d3.descending("b", "a") < 0); +it("descending(a, b) returns a negative number if a > b", () => { + assert(descending(1, 0) < 0); + assert(descending("b", "a") < 0); }); -tape("descending(a, b) returns zero if a >= b and a <= b", (test) => { - test.equal(d3.descending(0, 0), 0); - test.equal(d3.descending("a", "a"), 0); - test.equal(d3.descending("0", 0), 0); - test.equal(d3.descending(0, "0"), 0); +it("descending(a, b) returns zero if a >= b and a <= b", () => { + assert.strictEqual(descending(0, 0), 0); + assert.strictEqual(descending("a", "a"), 0); + assert.strictEqual(descending("0", 0), 0); + assert.strictEqual(descending(0, "0"), 0); }); -tape("descending(a, b) returns NaN if a and b are not comparable", (test) => { - test.isNaN(d3.descending(0, undefined)); - test.isNaN(d3.descending(undefined, 0)); - test.isNaN(d3.descending(undefined, undefined)); - test.isNaN(d3.descending(0, NaN)); - test.isNaN(d3.descending(NaN, 0)); - test.isNaN(d3.descending(NaN, NaN)); +it("descending(a, b) returns NaN if a and b are not comparable", () => { + assert(isNaN(descending(0, undefined))); + assert(isNaN(descending(undefined, 0))); + assert(isNaN(descending(undefined, undefined))); + assert(isNaN(descending(0, NaN))); + assert(isNaN(descending(NaN, 0))); + assert(isNaN(descending(NaN, NaN))); }); diff --git a/test/deviation-test.js b/test/deviation-test.js index fc824ccc..3daae413 100644 --- a/test/deviation-test.js +++ b/test/deviation-test.js @@ -1,56 +1,56 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {deviation} from "../src/index.js"; -tape("deviation(array) returns the standard deviation of the specified numbers", (test) => { - test.equal(d3.deviation([5, 1, 2, 3, 4]), Math.sqrt(2.5)); - test.equal(d3.deviation([20, 3]), Math.sqrt(144.5)); - test.equal(d3.deviation([3, 20]), Math.sqrt(144.5)); +it("deviation(array) returns the standard deviation of the specified numbers", () => { + assert.strictEqual(deviation([5, 1, 2, 3, 4]), Math.sqrt(2.5)); + assert.strictEqual(deviation([20, 3]), Math.sqrt(144.5)); + assert.strictEqual(deviation([3, 20]), Math.sqrt(144.5)); }); -tape("deviation(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.deviation([NaN, 1, 2, 3, 4, 5]), Math.sqrt(2.5)); - test.equal(d3.deviation([1, 2, 3, 4, 5, NaN]), Math.sqrt(2.5)); - test.equal(d3.deviation([10, null, 3, undefined, 5, NaN]), Math.sqrt(13)); +it("deviation(array) ignores null, undefined and NaN", () => { + assert.strictEqual(deviation([NaN, 1, 2, 3, 4, 5]), Math.sqrt(2.5)); + assert.strictEqual(deviation([1, 2, 3, 4, 5, NaN]), Math.sqrt(2.5)); + assert.strictEqual(deviation([10, null, 3, undefined, 5, NaN]), Math.sqrt(13)); }); -tape("deviation(array) can handle large numbers without overflowing", (test) => { - test.equal(d3.deviation([Number.MAX_VALUE, Number.MAX_VALUE]), 0); - test.equal(d3.deviation([-Number.MAX_VALUE, -Number.MAX_VALUE]), 0); +it("deviation(array) can handle large numbers without overflowing", () => { + assert.strictEqual(deviation([Number.MAX_VALUE, Number.MAX_VALUE]), 0); + assert.strictEqual(deviation([-Number.MAX_VALUE, -Number.MAX_VALUE]), 0); }); -tape("deviation(array) returns undefined if the array has fewer than two numbers", (test) => { - test.equal(d3.deviation([1]), undefined); - test.equal(d3.deviation([]), undefined); - test.equal(d3.deviation([null]), undefined); - test.equal(d3.deviation([undefined]), undefined); - test.equal(d3.deviation([NaN]), undefined); - test.equal(d3.deviation([NaN, NaN]), undefined); +it("deviation(array) returns undefined if the array has fewer than two numbers", () => { + assert.strictEqual(deviation([1]), undefined); + assert.strictEqual(deviation([]), undefined); + assert.strictEqual(deviation([null]), undefined); + assert.strictEqual(deviation([undefined]), undefined); + assert.strictEqual(deviation([NaN]), undefined); + assert.strictEqual(deviation([NaN, NaN]), undefined); }); -tape("deviation(array, f) returns the deviation of the specified numbers", (test) => { - test.equal(d3.deviation([5, 1, 2, 3, 4].map(box), unbox), Math.sqrt(2.5)); - test.equal(d3.deviation([20, 3].map(box), unbox), Math.sqrt(144.5)); - test.equal(d3.deviation([3, 20].map(box), unbox), Math.sqrt(144.5)); +it("deviation(array, f) returns the deviation of the specified numbers", () => { + assert.strictEqual(deviation([5, 1, 2, 3, 4].map(box), unbox), Math.sqrt(2.5)); + assert.strictEqual(deviation([20, 3].map(box), unbox), Math.sqrt(144.5)); + assert.strictEqual(deviation([3, 20].map(box), unbox), Math.sqrt(144.5)); }); -tape("deviation(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.deviation([NaN, 1, 2, 3, 4, 5].map(box), unbox), Math.sqrt(2.5)); - test.equal(d3.deviation([1, 2, 3, 4, 5, NaN].map(box), unbox), Math.sqrt(2.5)); - test.equal(d3.deviation([10, null, 3, undefined, 5, NaN].map(box), unbox), Math.sqrt(13)); +it("deviation(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(deviation([NaN, 1, 2, 3, 4, 5].map(box), unbox), Math.sqrt(2.5)); + assert.strictEqual(deviation([1, 2, 3, 4, 5, NaN].map(box), unbox), Math.sqrt(2.5)); + assert.strictEqual(deviation([10, null, 3, undefined, 5, NaN].map(box), unbox), Math.sqrt(13)); }); -tape("deviation(array, f) can handle large numbers without overflowing", (test) => { - test.equal(d3.deviation([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), 0); - test.equal(d3.deviation([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), 0); +it("deviation(array, f) can handle large numbers without overflowing", () => { + assert.strictEqual(deviation([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), 0); + assert.strictEqual(deviation([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), 0); }); -tape("deviation(array, f) returns undefined if the array has fewer than two numbers", (test) => { - test.equal(d3.deviation([1].map(box), unbox), undefined); - test.equal(d3.deviation([].map(box), unbox), undefined); - test.equal(d3.deviation([null].map(box), unbox), undefined); - test.equal(d3.deviation([undefined].map(box), unbox), undefined); - test.equal(d3.deviation([NaN].map(box), unbox), undefined); - test.equal(d3.deviation([NaN, NaN].map(box), unbox), undefined); +it("deviation(array, f) returns undefined if the array has fewer than two numbers", () => { + assert.strictEqual(deviation([1].map(box), unbox), undefined); + assert.strictEqual(deviation([].map(box), unbox), undefined); + assert.strictEqual(deviation([null].map(box), unbox), undefined); + assert.strictEqual(deviation([undefined].map(box), unbox), undefined); + assert.strictEqual(deviation([NaN].map(box), unbox), undefined); + assert.strictEqual(deviation([NaN, NaN].map(box), unbox), undefined); }); function box(value) { diff --git a/test/difference-test.js b/test/difference-test.js index 9c7b7d81..e7d94b2c 100644 --- a/test/difference-test.js +++ b/test/difference-test.js @@ -1,14 +1,12 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import {difference} from "../src/index.js"; +import {assertSetEqual} from "./asserts.js"; -require("./setEqual"); - -tape("difference(values, other) returns a set of values", (test) => { - test.setEqual(d3.difference([1, 2, 3], [2, 1]), new Set([3])); - test.setEqual(d3.difference([1, 2], [2, 3, 1]), new Set([])); - test.setEqual(d3.difference([2, 1, 3], [4, 3, 1]), new Set([2])); +it("difference(values, other) returns a set of values", () => { + assertSetEqual(difference([1, 2, 3], [2, 1]), new Set([3])); + assertSetEqual(difference([1, 2], [2, 3, 1]), new Set([])); + assertSetEqual(difference([2, 1, 3], [4, 3, 1]), new Set([2])); }); -tape("difference(...values) accepts iterables", (test) => { - test.setEqual(d3.difference(new Set([1, 2, 3]), new Set([1])), new Set([2, 3])); +it("difference(...values) accepts iterables", () => { + assertSetEqual(difference(new Set([1, 2, 3]), new Set([1])), new Set([2, 3])); }); diff --git a/test/disjoint-test.js b/test/disjoint-test.js index 9c7a2e3c..c918314b 100644 --- a/test/disjoint-test.js +++ b/test/disjoint-test.js @@ -1,18 +1,18 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {disjoint} from "../src/index.js"; -tape("disjoint(values, other) returns true if sets are disjoint", (test) => { - test.equal(d3.disjoint([1], [2]), true); - test.equal(d3.disjoint([2, 3], [3, 4]), false); - test.equal(d3.disjoint([1], []), true); +it("disjoint(values, other) returns true if sets are disjoint", () => { + assert.strictEqual(disjoint([1], [2]), true); + assert.strictEqual(disjoint([2, 3], [3, 4]), false); + assert.strictEqual(disjoint([1], []), true); }); -tape("disjoint(values, other) allows values to be infinite", (test) => { - test.equal(d3.disjoint(odds(), [0, 2, 4, 5]), false); +it("disjoint(values, other) allows values to be infinite", () => { + assert.strictEqual(disjoint(odds(), [0, 2, 4, 5]), false); }); -tape("disjoint(values, other) allows other to be infinite", (test) => { - test.equal(d3.disjoint([2], repeat(1, 3, 2)), false); +it("disjoint(values, other) allows other to be infinite", () => { + assert.strictEqual(disjoint([2], repeat(1, 3, 2)), false); }); function* odds() { diff --git a/test/every-test.js b/test/every-test.js index e436bfac..da75f44b 100644 --- a/test/every-test.js +++ b/test/every-test.js @@ -1,53 +1,51 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {every} from "../src/index.js"; -tape("every(values, test) returns true if all tests pass", (test) => { - test.strictEqual(d3.every([1, 2, 3, 2, 1], x => x & 1), false); - test.strictEqual(d3.every([1, 2, 3, 2, 1], x => x >= 1), true); +it("every(values, test) returns true if all tests pass", () => { + assert.strictEqual(every([1, 2, 3, 2, 1], x => x & 1), false); + assert.strictEqual(every([1, 2, 3, 2, 1], x => x >= 1), true); }); -tape("every(values, test) returns true if values is empty", (test) => { - test.strictEqual(d3.every([], () => false), true); +it("every(values, test) returns true if values is empty", () => { + assert.strictEqual(every([], () => false), true); }); -tape("every(values, test) accepts an iterable", (test) => { - test.strictEqual(d3.every(new Set([1, 2, 3, 2, 1]), x => x >= 1), true); - test.strictEqual(d3.every((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x >= 1), true); - test.strictEqual(d3.every(Uint8Array.of(1, 2, 3, 2, 1), x => x >= 1), true); +it("every(values, test) accepts an iterable", () => { + assert.strictEqual(every(new Set([1, 2, 3, 2, 1]), x => x >= 1), true); + assert.strictEqual(every((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x >= 1), true); + assert.strictEqual(every(Uint8Array.of(1, 2, 3, 2, 1), x => x >= 1), true); }); -tape("every(values, test) enforces that test is a function", (test) => { - test.throws(() => d3.every([]), TypeError); +it("every(values, test) enforces that test is a function", () => { + assert.throws(() => every([]), TypeError); }); -tape("every(values, test) enforces that values is iterable", (test) => { - test.throws(() => d3.every({}, () => true), TypeError); +it("every(values, test) enforces that values is iterable", () => { + assert.throws(() => every({}, () => true), TypeError); }); -tape("every(values, test) passes test (value, index, values)", (test) => { +it("every(values, test) passes test (value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); - d3.every(values, function() { return calls.push([this, ...arguments]); }); - test.deepEqual(calls, [ - [global, 5, 0, values], - [global, 4, 1, values], - [global, 3, 2, values], - [global, 2, 3, values], - [global, 1, 4, values] + every(values, function() { return calls.push([this, ...arguments]); }); + assert.deepStrictEqual(calls, [ + [undefined, 5, 0, values], + [undefined, 4, 1, values], + [undefined, 3, 2, values], + [undefined, 2, 3, values], + [undefined, 1, 4, values] ]); }); -tape("every(values, test) short-circuts when test returns falsey", (test) => { +it("every(values, test) short-circuts when test returns falsey", () => { let calls = 0; - test.strictEqual(d3.every([1, 2, 3], x => (++calls, x < 2)), false); - test.strictEqual(calls, 2); - test.strictEqual(d3.every([1, 2, 3], x => (++calls, x - 2)), false); - test.strictEqual(calls, 4); + assert.strictEqual(every([1, 2, 3], x => (++calls, x < 2)), false); + assert.strictEqual(calls, 2); + assert.strictEqual(every([1, 2, 3], x => (++calls, x - 2)), false); + assert.strictEqual(calls, 4); }); -tape("every(values, test) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.every([, 1, 2,,], x => x === undefined || x >=1), true); - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.every([, 1, 2,,], x => x >=1), false); +it("every(values, test) does not skip sparse elements", () => { + assert.deepStrictEqual(every([, 1, 2,, ], x => x === undefined || x >=1), true); + assert.deepStrictEqual(every([, 1, 2,, ], x => x >=1), false); }); diff --git a/test/extent-test.js b/test/extent-test.js index 68458248..52f93570 100644 --- a/test/extent-test.js +++ b/test/extent-test.js @@ -1,93 +1,93 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {extent} from "../src/index.js"; -tape("extent(array) returns the least and greatest numeric values for numbers", (test) => { - test.deepEqual(d3.extent([1]), [1, 1]); - test.deepEqual(d3.extent([5, 1, 2, 3, 4]), [1, 5]); - test.deepEqual(d3.extent([20, 3]), [3, 20]); - test.deepEqual(d3.extent([3, 20]), [3, 20]); +it("extent(array) returns the least and greatest numeric values for numbers", () => { + assert.deepStrictEqual(extent([1]), [1, 1]); + assert.deepStrictEqual(extent([5, 1, 2, 3, 4]), [1, 5]); + assert.deepStrictEqual(extent([20, 3]), [3, 20]); + assert.deepStrictEqual(extent([3, 20]), [3, 20]); }); -tape("extent(array) returns the least and greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.extent(["c", "a", "b"]), ["a", "c"]); - test.deepEqual(d3.extent(["20", "3"]), ["20", "3"]); - test.deepEqual(d3.extent(["3", "20"]), ["20", "3"]); +it("extent(array) returns the least and greatest lexicographic value for strings", () => { + assert.deepStrictEqual(extent(["c", "a", "b"]), ["a", "c"]); + assert.deepStrictEqual(extent(["20", "3"]), ["20", "3"]); + assert.deepStrictEqual(extent(["3", "20"]), ["20", "3"]); }); -tape("extent(array) ignores null, undefined and NaN", (test) => { +it("extent(array) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.extent([NaN, 1, 2, 3, 4, 5]), [1, 5]); - test.deepEqual(d3.extent([o, 1, 2, 3, 4, 5]), [1, 5]); - test.deepEqual(d3.extent([1, 2, 3, 4, 5, NaN]), [1, 5]); - test.deepEqual(d3.extent([1, 2, 3, 4, 5, o]), [1, 5]); - test.deepEqual(d3.extent([10, null, 3, undefined, 5, NaN]), [3, 10]); - test.deepEqual(d3.extent([-1, null, -3, undefined, -5, NaN]), [-5, -1]); + assert.deepStrictEqual(extent([NaN, 1, 2, 3, 4, 5]), [1, 5]); + assert.deepStrictEqual(extent([o, 1, 2, 3, 4, 5]), [1, 5]); + assert.deepStrictEqual(extent([1, 2, 3, 4, 5, NaN]), [1, 5]); + assert.deepStrictEqual(extent([1, 2, 3, 4, 5, o]), [1, 5]); + assert.deepStrictEqual(extent([10, null, 3, undefined, 5, NaN]), [3, 10]); + assert.deepStrictEqual(extent([-1, null, -3, undefined, -5, NaN]), [-5, -1]); }); -tape("extent(array) compares heterogenous types as numbers", (test) => { - test.deepEqual(d3.extent([20, "3"]), ["3", 20]); - test.deepEqual(d3.extent(["20", 3]), [3, "20"]); - test.deepEqual(d3.extent([3, "20"]), [3, "20"]); - test.deepEqual(d3.extent(["3", 20]), ["3", 20]); +it("extent(array) compares heterogenous types as numbers", () => { + assert.deepStrictEqual(extent([20, "3"]), ["3", 20]); + assert.deepStrictEqual(extent(["20", 3]), [3, "20"]); + assert.deepStrictEqual(extent([3, "20"]), [3, "20"]); + assert.deepStrictEqual(extent(["3", 20]), ["3", 20]); }); -tape("extent(array) returns undefined if the array contains no numbers", (test) => { - test.deepEqual(d3.extent([]), [undefined, undefined]); - test.deepEqual(d3.extent([null]), [undefined, undefined]); - test.deepEqual(d3.extent([undefined]), [undefined, undefined]); - test.deepEqual(d3.extent([NaN]), [undefined, undefined]); - test.deepEqual(d3.extent([NaN, NaN]), [undefined, undefined]); +it("extent(array) returns undefined if the array contains no numbers", () => { + assert.deepStrictEqual(extent([]), [undefined, undefined]); + assert.deepStrictEqual(extent([null]), [undefined, undefined]); + assert.deepStrictEqual(extent([undefined]), [undefined, undefined]); + assert.deepStrictEqual(extent([NaN]), [undefined, undefined]); + assert.deepStrictEqual(extent([NaN, NaN]), [undefined, undefined]); }); -tape("extent(array, f) returns the least and greatest numeric value for numbers", (test) => { - test.deepEqual(d3.extent([1].map(box), unbox), [1, 1]); - test.deepEqual(d3.extent([5, 1, 2, 3, 4].map(box), unbox), [1, 5]); - test.deepEqual(d3.extent([20, 3].map(box), unbox), [3, 20]); - test.deepEqual(d3.extent([3, 20].map(box), unbox), [3, 20]); +it("extent(array, f) returns the least and greatest numeric value for numbers", () => { + assert.deepStrictEqual(extent([1].map(box), unbox), [1, 1]); + assert.deepStrictEqual(extent([5, 1, 2, 3, 4].map(box), unbox), [1, 5]); + assert.deepStrictEqual(extent([20, 3].map(box), unbox), [3, 20]); + assert.deepStrictEqual(extent([3, 20].map(box), unbox), [3, 20]); }); -tape("extent(array, f) returns the least and greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.extent(["c", "a", "b"].map(box), unbox), ["a", "c"]); - test.deepEqual(d3.extent(["20", "3"].map(box), unbox), ["20", "3"]); - test.deepEqual(d3.extent(["3", "20"].map(box), unbox), ["20", "3"]); +it("extent(array, f) returns the least and greatest lexicographic value for strings", () => { + assert.deepStrictEqual(extent(["c", "a", "b"].map(box), unbox), ["a", "c"]); + assert.deepStrictEqual(extent(["20", "3"].map(box), unbox), ["20", "3"]); + assert.deepStrictEqual(extent(["3", "20"].map(box), unbox), ["20", "3"]); }); -tape("extent(array, f) ignores null, undefined and NaN", (test) => { +it("extent(array, f) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.extent([NaN, 1, 2, 3, 4, 5].map(box), unbox), [1, 5]); - test.deepEqual(d3.extent([o, 1, 2, 3, 4, 5].map(box), unbox), [1, 5]); - test.deepEqual(d3.extent([1, 2, 3, 4, 5, NaN].map(box), unbox), [1, 5]); - test.deepEqual(d3.extent([1, 2, 3, 4, 5, o].map(box), unbox), [1, 5]); - test.deepEqual(d3.extent([10, null, 3, undefined, 5, NaN].map(box), unbox), [3, 10]); - test.deepEqual(d3.extent([-1, null, -3, undefined, -5, NaN].map(box), unbox), [-5, -1]); + assert.deepStrictEqual(extent([NaN, 1, 2, 3, 4, 5].map(box), unbox), [1, 5]); + assert.deepStrictEqual(extent([o, 1, 2, 3, 4, 5].map(box), unbox), [1, 5]); + assert.deepStrictEqual(extent([1, 2, 3, 4, 5, NaN].map(box), unbox), [1, 5]); + assert.deepStrictEqual(extent([1, 2, 3, 4, 5, o].map(box), unbox), [1, 5]); + assert.deepStrictEqual(extent([10, null, 3, undefined, 5, NaN].map(box), unbox), [3, 10]); + assert.deepStrictEqual(extent([-1, null, -3, undefined, -5, NaN].map(box), unbox), [-5, -1]); }); -tape("extent(array, f) compares heterogenous types as numbers", (test) => { - test.deepEqual(d3.extent([20, "3"].map(box), unbox), ["3", 20]); - test.deepEqual(d3.extent(["20", 3].map(box), unbox), [3, "20"]); - test.deepEqual(d3.extent([3, "20"].map(box), unbox), [3, "20"]); - test.deepEqual(d3.extent(["3", 20].map(box), unbox), ["3", 20]); +it("extent(array, f) compares heterogenous types as numbers", () => { + assert.deepStrictEqual(extent([20, "3"].map(box), unbox), ["3", 20]); + assert.deepStrictEqual(extent(["20", 3].map(box), unbox), [3, "20"]); + assert.deepStrictEqual(extent([3, "20"].map(box), unbox), [3, "20"]); + assert.deepStrictEqual(extent(["3", 20].map(box), unbox), ["3", 20]); }); -tape("extent(array, f) returns undefined if the array contains no observed values", (test) => { - test.deepEqual(d3.extent([].map(box), unbox), [undefined, undefined]); - test.deepEqual(d3.extent([null].map(box), unbox), [undefined, undefined]); - test.deepEqual(d3.extent([undefined].map(box), unbox), [undefined, undefined]); - test.deepEqual(d3.extent([NaN].map(box), unbox), [undefined, undefined]); - test.deepEqual(d3.extent([NaN, NaN].map(box), unbox), [undefined, undefined]); +it("extent(array, f) returns undefined if the array contains no observed values", () => { + assert.deepStrictEqual(extent([].map(box), unbox), [undefined, undefined]); + assert.deepStrictEqual(extent([null].map(box), unbox), [undefined, undefined]); + assert.deepStrictEqual(extent([undefined].map(box), unbox), [undefined, undefined]); + assert.deepStrictEqual(extent([NaN].map(box), unbox), [undefined, undefined]); + assert.deepStrictEqual(extent([NaN, NaN].map(box), unbox), [undefined, undefined]); }); -tape("extent(array, f) passes the accessor d, i, and array", (test) => { +it("extent(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.extent(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + extent(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("extent(array, f) uses the global context", (test) => { +it("extent(array, f) uses the undefined context", () => { const results = []; - d3.extent([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + extent([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/fcumsum-test.js b/test/fcumsum-test.js index b52b7139..07fd4685 100644 --- a/test/fcumsum-test.js +++ b/test/fcumsum-test.js @@ -1,100 +1,100 @@ -const tape = require("tape-await"); -const d3 = require("../"); - -tape("fcumsum(array) returns a Float64Array of the expected length", (test) => { - const A = [.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]; - const R = d3.cumsum(A); - test.true(R instanceof Float64Array); - test.equal(R.length, A.length); +import assert from "assert"; +import {cumsum, fcumsum} from "../src/index.js"; + +it("fcumsum(array) returns a Float64Array of the expected length", () => { + const A = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]; + const R = cumsum(A); + assert(R instanceof Float64Array); + assert.strictEqual(R.length, A.length); }); -tape("fcumsum(array) is an exact cumsum", (test) => { - test.equal(lastc([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]), 1); - test.equal(lastc([.3, .3, .3, .3, .3, .3, .3, .3, .3, .3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3]), 0); - test.equal(lastc(["20", "3"].map(box), unbox), 23); +it("fcumsum(array) is an exact cumsum", () => { + assert.strictEqual(lastc([0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]), 1); + assert.strictEqual(lastc([0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, -0.3, -0.3, -0.3, -0.3, -0.3, -0.3, -0.3, -0.3, -0.3, -0.3]), 0); + assert.strictEqual(lastc(["20", "3"].map(box), unbox), 23); }); -tape("fcumsum(array) returns the fsum of the specified numbers", (test) => { - test.equal(lastc([1]), 1); - test.equal(lastc([5, 1, 2, 3, 4]), 15); - test.equal(lastc([20, 3]), 23); - test.equal(lastc([3, 20]), 23); +it("fcumsum(array) returns the fsum of the specified numbers", () => { + assert.strictEqual(lastc([1]), 1); + assert.strictEqual(lastc([5, 1, 2, 3, 4]), 15); + assert.strictEqual(lastc([20, 3]), 23); + assert.strictEqual(lastc([3, 20]), 23); }); -tape("fcumsum(array) observes values that can be coerced to numbers", (test) => { - test.equal(lastc(["20", "3"]), 23); - test.equal(lastc(["3", "20"]), 23); - test.equal(lastc(["3", 20]), 23); - test.equal(lastc([20, "3"]), 23); - test.equal(lastc([3, "20"]), 23); - test.equal(lastc(["20", 3]), 23); +it("fcumsum(array) observes values that can be coerced to numbers", () => { + assert.strictEqual(lastc(["20", "3"]), 23); + assert.strictEqual(lastc(["3", "20"]), 23); + assert.strictEqual(lastc(["3", 20]), 23); + assert.strictEqual(lastc([20, "3"]), 23); + assert.strictEqual(lastc([3, "20"]), 23); + assert.strictEqual(lastc(["20", 3]), 23); }); -tape("fcumsum(array) ignores non-numeric values", (test) => { - test.equal(lastc(["a", "b", "c"]), 0); - test.equal(lastc(["a", 1, "2"]), 3); +it("fcumsum(array) ignores non-numeric values", () => { + assert.strictEqual(lastc(["a", "b", "c"]), 0); + assert.strictEqual(lastc(["a", 1, "2"]), 3); }); -tape("fcumsum(array) ignores null, undefined and NaN", (test) => { - test.equal(lastc([NaN, 1, 2, 3, 4, 5]), 15); - test.equal(lastc([1, 2, 3, 4, 5, NaN]), 15); - test.equal(lastc([10, null, 3, undefined, 5, NaN]), 18); +it("fcumsum(array) ignores null, undefined and NaN", () => { + assert.strictEqual(lastc([NaN, 1, 2, 3, 4, 5]), 15); + assert.strictEqual(lastc([1, 2, 3, 4, 5, NaN]), 15); + assert.strictEqual(lastc([10, null, 3, undefined, 5, NaN]), 18); }); -tape("fcumsum(array) returns the an array of zeros if there are no numbers", (test) => { - test.deepEqual(d3.fcumsum([]), []); - test.deepEqual(d3.fcumsum([NaN]), [0]); - test.deepEqual(d3.fcumsum([undefined]), [0]); - test.deepEqual(d3.fcumsum([undefined, NaN]), [0, 0]); - test.deepEqual(d3.fcumsum([undefined, NaN, {}]), [0, 0, 0]); +it("fcumsum(array) returns an array of zeros if there are no numbers", () => { + assert.deepStrictEqual(Array.from(fcumsum([])), []); + assert.deepStrictEqual(Array.from(fcumsum([NaN])), [0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined])), [0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined, NaN])), [0, 0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined, NaN, {}])), [0, 0, 0]); }); -tape("fcumsum(array, f) returns the fsum of the specified numbers", (test) => { - test.equal(lastc([1].map(box), unbox), 1); - test.equal(lastc([5, 1, 2, 3, 4].map(box), unbox), 15); - test.equal(lastc([20, 3].map(box), unbox), 23); - test.equal(lastc([3, 20].map(box), unbox), 23); +it("fcumsum(array, f) returns the fsum of the specified numbers", () => { + assert.strictEqual(lastc([1].map(box), unbox), 1); + assert.strictEqual(lastc([5, 1, 2, 3, 4].map(box), unbox), 15); + assert.strictEqual(lastc([20, 3].map(box), unbox), 23); + assert.strictEqual(lastc([3, 20].map(box), unbox), 23); }); -tape("fcumsum(array, f) observes values that can be coerced to numbers", (test) => { - test.equal(lastc(["20", "3"].map(box), unbox), 23); - test.equal(lastc(["3", "20"].map(box), unbox), 23); - test.equal(lastc(["3", 20].map(box), unbox), 23); - test.equal(lastc([20, "3"].map(box), unbox), 23); - test.equal(lastc([3, "20"].map(box), unbox), 23); - test.equal(lastc(["20", 3].map(box), unbox), 23); +it("fcumsum(array, f) observes values that can be coerced to numbers", () => { + assert.strictEqual(lastc(["20", "3"].map(box), unbox), 23); + assert.strictEqual(lastc(["3", "20"].map(box), unbox), 23); + assert.strictEqual(lastc(["3", 20].map(box), unbox), 23); + assert.strictEqual(lastc([20, "3"].map(box), unbox), 23); + assert.strictEqual(lastc([3, "20"].map(box), unbox), 23); + assert.strictEqual(lastc(["20", 3].map(box), unbox), 23); }); -tape("fcumsum(array, f) ignores non-numeric values", (test) => { - test.equal(lastc(["a", "b", "c"].map(box), unbox), 0); - test.equal(lastc(["a", 1, "2"].map(box), unbox), 3); +it("fcumsum(array, f) ignores non-numeric values", () => { + assert.strictEqual(lastc(["a", "b", "c"].map(box), unbox), 0); + assert.strictEqual(lastc(["a", 1, "2"].map(box), unbox), 3); }); -tape("fcumsum(array, f) ignores null, undefined and NaN", (test) => { - test.equal(lastc([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); - test.equal(lastc([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); - test.equal(lastc([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); +it("fcumsum(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(lastc([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); + assert.strictEqual(lastc([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); + assert.strictEqual(lastc([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); }); -tape("fcumsum(array, f) returns zero if there are no numbers", (test) => { - test.deepEqual(d3.fcumsum([].map(box), unbox), []); - test.deepEqual(d3.fcumsum([NaN].map(box), unbox), [0]); - test.deepEqual(d3.fcumsum([undefined].map(box), unbox), [0]); - test.deepEqual(d3.fcumsum([undefined, NaN].map(box), unbox), [0, 0]); - test.deepEqual(d3.fcumsum([undefined, NaN, {}].map(box), unbox), [0, 0, 0]); +it("fcumsum(array, f) returns zero if there are no numbers", () => { + assert.deepStrictEqual(Array.from(fcumsum([].map(box), unbox)), []); + assert.deepStrictEqual(Array.from(fcumsum([NaN].map(box), unbox)), [0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined].map(box), unbox)), [0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined, NaN].map(box), unbox)), [0, 0]); + assert.deepStrictEqual(Array.from(fcumsum([undefined, NaN, {}].map(box), unbox)), [0, 0, 0]); }); -tape("fcumsum(array, f) passes the accessor d, i, and array", (test) => { +it("fcumsum(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; lastc(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("fcumsum(array, f) uses the global context", (test) => { +it("fcumsum(array, f) uses the undefined context", () => { const results = []; lastc([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { @@ -106,6 +106,6 @@ function unbox(box) { } function lastc(values, valueof) { - const array = d3.fcumsum(values, valueof); + const array = fcumsum(values, valueof); return array[array.length -1]; -} \ No newline at end of file +} diff --git a/test/filter-test.js b/test/filter-test.js index 2082ea59..38418294 100644 --- a/test/filter-test.js +++ b/test/filter-test.js @@ -1,41 +1,40 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import * as d3 from "../src/index.js"; -tape("filter(values, test) returns the values that pass the test", (test) => { - test.deepEqual(d3.filter([1, 2, 3, 2, 1], x => x & 1), [1, 3, 1]); +it("filter(values, test) returns the values that pass the test", () => { + assert.deepStrictEqual(d3.filter([1, 2, 3, 2, 1], x => x & 1), [1, 3, 1]); }); -tape("filter(values, test) accepts an iterable", (test) => { - test.deepEqual(d3.filter(new Set([1, 2, 3, 2, 1]), x => x & 1), [1, 3]); - test.deepEqual(d3.filter((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x & 1), [1, 3, 1]); +it("filter(values, test) accepts an iterable", () => { + assert.deepStrictEqual(d3.filter(new Set([1, 2, 3, 2, 1]), x => x & 1), [1, 3]); + assert.deepStrictEqual(d3.filter((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x & 1), [1, 3, 1]); }); -tape("filter(values, test) accepts a typed array", (test) => { - test.deepEqual(d3.filter(Uint8Array.of(1, 2, 3, 2, 1), x => x & 1), [1, 3, 1]); +it("filter(values, test) accepts a typed array", () => { + assert.deepStrictEqual(d3.filter(Uint8Array.of(1, 2, 3, 2, 1), x => x & 1), [1, 3, 1]); }); -tape("filter(values, test) enforces that test is a function", (test) => { - test.throws(() => d3.filter([]), TypeError); +it("filter(values, test) enforces that test is a function", () => { + assert.throws(() => d3.filter([]), TypeError); }); -tape("filter(values, test) enforces that values is iterable", (test) => { - test.throws(() => d3.filter({}, () => true), TypeError); +it("filter(values, test) enforces that values is iterable", () => { + assert.throws(() => d3.filter({}, () => true), TypeError); }); -tape("filter(values, test) passes test (value, index, values)", (test) => { +it("filter(values, test) passes test (value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); d3.filter(values, function() { calls.push([this, ...arguments]); }); - test.deepEqual(calls, [ - [global, 5, 0, values], - [global, 4, 1, values], - [global, 3, 2, values], - [global, 2, 3, values], - [global, 1, 4, values] + assert.deepStrictEqual(calls, [ + [undefined, 5, 0, values], + [undefined, 4, 1, values], + [undefined, 3, 2, values], + [undefined, 2, 3, values], + [undefined, 1, 4, values] ]); }); -tape("filter(values, test) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.filter([, 1, 2,,], () => true), [undefined, 1, 2, undefined]); +it("filter(values, test) does not skip sparse elements", () => { + assert.deepStrictEqual(d3.filter([, 1, 2,, ], () => true), [undefined, 1, 2, undefined]); }); diff --git a/test/fsum-test.js b/test/fsum-test.js index 0f24ee56..62a3b039 100644 --- a/test/fsum-test.js +++ b/test/fsum-test.js @@ -1,105 +1,105 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {Adder, fsum} from "../src/index.js"; -tape("new Adder() returns an Adder", (test) => { - test.equal(typeof new d3.Adder().add, "function"); - test.equal(typeof new d3.Adder().valueOf, "function"); +it("new Adder() returns an Adder", () => { + assert.strictEqual(typeof new Adder().add, "function"); + assert.strictEqual(typeof new Adder().valueOf, "function"); }); -tape("+adder can be applied several times", (test) => { - const adder = new d3.Adder(); +it("+adder can be applied several times", () => { + const adder = new Adder(); for (let i = 0; i < 10; ++i) adder.add(0.1); - test.equal(+adder, 1); - test.equal(+adder, 1); + assert.strictEqual(+adder, 1); + assert.strictEqual(+adder, 1); }); -tape("fsum(array) is an exact sum", (test) => { - test.equal(d3.fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]), 1); - test.equal(d3.fsum([.3, .3, .3, .3, .3, .3, .3, .3, .3, .3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3]), 0); - test.equal(d3.fsum(["20", "3"].map(box), unbox), 23); +it("fsum(array) is an exact sum", () => { + assert.strictEqual(fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]), 1); + assert.strictEqual(fsum([.3, .3, .3, .3, .3, .3, .3, .3, .3, .3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3, -.3]), 0); + assert.strictEqual(fsum(["20", "3"].map(box), unbox), 23); }); -tape("fsum(array) returns the fsum of the specified numbers", (test) => { - test.equal(d3.fsum([1]), 1); - test.equal(d3.fsum([5, 1, 2, 3, 4]), 15); - test.equal(d3.fsum([20, 3]), 23); - test.equal(d3.fsum([3, 20]), 23); +it("fsum(array) returns the fsum of the specified numbers", () => { + assert.strictEqual(fsum([1]), 1); + assert.strictEqual(fsum([5, 1, 2, 3, 4]), 15); + assert.strictEqual(fsum([20, 3]), 23); + assert.strictEqual(fsum([3, 20]), 23); }); -tape("fsum(array) observes values that can be coerced to numbers", (test) => { - test.equal(d3.fsum(["20", "3"]), 23); - test.equal(d3.fsum(["3", "20"]), 23); - test.equal(d3.fsum(["3", 20]), 23); - test.equal(d3.fsum([20, "3"]), 23); - test.equal(d3.fsum([3, "20"]), 23); - test.equal(d3.fsum(["20", 3]), 23); +it("fsum(array) observes values that can be coerced to numbers", () => { + assert.strictEqual(fsum(["20", "3"]), 23); + assert.strictEqual(fsum(["3", "20"]), 23); + assert.strictEqual(fsum(["3", 20]), 23); + assert.strictEqual(fsum([20, "3"]), 23); + assert.strictEqual(fsum([3, "20"]), 23); + assert.strictEqual(fsum(["20", 3]), 23); }); -tape("fsum(array) ignores non-numeric values", (test) => { - test.equal(d3.fsum(["a", "b", "c"]), 0); - test.equal(d3.fsum(["a", 1, "2"]), 3); +it("fsum(array) ignores non-numeric values", () => { + assert.strictEqual(fsum(["a", "b", "c"]), 0); + assert.strictEqual(fsum(["a", 1, "2"]), 3); }); -tape("fsum(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.fsum([NaN, 1, 2, 3, 4, 5]), 15); - test.equal(d3.fsum([1, 2, 3, 4, 5, NaN]), 15); - test.equal(d3.fsum([10, null, 3, undefined, 5, NaN]), 18); +it("fsum(array) ignores null, undefined and NaN", () => { + assert.strictEqual(fsum([NaN, 1, 2, 3, 4, 5]), 15); + assert.strictEqual(fsum([1, 2, 3, 4, 5, NaN]), 15); + assert.strictEqual(fsum([10, null, 3, undefined, 5, NaN]), 18); }); -tape("fsum(array) returns zero if there are no numbers", (test) => { - test.equal(d3.fsum([]), 0); - test.equal(d3.fsum([NaN]), 0); - test.equal(d3.fsum([undefined]), 0); - test.equal(d3.fsum([undefined, NaN]), 0); - test.equal(d3.fsum([undefined, NaN, {}]), 0); +it("fsum(array) returns zero if there are no numbers", () => { + assert.strictEqual(fsum([]), 0); + assert.strictEqual(fsum([NaN]), 0); + assert.strictEqual(fsum([undefined]), 0); + assert.strictEqual(fsum([undefined, NaN]), 0); + assert.strictEqual(fsum([undefined, NaN, {}]), 0); }); -tape("fsum(array, f) returns the fsum of the specified numbers", (test) => { - test.equal(d3.fsum([1].map(box), unbox), 1); - test.equal(d3.fsum([5, 1, 2, 3, 4].map(box), unbox), 15); - test.equal(d3.fsum([20, 3].map(box), unbox), 23); - test.equal(d3.fsum([3, 20].map(box), unbox), 23); +it("fsum(array, f) returns the fsum of the specified numbers", () => { + assert.strictEqual(fsum([1].map(box), unbox), 1); + assert.strictEqual(fsum([5, 1, 2, 3, 4].map(box), unbox), 15); + assert.strictEqual(fsum([20, 3].map(box), unbox), 23); + assert.strictEqual(fsum([3, 20].map(box), unbox), 23); }); -tape("fsum(array, f) observes values that can be coerced to numbers", (test) => { - test.equal(d3.fsum(["20", "3"].map(box), unbox), 23); - test.equal(d3.fsum(["3", "20"].map(box), unbox), 23); - test.equal(d3.fsum(["3", 20].map(box), unbox), 23); - test.equal(d3.fsum([20, "3"].map(box), unbox), 23); - test.equal(d3.fsum([3, "20"].map(box), unbox), 23); - test.equal(d3.fsum(["20", 3].map(box), unbox), 23); +it("fsum(array, f) observes values that can be coerced to numbers", () => { + assert.strictEqual(fsum(["20", "3"].map(box), unbox), 23); + assert.strictEqual(fsum(["3", "20"].map(box), unbox), 23); + assert.strictEqual(fsum(["3", 20].map(box), unbox), 23); + assert.strictEqual(fsum([20, "3"].map(box), unbox), 23); + assert.strictEqual(fsum([3, "20"].map(box), unbox), 23); + assert.strictEqual(fsum(["20", 3].map(box), unbox), 23); }); -tape("fsum(array, f) ignores non-numeric values", (test) => { - test.equal(d3.fsum(["a", "b", "c"].map(box), unbox), 0); - test.equal(d3.fsum(["a", 1, "2"].map(box), unbox), 3); +it("fsum(array, f) ignores non-numeric values", () => { + assert.strictEqual(fsum(["a", "b", "c"].map(box), unbox), 0); + assert.strictEqual(fsum(["a", 1, "2"].map(box), unbox), 3); }); -tape("fsum(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.fsum([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); - test.equal(d3.fsum([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); - test.equal(d3.fsum([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); +it("fsum(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(fsum([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); + assert.strictEqual(fsum([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); + assert.strictEqual(fsum([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); }); -tape("fsum(array, f) returns zero if there are no numbers", (test) => { - test.equal(d3.fsum([].map(box), unbox), 0); - test.equal(d3.fsum([NaN].map(box), unbox), 0); - test.equal(d3.fsum([undefined].map(box), unbox), 0); - test.equal(d3.fsum([undefined, NaN].map(box), unbox), 0); - test.equal(d3.fsum([undefined, NaN, {}].map(box), unbox), 0); +it("fsum(array, f) returns zero if there are no numbers", () => { + assert.strictEqual(fsum([].map(box), unbox), 0); + assert.strictEqual(fsum([NaN].map(box), unbox), 0); + assert.strictEqual(fsum([undefined].map(box), unbox), 0); + assert.strictEqual(fsum([undefined, NaN].map(box), unbox), 0); + assert.strictEqual(fsum([undefined, NaN, {}].map(box), unbox), 0); }); -tape("fsum(array, f) passes the accessor d, i, and array", (test) => { +it("fsum(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.fsum(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + fsum(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("fsum(array, f) uses the global context", (test) => { +it("fsum(array, f) uses the undefined context", () => { const results = []; - d3.fsum([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + fsum([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/greatest-test.js b/test/greatest-test.js index 38b958a5..229e0ee5 100644 --- a/test/greatest-test.js +++ b/test/greatest-test.js @@ -1,49 +1,49 @@ -const tape = require("tape-await"); -const d3 = require("../"); - -tape("greatest(array) compares using natural order", (test) => { - test.strictEqual(d3.greatest([0, 1]), 1); - test.strictEqual(d3.greatest([1, 0]), 1); - test.strictEqual(d3.greatest([0, "1"]), "1"); - test.strictEqual(d3.greatest(["1", 0]), "1"); - test.strictEqual(d3.greatest(["10", "2"]), "2"); - test.strictEqual(d3.greatest(["2", "10"]), "2"); - test.strictEqual(d3.greatest(["10", "2", NaN]), "2"); - test.strictEqual(d3.greatest([NaN, "10", "2"]), "2"); - test.strictEqual(d3.greatest(["2", NaN, "10"]), "2"); - test.strictEqual(d3.greatest([2, NaN, 10]), 10); - test.strictEqual(d3.greatest([10, 2, NaN]), 10); - test.strictEqual(d3.greatest([NaN, 10, 2]), 10); +import assert from "assert"; +import {descending, greatest} from "../src/index.js"; + +it("greatest(array) compares using natural order", () => { + assert.strictEqual(greatest([0, 1]), 1); + assert.strictEqual(greatest([1, 0]), 1); + assert.strictEqual(greatest([0, "1"]), "1"); + assert.strictEqual(greatest(["1", 0]), "1"); + assert.strictEqual(greatest(["10", "2"]), "2"); + assert.strictEqual(greatest(["2", "10"]), "2"); + assert.strictEqual(greatest(["10", "2", NaN]), "2"); + assert.strictEqual(greatest([NaN, "10", "2"]), "2"); + assert.strictEqual(greatest(["2", NaN, "10"]), "2"); + assert.strictEqual(greatest([2, NaN, 10]), 10); + assert.strictEqual(greatest([10, 2, NaN]), 10); + assert.strictEqual(greatest([NaN, 10, 2]), 10); }); -tape("greatest(array, compare) compares using the specified compare function", (test) => { - var a = {name: "a"}, b = {name: "b"}; - test.deepEqual(d3.greatest([a, b], (a, b) => a.name.localeCompare(b.name)), {name: "b"}); - test.strictEqual(d3.greatest([1, 0], d3.descending), 0); - test.strictEqual(d3.greatest(["1", 0], d3.descending), 0); - test.strictEqual(d3.greatest(["2", "10"], d3.descending), "10"); - test.strictEqual(d3.greatest(["2", NaN, "10"], d3.descending), "10"); - test.strictEqual(d3.greatest([2, NaN, 10], d3.descending), 2); +it("greatest(array, compare) compares using the specified compare function", () => { + const a = {name: "a"}, b = {name: "b"}; + assert.deepStrictEqual(greatest([a, b], (a, b) => a.name.localeCompare(b.name)), {name: "b"}); + assert.strictEqual(greatest([1, 0], descending), 0); + assert.strictEqual(greatest(["1", 0], descending), 0); + assert.strictEqual(greatest(["2", "10"], descending), "10"); + assert.strictEqual(greatest(["2", NaN, "10"], descending), "10"); + assert.strictEqual(greatest([2, NaN, 10], descending), 2); }); -tape("greatest(array, accessor) uses the specified accessor function", (test) => { - var a = {name: "a", v: 42}, b = {name: "b", v: 0.42}; - test.deepEqual(d3.greatest([a, b], d => d.name), b); - test.deepEqual(d3.greatest([a, b], d => d.v), a); +it("greatest(array, accessor) uses the specified accessor function", () => { + const a = {name: "a", v: 42}, b = {name: "b", v: 0.42}; + assert.deepStrictEqual(greatest([a, b], d => d.name), b); + assert.deepStrictEqual(greatest([a, b], d => d.v), a); }); -tape("greatest(array) returns undefined if the array is empty", (test) => { - test.strictEqual(d3.greatest([]), undefined); +it("greatest(array) returns undefined if the array is empty", () => { + assert.strictEqual(greatest([]), undefined); }); -tape("greatest(array) returns undefined if the array contains only incomparable values", (test) => { - test.strictEqual(d3.greatest([NaN, undefined]), undefined); - test.strictEqual(d3.greatest([NaN, "foo"], (a, b) => a - b), undefined); +it("greatest(array) returns undefined if the array contains only incomparable values", () => { + assert.strictEqual(greatest([NaN, undefined]), undefined); + assert.strictEqual(greatest([NaN, "foo"], (a, b) => a - b), undefined); }); -tape("greatest(array) returns the first of equal values", (test) => { - test.deepEqual(d3.greatest([2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), descendingValue), {value: 0, index: 4}); - test.deepEqual(d3.greatest([3, 2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), ascendingValue), {value: 3, index: 0}); +it("greatest(array) returns the first of equal values", () => { + assert.deepStrictEqual(greatest([2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), descendingValue), {value: 0, index: 4}); + assert.deepStrictEqual(greatest([3, 2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), ascendingValue), {value: 3, index: 0}); }); function box(value, index) { diff --git a/test/greatestIndex-test.js b/test/greatestIndex-test.js index 845ddb6c..25948d6c 100644 --- a/test/greatestIndex-test.js +++ b/test/greatestIndex-test.js @@ -1,47 +1,47 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {ascending, descending, greatestIndex} from "../src/index.js"; -tape("greatestIndex(array) compares using natural order", (test) => { - test.strictEqual(d3.greatestIndex([0, 1]), 1); - test.strictEqual(d3.greatestIndex([1, 0]), 0); - test.strictEqual(d3.greatestIndex([0, "1"]), 1); - test.strictEqual(d3.greatestIndex(["1", 0]), 0); - test.strictEqual(d3.greatestIndex(["10", "2"]), 1); - test.strictEqual(d3.greatestIndex(["2", "10"]), 0); - test.strictEqual(d3.greatestIndex(["10", "2", NaN]), 1); - test.strictEqual(d3.greatestIndex([NaN, "10", "2"]), 2); - test.strictEqual(d3.greatestIndex(["2", NaN, "10"]), 0); - test.strictEqual(d3.greatestIndex([2, NaN, 10]), 2); - test.strictEqual(d3.greatestIndex([10, 2, NaN]), 0); - test.strictEqual(d3.greatestIndex([NaN, 10, 2]), 1); +it("greatestIndex(array) compares using natural order", () => { + assert.strictEqual(greatestIndex([0, 1]), 1); + assert.strictEqual(greatestIndex([1, 0]), 0); + assert.strictEqual(greatestIndex([0, "1"]), 1); + assert.strictEqual(greatestIndex(["1", 0]), 0); + assert.strictEqual(greatestIndex(["10", "2"]), 1); + assert.strictEqual(greatestIndex(["2", "10"]), 0); + assert.strictEqual(greatestIndex(["10", "2", NaN]), 1); + assert.strictEqual(greatestIndex([NaN, "10", "2"]), 2); + assert.strictEqual(greatestIndex(["2", NaN, "10"]), 0); + assert.strictEqual(greatestIndex([2, NaN, 10]), 2); + assert.strictEqual(greatestIndex([10, 2, NaN]), 0); + assert.strictEqual(greatestIndex([NaN, 10, 2]), 1); }); -tape("greatestIndex(array, compare) compares using the specified compare function", (test) => { +it("greatestIndex(array, compare) compares using the specified compare function", () => { const a = {name: "a"}, b = {name: "b"}; - test.strictEqual(d3.greatestIndex([a, b], (a, b) => a.name.localeCompare(b.name)), 1); - test.strictEqual(d3.greatestIndex([1, 0], d3.ascending), 0); - test.strictEqual(d3.greatestIndex(["1", 0], d3.ascending), 0); - test.strictEqual(d3.greatestIndex(["2", "10"], d3.ascending), 0); - test.strictEqual(d3.greatestIndex(["2", NaN, "10"], d3.ascending), 0); - test.strictEqual(d3.greatestIndex([2, NaN, 10], d3.ascending), 2); + assert.strictEqual(greatestIndex([a, b], (a, b) => a.name.localeCompare(b.name)), 1); + assert.strictEqual(greatestIndex([1, 0], ascending), 0); + assert.strictEqual(greatestIndex(["1", 0], ascending), 0); + assert.strictEqual(greatestIndex(["2", "10"], ascending), 0); + assert.strictEqual(greatestIndex(["2", NaN, "10"], ascending), 0); + assert.strictEqual(greatestIndex([2, NaN, 10], ascending), 2); }); -tape("greatestIndex(array, accessor) uses the specified accessor function", (test) => { +it("greatestIndex(array, accessor) uses the specified accessor function", () => { const a = {name: "a", v: 42}, b = {name: "b", v: 0.42}; - test.deepEqual(d3.greatestIndex([a, b], d => d.name), 1); - test.deepEqual(d3.greatestIndex([a, b], d => d.v), 0); + assert.deepStrictEqual(greatestIndex([a, b], d => d.name), 1); + assert.deepStrictEqual(greatestIndex([a, b], d => d.v), 0); }); -tape("greatestIndex(array) returns -1 if the array is empty", (test) => { - test.strictEqual(d3.greatestIndex([]), -1); +it("greatestIndex(array) returns -1 if the array is empty", () => { + assert.strictEqual(greatestIndex([]), -1); }); -tape("greatestIndex(array) returns -1 if the array contains only incomparable values", (test) => { - test.strictEqual(d3.greatestIndex([NaN, undefined]), -1); - test.strictEqual(d3.greatestIndex([NaN, "foo"], (a, b) => a - b), -1); +it("greatestIndex(array) returns -1 if the array contains only incomparable values", () => { + assert.strictEqual(greatestIndex([NaN, undefined]), -1); + assert.strictEqual(greatestIndex([NaN, "foo"], (a, b) => a - b), -1); }); -tape("greatestIndex(array) returns the first of equal values", (test) => { - test.strictEqual(d3.greatestIndex([-2, -2, -1, -1, 0, 0, 0, -3, 0]), 4); - test.strictEqual(d3.greatestIndex([-3, -2, -2, -1, -1, 0, 0, 0, -3, 0], d3.descending), 0); +it("greatestIndex(array) returns the first of equal values", () => { + assert.strictEqual(greatestIndex([-2, -2, -1, -1, 0, 0, 0, -3, 0]), 4); + assert.strictEqual(greatestIndex([-3, -2, -2, -1, -1, 0, 0, 0, -3, 0], descending), 0); }); diff --git a/test/group-test.js b/test/group-test.js index 758e5162..24eaa7b3 100644 --- a/test/group-test.js +++ b/test/group-test.js @@ -1,5 +1,5 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {group} from "../src/index.js"; const data = [ {name: "jim", amount: "34.0", date: "11/12/2015"}, @@ -8,9 +8,9 @@ const data = [ {name: "stacy", amount: "34.05", date: "01/04/2016"} ]; -tape("group(data, accessor) returns the expected map", (test) => { - test.deepEqual( - entries(d3.group(data, d => d.name), 1), +it("group(data, accessor) returns the expected map", () => { + assert.deepStrictEqual( + entries(group(data, d => d.name), 1), [ [ "jim", @@ -51,9 +51,9 @@ tape("group(data, accessor) returns the expected map", (test) => { ); }); -tape("group(data, accessor, accessor) returns the expected map", (test) => { - test.deepEqual( - entries(d3.group(data, d => d.name, d => d.amount), 2), +it("group(data, accessor, accessor) returns the expected map", () => { + assert.deepStrictEqual( + entries(group(data, d => d.name, d => d.amount), 2), [ [ "jim", @@ -114,19 +114,19 @@ tape("group(data, accessor, accessor) returns the expected map", (test) => { ); }); -tape("group(data, accessor) interns keys", (test) => { +it("group(data, accessor) interns keys", () => { const a1 = new Date(Date.UTC(2001, 0, 1)); const a2 = new Date(Date.UTC(2001, 0, 1)); const b = new Date(Date.UTC(2002, 0, 1)); - const map = d3.group([[a1, 1], [a2, 2], [b, 3]], ([date]) => date); - test.deepEqual(map.get(a1), [[a1, 1], [a2, 2]]); - test.deepEqual(map.get(a2), [[a1, 1], [a2, 2]]); - test.deepEqual(map.get(b), [[b, 3]]); - test.deepEqual(map.get(+a1), [[a1, 1], [a2, 2]]); - test.deepEqual(map.get(+a2), [[a1, 1], [a2, 2]]); - test.deepEqual(map.get(+b), [[b, 3]]); - test.strictEqual([...map.keys()][0], a1); - test.strictEqual([...map.keys()][1], b); + const map = group([[a1, 1], [a2, 2], [b, 3]], ([date]) => date); + assert.deepStrictEqual(map.get(a1), [[a1, 1], [a2, 2]]); + assert.deepStrictEqual(map.get(a2), [[a1, 1], [a2, 2]]); + assert.deepStrictEqual(map.get(b), [[b, 3]]); + assert.deepStrictEqual(map.get(+a1), [[a1, 1], [a2, 2]]); + assert.deepStrictEqual(map.get(+a2), [[a1, 1], [a2, 2]]); + assert.deepStrictEqual(map.get(+b), [[b, 3]]); + assert.strictEqual([...map.keys()][0], a1); + assert.strictEqual([...map.keys()][1], b); }); function entries(map, depth) { diff --git a/test/groupSort-test.js b/test/groupSort-test.js index 64164809..2d7d76b3 100644 --- a/test/groupSort-test.js +++ b/test/groupSort-test.js @@ -1,49 +1,51 @@ -const tape = require("tape-await"); -const d3 = require("../"); -const barley = require("./data/barley.json"); +import assert from "assert"; +import {readFileSync} from "fs"; +import {ascending, descending, groupSort, median} from "../src/index.js"; -tape("groupSort(data, reduce, key) returns sorted keys when reduce is an accessor", (test) => { - test.deepEquals( - d3.groupSort(barley, g => d3.median(g, d => d.yield), d => d.variety), +const barley = JSON.parse(readFileSync("./test/data/barley.json")); + +it("groupSort(data, reduce, key) returns sorted keys when reduce is an accessor", () => { + assert.deepStrictEqual( + groupSort(barley, g => median(g, d => d.yield), d => d.variety), ["Svansota", "No. 462", "Manchuria", "No. 475", "Velvet", "Peatland", "Glabron", "No. 457", "Wisconsin No. 38", "Trebi"] ); - test.deepEquals( - d3.groupSort(barley, g => -d3.median(g, d => d.yield), d => d.variety), + assert.deepStrictEqual( + groupSort(barley, g => -median(g, d => d.yield), d => d.variety), ["Trebi", "Wisconsin No. 38", "No. 457", "Glabron", "Peatland", "Velvet", "No. 475", "Manchuria", "No. 462", "Svansota"] ); - test.deepEquals( - d3.groupSort(barley, g => d3.median(g, d => -d.yield), d => d.variety), + assert.deepStrictEqual( + groupSort(barley, g => median(g, d => -d.yield), d => d.variety), ["Trebi", "Wisconsin No. 38", "No. 457", "Glabron", "Peatland", "Velvet", "No. 475", "Manchuria", "No. 462", "Svansota"] ); - test.deepEquals( - d3.groupSort(barley, g => d3.median(g, d => d.yield), d => d.site), + assert.deepStrictEqual( + groupSort(barley, g => median(g, d => d.yield), d => d.site), ["Grand Rapids", "Duluth", "University Farm", "Morris", "Crookston", "Waseca"] ); - test.deepEquals( - d3.groupSort(barley, g => -d3.median(g, d => d.yield), d => d.site), + assert.deepStrictEqual( + groupSort(barley, g => -median(g, d => d.yield), d => d.site), ["Waseca", "Crookston", "Morris", "University Farm", "Duluth", "Grand Rapids"] ); - test.deepEquals( - d3.groupSort(barley, g => d3.median(g, d => -d.yield), d => d.site), + assert.deepStrictEqual( + groupSort(barley, g => median(g, d => -d.yield), d => d.site), ["Waseca", "Crookston", "Morris", "University Farm", "Duluth", "Grand Rapids"] ); }); -tape("groupSort(data, reduce, key) returns sorted keys when reduce is a comparator", (test) => { - test.deepEquals( - d3.groupSort(barley, (a, b) => d3.ascending(d3.median(a, d => d.yield), d3.median(b, d => d.yield)), d => d.variety), +it("groupSort(data, reduce, key) returns sorted keys when reduce is a comparator", () => { + assert.deepStrictEqual( + groupSort(barley, (a, b) => ascending(median(a, d => d.yield), median(b, d => d.yield)), d => d.variety), ["Svansota", "No. 462", "Manchuria", "No. 475", "Velvet", "Peatland", "Glabron", "No. 457", "Wisconsin No. 38", "Trebi"] ); - test.deepEquals( - d3.groupSort(barley, (a, b) => d3.descending(d3.median(a, d => d.yield), d3.median(b, d => d.yield)), d => d.variety), + assert.deepStrictEqual( + groupSort(barley, (a, b) => descending(median(a, d => d.yield), median(b, d => d.yield)), d => d.variety), ["Trebi", "Wisconsin No. 38", "No. 457", "Glabron", "Peatland", "Velvet", "No. 475", "Manchuria", "No. 462", "Svansota"] ); - test.deepEquals( - d3.groupSort(barley, (a, b) => d3.ascending(d3.median(a, d => d.yield), d3.median(b, d => d.yield)), d => d.site), + assert.deepStrictEqual( + groupSort(barley, (a, b) => ascending(median(a, d => d.yield), median(b, d => d.yield)), d => d.site), ["Grand Rapids", "Duluth", "University Farm", "Morris", "Crookston", "Waseca"] ); - test.deepEquals( - d3.groupSort(barley, (a, b) => d3.descending(d3.median(a, d => d.yield), d3.median(b, d => d.yield)), d => d.site), + assert.deepStrictEqual( + groupSort(barley, (a, b) => descending(median(a, d => d.yield), median(b, d => d.yield)), d => d.site), ["Waseca", "Crookston", "Morris", "University Farm", "Duluth", "Grand Rapids"] ); }); diff --git a/test/groups-test.js b/test/groups-test.js index ebf38407..6ebb4bfa 100644 --- a/test/groups-test.js +++ b/test/groups-test.js @@ -1,5 +1,5 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {groups} from "../src/index.js"; const data = [ {name: "jim", amount: "34.0", date: "11/12/2015"}, @@ -8,9 +8,9 @@ const data = [ {name: "stacy", amount: "34.05", date: "01/04/2016"} ]; -tape("groups(data, accessor) returns the expected array", (test) => { - test.deepEqual( - d3.groups(data, d => d.name), +it("groups(data, accessor) returns the expected array", () => { + assert.deepStrictEqual( + groups(data, d => d.name), [ [ "jim", @@ -51,9 +51,9 @@ tape("groups(data, accessor) returns the expected array", (test) => { ); }); -tape("groups(data, accessor, accessor) returns the expected array", (test) => { - test.deepEqual( - d3.groups(data, d => d.name, d => d.amount), +it("groups(data, accessor, accessor) returns the expected array", () => { + assert.deepStrictEqual( + groups(data, d => d.name, d => d.amount), [ [ "jim", diff --git a/test/index-test.js b/test/index-test.js index 59a62fbe..0afe419d 100644 --- a/test/index-test.js +++ b/test/index-test.js @@ -1,5 +1,5 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {index, indexes} from "../src/index.js"; const data = [ {name: "jim", amount: 34.0, date: "11/12/2015"}, @@ -8,9 +8,9 @@ const data = [ {name: "stacy", amount: 34.05, date: "01/04/2016"} ]; -tape("indexes(data, ...keys) returns the expected nested arrays", (test) => { - test.deepEqual( - d3.indexes(data, d => d.amount), +it("indexes(data, ...keys) returns the expected nested arrays", () => { + assert.deepStrictEqual( + indexes(data, d => d.amount), [ [34.0, {name: "jim", amount: 34.0, date: "11/12/2015"}], [120.11, {name: "carl", amount: 120.11, date: "11/12/2015"}], @@ -18,8 +18,8 @@ tape("indexes(data, ...keys) returns the expected nested arrays", (test) => { [34.05, {name: "stacy", amount: 34.05, date: "01/04/2016"}] ] ); - test.deepEqual( - d3.indexes(data, d => d.name, d => d.amount), + assert.deepStrictEqual( + indexes(data, d => d.name, d => d.amount), [ [ "jim", @@ -44,20 +44,20 @@ tape("indexes(data, ...keys) returns the expected nested arrays", (test) => { ); }); -tape("index(data, ...keys) returns the expected map", (test) => { - test.deepEqual( - entries(d3.index(data, d => d.amount), 1), - d3.indexes(data, d => d.amount) +it("index(data, ...keys) returns the expected map", () => { + assert.deepStrictEqual( + entries(index(data, d => d.amount), 1), + indexes(data, d => d.amount) ); - test.deepEqual( - entries(d3.index(data, d => d.name, d => d.amount), 2), - d3.indexes(data, d => d.name, d => d.amount) + assert.deepStrictEqual( + entries(index(data, d => d.name, d => d.amount), 2), + indexes(data, d => d.name, d => d.amount) ); }); -tape("index(data, ...keys) throws on a non-unique key", (test) => { - test.throws(() => d3.index(data, d => d.name)); - test.throws(() => d3.index(data, d => d.date)); +it("index(data, ...keys) throws on a non-unique key", () => { + assert.throws(() => index(data, d => d.name)); + assert.throws(() => index(data, d => d.date)); }); function entries(map, depth) { diff --git a/test/intersection-test.js b/test/intersection-test.js index fd260b7c..b4d08fdb 100644 --- a/test/intersection-test.js +++ b/test/intersection-test.js @@ -1,21 +1,19 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import {intersection} from "../src/index.js"; +import {assertSetEqual} from "./asserts.js"; -require("./setEqual"); - -tape("intersection(values) returns a set of values", (test) => { - test.setEqual(d3.intersection([1, 2, 3, 2, 1]), new Set([1, 2, 3])); +it("intersection(values) returns a set of values", () => { + assertSetEqual(intersection([1, 2, 3, 2, 1]), new Set([1, 2, 3])); }); -tape("intersection(values, other) returns a set of values", (test) => { - test.setEqual(d3.intersection([1, 2], [2, 3, 1]), new Set([1, 2])); - test.setEqual(d3.intersection([2, 1, 3], [4, 3, 1]), new Set([1, 3])); +it("intersection(values, other) returns a set of values", () => { + assertSetEqual(intersection([1, 2], [2, 3, 1]), new Set([1, 2])); + assertSetEqual(intersection([2, 1, 3], [4, 3, 1]), new Set([1, 3])); }); -tape("intersection(...values) returns a set of values", (test) => { - test.setEqual(d3.intersection([1, 2], [2, 1], [2, 3]), new Set([2])); +it("intersection(...values) returns a set of values", () => { + assertSetEqual(intersection([1, 2], [2, 1], [2, 3]), new Set([2])); }); -tape("intersection(...values) accepts iterables", (test) => { - test.setEqual(d3.intersection(new Set([1, 2, 3])), new Set([1, 2, 3])); +it("intersection(...values) accepts iterables", () => { + assertSetEqual(intersection(new Set([1, 2, 3])), new Set([1, 2, 3])); }); diff --git a/test/isNaN.js b/test/isNaN.js deleted file mode 100644 index d1246941..00000000 --- a/test/isNaN.js +++ /dev/null @@ -1,10 +0,0 @@ -const tape = require("tape-await"); - -tape.Test.prototype.isNaN = function(actual) { - this._assert(isNaN(actual) && actual !== actual, { - message: "should be NaN", - operator: "isNaN", - actual: actual, - expected: NaN - }); -}; diff --git a/test/least-test.js b/test/least-test.js index 1dae893c..ce73be5f 100644 --- a/test/least-test.js +++ b/test/least-test.js @@ -1,49 +1,49 @@ -const tape = require("tape-await"); -const d3 = require("../"); - -tape("least(array) compares using natural order", (test) => { - test.strictEqual(d3.least([0, 1]), 0); - test.strictEqual(d3.least([1, 0]), 0); - test.strictEqual(d3.least([0, "1"]), 0); - test.strictEqual(d3.least(["1", 0]), 0); - test.strictEqual(d3.least(["10", "2"]), "10"); - test.strictEqual(d3.least(["2", "10"]), "10"); - test.strictEqual(d3.least(["10", "2", NaN]), "10"); - test.strictEqual(d3.least([NaN, "10", "2"]), "10"); - test.strictEqual(d3.least(["2", NaN, "10"]), "10"); - test.strictEqual(d3.least([2, NaN, 10]), 2); - test.strictEqual(d3.least([10, 2, NaN]), 2); - test.strictEqual(d3.least([NaN, 10, 2]), 2); +import assert from "assert"; +import {descending, least} from "../src/index.js"; + +it("least(array) compares using natural order", () => { + assert.strictEqual(least([0, 1]), 0); + assert.strictEqual(least([1, 0]), 0); + assert.strictEqual(least([0, "1"]), 0); + assert.strictEqual(least(["1", 0]), 0); + assert.strictEqual(least(["10", "2"]), "10"); + assert.strictEqual(least(["2", "10"]), "10"); + assert.strictEqual(least(["10", "2", NaN]), "10"); + assert.strictEqual(least([NaN, "10", "2"]), "10"); + assert.strictEqual(least(["2", NaN, "10"]), "10"); + assert.strictEqual(least([2, NaN, 10]), 2); + assert.strictEqual(least([10, 2, NaN]), 2); + assert.strictEqual(least([NaN, 10, 2]), 2); }); -tape("least(array, compare) compares using the specified compare function", (test) => { +it("least(array, compare) compares using the specified compare function", () => { const a = {name: "a"}, b = {name: "b"}; - test.deepEqual(d3.least([a, b], (a, b) => a.name.localeCompare(b.name)), {name: "a"}); - test.strictEqual(d3.least([1, 0], d3.descending), 1); - test.strictEqual(d3.least(["1", 0], d3.descending), "1"); - test.strictEqual(d3.least(["2", "10"], d3.descending), "2"); - test.strictEqual(d3.least(["2", NaN, "10"], d3.descending), "2"); - test.strictEqual(d3.least([2, NaN, 10], d3.descending), 10); + assert.deepStrictEqual(least([a, b], (a, b) => a.name.localeCompare(b.name)), {name: "a"}); + assert.strictEqual(least([1, 0], descending), 1); + assert.strictEqual(least(["1", 0], descending), "1"); + assert.strictEqual(least(["2", "10"], descending), "2"); + assert.strictEqual(least(["2", NaN, "10"], descending), "2"); + assert.strictEqual(least([2, NaN, 10], descending), 10); }); -tape("least(array, accessor) uses the specified accessor function", (test) => { +it("least(array, accessor) uses the specified accessor function", () => { const a = {name: "a", v: 42}, b = {name: "b", v: 0.42}; - test.deepEqual(d3.least([a, b], d => d.name), a); - test.deepEqual(d3.least([a, b], d => d.v), b); + assert.deepStrictEqual(least([a, b], d => d.name), a); + assert.deepStrictEqual(least([a, b], d => d.v), b); }); -tape("least(array) returns undefined if the array is empty", (test) => { - test.strictEqual(d3.least([]), undefined); +it("least(array) returns undefined if the array is empty", () => { + assert.strictEqual(least([]), undefined); }); -tape("least(array) returns undefined if the array contains only incomparable values", (test) => { - test.strictEqual(d3.least([NaN, undefined]), undefined); - test.strictEqual(d3.least([NaN, "foo"], (a, b) => a - b), undefined); +it("least(array) returns undefined if the array contains only incomparable values", () => { + assert.strictEqual(least([NaN, undefined]), undefined); + assert.strictEqual(least([NaN, "foo"], (a, b) => a - b), undefined); }); -tape("least(array) returns the first of equal values", (test) => { - test.deepEqual(d3.least([2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), ascendingValue), {value: 0, index: 4}); - test.deepEqual(d3.least([3, 2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), descendingValue), {value: 3, index: 0}); +it("least(array) returns the first of equal values", () => { + assert.deepStrictEqual(least([2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), ascendingValue), {value: 0, index: 4}); + assert.deepStrictEqual(least([3, 2, 2, 1, 1, 0, 0, 0, 3, 0].map(box), descendingValue), {value: 3, index: 0}); }); function box(value, index) { diff --git a/test/leastIndex-test.js b/test/leastIndex-test.js index ce0b6d34..9da2972c 100644 --- a/test/leastIndex-test.js +++ b/test/leastIndex-test.js @@ -1,47 +1,47 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {descending, leastIndex} from "../src/index.js"; -tape("leastIndex(array) compares using natural order", (test) => { - test.strictEqual(d3.leastIndex([0, 1]), 0); - test.strictEqual(d3.leastIndex([1, 0]), 1); - test.strictEqual(d3.leastIndex([0, "1"]), 0); - test.strictEqual(d3.leastIndex(["1", 0]), 1); - test.strictEqual(d3.leastIndex(["10", "2"]), 0); - test.strictEqual(d3.leastIndex(["2", "10"]), 1); - test.strictEqual(d3.leastIndex(["10", "2", NaN]), 0); - test.strictEqual(d3.leastIndex([NaN, "10", "2"]), 1); - test.strictEqual(d3.leastIndex(["2", NaN, "10"]), 2); - test.strictEqual(d3.leastIndex([2, NaN, 10]), 0); - test.strictEqual(d3.leastIndex([10, 2, NaN]), 1); - test.strictEqual(d3.leastIndex([NaN, 10, 2]), 2); +it("leastIndex(array) compares using natural order", () => { + assert.strictEqual(leastIndex([0, 1]), 0); + assert.strictEqual(leastIndex([1, 0]), 1); + assert.strictEqual(leastIndex([0, "1"]), 0); + assert.strictEqual(leastIndex(["1", 0]), 1); + assert.strictEqual(leastIndex(["10", "2"]), 0); + assert.strictEqual(leastIndex(["2", "10"]), 1); + assert.strictEqual(leastIndex(["10", "2", NaN]), 0); + assert.strictEqual(leastIndex([NaN, "10", "2"]), 1); + assert.strictEqual(leastIndex(["2", NaN, "10"]), 2); + assert.strictEqual(leastIndex([2, NaN, 10]), 0); + assert.strictEqual(leastIndex([10, 2, NaN]), 1); + assert.strictEqual(leastIndex([NaN, 10, 2]), 2); }); -tape("leastIndex(array, compare) compares using the specified compare function", (test) => { +it("leastIndex(array, compare) compares using the specified compare function", () => { const a = {name: "a"}, b = {name: "b"}; - test.strictEqual(d3.leastIndex([a, b], (a, b) => a.name.localeCompare(b.name)), 0); - test.strictEqual(d3.leastIndex([1, 0], d3.descending), 0); - test.strictEqual(d3.leastIndex(["1", 0], d3.descending), 0); - test.strictEqual(d3.leastIndex(["2", "10"], d3.descending), 0); - test.strictEqual(d3.leastIndex(["2", NaN, "10"], d3.descending), 0); - test.strictEqual(d3.leastIndex([2, NaN, 10], d3.descending), 2); + assert.strictEqual(leastIndex([a, b], (a, b) => a.name.localeCompare(b.name)), 0); + assert.strictEqual(leastIndex([1, 0], descending), 0); + assert.strictEqual(leastIndex(["1", 0], descending), 0); + assert.strictEqual(leastIndex(["2", "10"], descending), 0); + assert.strictEqual(leastIndex(["2", NaN, "10"], descending), 0); + assert.strictEqual(leastIndex([2, NaN, 10], descending), 2); }); -tape("leastIndex(array, accessor) uses the specified accessor function", (test) => { +it("leastIndex(array, accessor) uses the specified accessor function", () => { const a = {name: "a", v: 42}, b = {name: "b", v: 0.42}; - test.deepEqual(d3.leastIndex([a, b], d => d.name), 0); - test.deepEqual(d3.leastIndex([a, b], d => d.v), 1); + assert.deepStrictEqual(leastIndex([a, b], d => d.name), 0); + assert.deepStrictEqual(leastIndex([a, b], d => d.v), 1); }); -tape("leastIndex(array) returns -1 if the array is empty", (test) => { - test.strictEqual(d3.leastIndex([]), -1); +it("leastIndex(array) returns -1 if the array is empty", () => { + assert.strictEqual(leastIndex([]), -1); }); -tape("leastIndex(array) returns -1 if the array contains only incomparable values", (test) => { - test.strictEqual(d3.leastIndex([NaN, undefined]), -1); - test.strictEqual(d3.leastIndex([NaN, "foo"], (a, b) => a - b), -1); +it("leastIndex(array) returns -1 if the array contains only incomparable values", () => { + assert.strictEqual(leastIndex([NaN, undefined]), -1); + assert.strictEqual(leastIndex([NaN, "foo"], (a, b) => a - b), -1); }); -tape("leastIndex(array) returns the first of equal values", (test) => { - test.strictEqual(d3.leastIndex([2, 2, 1, 1, 0, 0, 0, 3, 0]), 4); - test.strictEqual(d3.leastIndex([3, 2, 2, 1, 1, 0, 0, 0, 3, 0], d3.descending), 0); +it("leastIndex(array) returns the first of equal values", () => { + assert.strictEqual(leastIndex([2, 2, 1, 1, 0, 0, 0, 3, 0]), 4); + assert.strictEqual(leastIndex([3, 2, 2, 1, 1, 0, 0, 0, 3, 0], descending), 0); }); diff --git a/test/map-test.js b/test/map-test.js index 70921be8..353c0dca 100644 --- a/test/map-test.js +++ b/test/map-test.js @@ -1,41 +1,40 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {map} from "../src/index.js"; -tape("map(values, mapper) returns the mapped values", (test) => { - test.deepEqual(d3.map([1, 2, 3, 2, 1], x => x * 2), [2, 4, 6, 4, 2]); +it("map(values, mapper) returns the mapped values", () => { + assert.deepStrictEqual(map([1, 2, 3, 2, 1], x => x * 2), [2, 4, 6, 4, 2]); }); -tape("map(values, mapper) accepts an iterable", (test) => { - test.deepEqual(d3.map(new Set([1, 2, 3, 2, 1]), x => x * 2), [2, 4, 6]); - test.deepEqual(d3.map((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x * 2), [2, 4, 6, 4, 2]); +it("map(values, mapper) accepts an iterable", () => { + assert.deepStrictEqual(map(new Set([1, 2, 3, 2, 1]), x => x * 2), [2, 4, 6]); + assert.deepStrictEqual(map((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x * 2), [2, 4, 6, 4, 2]); }); -tape("map(values, mapper) accepts a typed array", (test) => { - test.deepEqual(d3.map(Uint8Array.of(1, 2, 3, 2, 1), x => x * 2), [2, 4, 6, 4, 2]); +it("map(values, mapper) accepts a typed array", () => { + assert.deepStrictEqual(map(Uint8Array.of(1, 2, 3, 2, 1), x => x * 2), [2, 4, 6, 4, 2]); }); -tape("map(values, mapper) enforces that test is a function", (test) => { - test.throws(() => d3.map([]), TypeError); +it("map(values, mapper) enforces that test is a function", () => { + assert.throws(() => map([]), TypeError); }); -tape("map(values, mapper) enforces that values is iterable", (test) => { - test.throws(() => d3.map({}, () => true), TypeError); +it("map(values, mapper) enforces that values is iterable", () => { + assert.throws(() => map({}, () => true), TypeError); }); -tape("map(values, mapper) passes test (value, index, values)", (test) => { +it("map(values, mapper) passes test (value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); - d3.map(values, function() { calls.push([this, ...arguments]); }); - test.deepEqual(calls, [ - [global, 5, 0, values], - [global, 4, 1, values], - [global, 3, 2, values], - [global, 2, 3, values], - [global, 1, 4, values] + map(values, function() { calls.push([this, ...arguments]); }); + assert.deepStrictEqual(calls, [ + [undefined, 5, 0, values], + [undefined, 4, 1, values], + [undefined, 3, 2, values], + [undefined, 2, 3, values], + [undefined, 1, 4, values] ]); }); -tape("map(values, mapper) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.map([, 1, 2,,], x => x * 2), [NaN, 2, 4, NaN]); +it("map(values, mapper) does not skip sparse elements", () => { + assert.deepStrictEqual(map([, 1, 2,, ], x => x * 2), [NaN, 2, 4, NaN]); }); diff --git a/test/max-test.js b/test/max-test.js index 1838ae4a..2b17d36f 100644 --- a/test/max-test.js +++ b/test/max-test.js @@ -1,93 +1,93 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {max} from "../src/index.js"; -tape("max(array) returns the greatest numeric value for numbers", (test) => { - test.deepEqual(d3.max([1]), 1); - test.deepEqual(d3.max([5, 1, 2, 3, 4]), 5); - test.deepEqual(d3.max([20, 3]), 20); - test.deepEqual(d3.max([3, 20]), 20); +it("max(array) returns the greatest numeric value for numbers", () => { + assert.deepStrictEqual(max([1]), 1); + assert.deepStrictEqual(max([5, 1, 2, 3, 4]), 5); + assert.deepStrictEqual(max([20, 3]), 20); + assert.deepStrictEqual(max([3, 20]), 20); }); -tape("max(array) returns the greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.max(["c", "a", "b"]), "c"); - test.deepEqual(d3.max(["20", "3"]), "3"); - test.deepEqual(d3.max(["3", "20"]), "3"); +it("max(array) returns the greatest lexicographic value for strings", () => { + assert.deepStrictEqual(max(["c", "a", "b"]), "c"); + assert.deepStrictEqual(max(["20", "3"]), "3"); + assert.deepStrictEqual(max(["3", "20"]), "3"); }); -tape("max(array) ignores null, undefined and NaN", (test) => { +it("max(array) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.max([NaN, 1, 2, 3, 4, 5]), 5); - test.deepEqual(d3.max([o, 1, 2, 3, 4, 5]), 5); - test.deepEqual(d3.max([1, 2, 3, 4, 5, NaN]), 5); - test.deepEqual(d3.max([1, 2, 3, 4, 5, o]), 5); - test.deepEqual(d3.max([10, null, 3, undefined, 5, NaN]), 10); - test.deepEqual(d3.max([-1, null, -3, undefined, -5, NaN]), -1); + assert.deepStrictEqual(max([NaN, 1, 2, 3, 4, 5]), 5); + assert.deepStrictEqual(max([o, 1, 2, 3, 4, 5]), 5); + assert.deepStrictEqual(max([1, 2, 3, 4, 5, NaN]), 5); + assert.deepStrictEqual(max([1, 2, 3, 4, 5, o]), 5); + assert.deepStrictEqual(max([10, null, 3, undefined, 5, NaN]), 10); + assert.deepStrictEqual(max([-1, null, -3, undefined, -5, NaN]), -1); }); -tape("max(array) compares heterogenous types as numbers", (test) => { - test.equal(d3.max([20, "3"]), 20); - test.equal(d3.max(["20", 3]), "20"); - test.equal(d3.max([3, "20"]), "20"); - test.equal(d3.max(["3", 20]), 20); +it("max(array) compares heterogenous types as numbers", () => { + assert.strictEqual(max([20, "3"]), 20); + assert.strictEqual(max(["20", 3]), "20"); + assert.strictEqual(max([3, "20"]), "20"); + assert.strictEqual(max(["3", 20]), 20); }); -tape("max(array) returns undefined if the array contains no numbers", (test) => { - test.equal(d3.max([]), undefined); - test.equal(d3.max([null]), undefined); - test.equal(d3.max([undefined]), undefined); - test.equal(d3.max([NaN]), undefined); - test.equal(d3.max([NaN, NaN]), undefined); +it("max(array) returns undefined if the array contains no numbers", () => { + assert.strictEqual(max([]), undefined); + assert.strictEqual(max([null]), undefined); + assert.strictEqual(max([undefined]), undefined); + assert.strictEqual(max([NaN]), undefined); + assert.strictEqual(max([NaN, NaN]), undefined); }); -tape("max(array, f) returns the greatest numeric value for numbers", (test) => { - test.deepEqual(d3.max([1].map(box), unbox), 1); - test.deepEqual(d3.max([5, 1, 2, 3, 4].map(box), unbox), 5); - test.deepEqual(d3.max([20, 3].map(box), unbox), 20); - test.deepEqual(d3.max([3, 20].map(box), unbox), 20); +it("max(array, f) returns the greatest numeric value for numbers", () => { + assert.deepStrictEqual(max([1].map(box), unbox), 1); + assert.deepStrictEqual(max([5, 1, 2, 3, 4].map(box), unbox), 5); + assert.deepStrictEqual(max([20, 3].map(box), unbox), 20); + assert.deepStrictEqual(max([3, 20].map(box), unbox), 20); }); -tape("max(array, f) returns the greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.max(["c", "a", "b"].map(box), unbox), "c"); - test.deepEqual(d3.max(["20", "3"].map(box), unbox), "3"); - test.deepEqual(d3.max(["3", "20"].map(box), unbox), "3"); +it("max(array, f) returns the greatest lexicographic value for strings", () => { + assert.deepStrictEqual(max(["c", "a", "b"].map(box), unbox), "c"); + assert.deepStrictEqual(max(["20", "3"].map(box), unbox), "3"); + assert.deepStrictEqual(max(["3", "20"].map(box), unbox), "3"); }); -tape("max(array, f) ignores null, undefined and NaN", (test) => { +it("max(array, f) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.max([NaN, 1, 2, 3, 4, 5].map(box), unbox), 5); - test.deepEqual(d3.max([o, 1, 2, 3, 4, 5].map(box), unbox), 5); - test.deepEqual(d3.max([1, 2, 3, 4, 5, NaN].map(box), unbox), 5); - test.deepEqual(d3.max([1, 2, 3, 4, 5, o].map(box), unbox), 5); - test.deepEqual(d3.max([10, null, 3, undefined, 5, NaN].map(box), unbox), 10); - test.deepEqual(d3.max([-1, null, -3, undefined, -5, NaN].map(box), unbox), -1); + assert.deepStrictEqual(max([NaN, 1, 2, 3, 4, 5].map(box), unbox), 5); + assert.deepStrictEqual(max([o, 1, 2, 3, 4, 5].map(box), unbox), 5); + assert.deepStrictEqual(max([1, 2, 3, 4, 5, NaN].map(box), unbox), 5); + assert.deepStrictEqual(max([1, 2, 3, 4, 5, o].map(box), unbox), 5); + assert.deepStrictEqual(max([10, null, 3, undefined, 5, NaN].map(box), unbox), 10); + assert.deepStrictEqual(max([-1, null, -3, undefined, -5, NaN].map(box), unbox), -1); }); -tape("max(array, f) compares heterogenous types as numbers", (test) => { - test.equal(d3.max([20, "3"].map(box), unbox), 20); - test.equal(d3.max(["20", 3].map(box), unbox), "20"); - test.equal(d3.max([3, "20"].map(box), unbox), "20"); - test.equal(d3.max(["3", 20].map(box), unbox), 20); +it("max(array, f) compares heterogenous types as numbers", () => { + assert.strictEqual(max([20, "3"].map(box), unbox), 20); + assert.strictEqual(max(["20", 3].map(box), unbox), "20"); + assert.strictEqual(max([3, "20"].map(box), unbox), "20"); + assert.strictEqual(max(["3", 20].map(box), unbox), 20); }); -tape("max(array, f) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.max([].map(box), unbox), undefined); - test.equal(d3.max([null].map(box), unbox), undefined); - test.equal(d3.max([undefined].map(box), unbox), undefined); - test.equal(d3.max([NaN].map(box), unbox), undefined); - test.equal(d3.max([NaN, NaN].map(box), unbox), undefined); +it("max(array, f) returns undefined if the array contains no observed values", () => { + assert.strictEqual(max([].map(box), unbox), undefined); + assert.strictEqual(max([null].map(box), unbox), undefined); + assert.strictEqual(max([undefined].map(box), unbox), undefined); + assert.strictEqual(max([NaN].map(box), unbox), undefined); + assert.strictEqual(max([NaN, NaN].map(box), unbox), undefined); }); -tape("max(array, f) passes the accessor d, i, and array", (test) => { +it("max(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.max(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + max(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("max(array, f) uses the global context", (test) => { +it("max(array, f) uses the undefined context", () => { const results = []; - d3.max([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + max([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/maxIndex-test.js b/test/maxIndex-test.js index c6cfeda9..6ed831ad 100644 --- a/test/maxIndex-test.js +++ b/test/maxIndex-test.js @@ -1,93 +1,93 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {maxIndex} from "../src/index.js"; -tape("maxIndex(array) returns the index of the greatest numeric value for numbers", (test) => { - test.deepEqual(d3.maxIndex([1]), 0); - test.deepEqual(d3.maxIndex([5, 1, 2, 3, 4]), 0); - test.deepEqual(d3.maxIndex([20, 3]), 0); - test.deepEqual(d3.maxIndex([3, 20]), 1); +it("maxIndex(array) returns the index of the greatest numeric value for numbers", () => { + assert.deepStrictEqual(maxIndex([1]), 0); + assert.deepStrictEqual(maxIndex([5, 1, 2, 3, 4]), 0); + assert.deepStrictEqual(maxIndex([20, 3]), 0); + assert.deepStrictEqual(maxIndex([3, 20]), 1); }); -tape("maxIndex(array) returns the greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.maxIndex(["c", "a", "b"]), 0); - test.deepEqual(d3.maxIndex(["20", "3"]), 1); - test.deepEqual(d3.maxIndex(["3", "20"]), 0); +it("maxIndex(array) returns the greatest lexicographic value for strings", () => { + assert.deepStrictEqual(maxIndex(["c", "a", "b"]), 0); + assert.deepStrictEqual(maxIndex(["20", "3"]), 1); + assert.deepStrictEqual(maxIndex(["3", "20"]), 0); }); -tape("maxIndex(array) ignores null, undefined and NaN", (test) => { +it("maxIndex(array) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.maxIndex([NaN, 1, 2, 3, 4, 5]), 5); - test.deepEqual(d3.maxIndex([o, 1, 2, 3, 4, 5]), 5); - test.deepEqual(d3.maxIndex([1, 2, 3, 4, 5, NaN]), 4); - test.deepEqual(d3.maxIndex([1, 2, 3, 4, 5, o]), 4); - test.deepEqual(d3.maxIndex([10, null, 3, undefined, 5, NaN]), 0); - test.deepEqual(d3.maxIndex([-1, null, -3, undefined, -5, NaN]), 0); + assert.deepStrictEqual(maxIndex([NaN, 1, 2, 3, 4, 5]), 5); + assert.deepStrictEqual(maxIndex([o, 1, 2, 3, 4, 5]), 5); + assert.deepStrictEqual(maxIndex([1, 2, 3, 4, 5, NaN]), 4); + assert.deepStrictEqual(maxIndex([1, 2, 3, 4, 5, o]), 4); + assert.deepStrictEqual(maxIndex([10, null, 3, undefined, 5, NaN]), 0); + assert.deepStrictEqual(maxIndex([-1, null, -3, undefined, -5, NaN]), 0); }); -tape("maxIndex(array) compares heterogenous types as numbers", (test) => { - test.equal(d3.maxIndex([20, "3"]), 0); - test.equal(d3.maxIndex(["20", 3]), 0); - test.equal(d3.maxIndex([3, "20"]), 1); - test.equal(d3.maxIndex(["3", 20]), 1); +it("maxIndex(array) compares heterogenous types as numbers", () => { + assert.strictEqual(maxIndex([20, "3"]), 0); + assert.strictEqual(maxIndex(["20", 3]), 0); + assert.strictEqual(maxIndex([3, "20"]), 1); + assert.strictEqual(maxIndex(["3", 20]), 1); }); -tape("maxIndex(array) returns -1 if the array contains no numbers", (test) => { - test.equal(d3.maxIndex([]), -1); - test.equal(d3.maxIndex([null]), -1); - test.equal(d3.maxIndex([undefined]), -1); - test.equal(d3.maxIndex([NaN]), -1); - test.equal(d3.maxIndex([NaN, NaN]), -1); +it("maxIndex(array) returns -1 if the array contains no numbers", () => { + assert.strictEqual(maxIndex([]), -1); + assert.strictEqual(maxIndex([null]), -1); + assert.strictEqual(maxIndex([undefined]), -1); + assert.strictEqual(maxIndex([NaN]), -1); + assert.strictEqual(maxIndex([NaN, NaN]), -1); }); -tape("maxIndex(array, f) returns the greatest numeric value for numbers", (test) => { - test.deepEqual(d3.maxIndex([1].map(box), unbox), 0); - test.deepEqual(d3.maxIndex([5, 1, 2, 3, 4].map(box), unbox), 0); - test.deepEqual(d3.maxIndex([20, 3].map(box), unbox), 0); - test.deepEqual(d3.maxIndex([3, 20].map(box), unbox), 1); +it("maxIndex(array, f) returns the greatest numeric value for numbers", () => { + assert.deepStrictEqual(maxIndex([1].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex([5, 1, 2, 3, 4].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex([20, 3].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex([3, 20].map(box), unbox), 1); }); -tape("maxIndex(array, f) returns the greatest lexicographic value for strings", (test) => { - test.deepEqual(d3.maxIndex(["c", "a", "b"].map(box), unbox), 0); - test.deepEqual(d3.maxIndex(["20", "3"].map(box), unbox), 1); - test.deepEqual(d3.maxIndex(["3", "20"].map(box), unbox), 0); +it("maxIndex(array, f) returns the greatest lexicographic value for strings", () => { + assert.deepStrictEqual(maxIndex(["c", "a", "b"].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex(["20", "3"].map(box), unbox), 1); + assert.deepStrictEqual(maxIndex(["3", "20"].map(box), unbox), 0); }); -tape("maxIndex(array, f) ignores null, undefined and NaN", (test) => { +it("maxIndex(array, f) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.maxIndex([NaN, 1, 2, 3, 4, 5].map(box), unbox), 5); - test.deepEqual(d3.maxIndex([o, 1, 2, 3, 4, 5].map(box), unbox), 5); - test.deepEqual(d3.maxIndex([1, 2, 3, 4, 5, NaN].map(box), unbox), 4); - test.deepEqual(d3.maxIndex([1, 2, 3, 4, 5, o].map(box), unbox), 4); - test.deepEqual(d3.maxIndex([10, null, 3, undefined, 5, NaN].map(box), unbox), 0); - test.deepEqual(d3.maxIndex([-1, null, -3, undefined, -5, NaN].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex([NaN, 1, 2, 3, 4, 5].map(box), unbox), 5); + assert.deepStrictEqual(maxIndex([o, 1, 2, 3, 4, 5].map(box), unbox), 5); + assert.deepStrictEqual(maxIndex([1, 2, 3, 4, 5, NaN].map(box), unbox), 4); + assert.deepStrictEqual(maxIndex([1, 2, 3, 4, 5, o].map(box), unbox), 4); + assert.deepStrictEqual(maxIndex([10, null, 3, undefined, 5, NaN].map(box), unbox), 0); + assert.deepStrictEqual(maxIndex([-1, null, -3, undefined, -5, NaN].map(box), unbox), 0); }); -tape("maxIndex(array, f) compares heterogenous types as numbers", (test) => { - test.equal(d3.maxIndex([20, "3"].map(box), unbox), 0); - test.equal(d3.maxIndex(["20", 3].map(box), unbox), 0); - test.equal(d3.maxIndex([3, "20"].map(box), unbox), 1); - test.equal(d3.maxIndex(["3", 20].map(box), unbox), 1); +it("maxIndex(array, f) compares heterogenous types as numbers", () => { + assert.strictEqual(maxIndex([20, "3"].map(box), unbox), 0); + assert.strictEqual(maxIndex(["20", 3].map(box), unbox), 0); + assert.strictEqual(maxIndex([3, "20"].map(box), unbox), 1); + assert.strictEqual(maxIndex(["3", 20].map(box), unbox), 1); }); -tape("maxIndex(array, f) returns -1 if the array contains no observed values", (test) => { - test.equal(d3.maxIndex([].map(box), unbox), -1); - test.equal(d3.maxIndex([null].map(box), unbox), -1); - test.equal(d3.maxIndex([undefined].map(box), unbox), -1); - test.equal(d3.maxIndex([NaN].map(box), unbox), -1); - test.equal(d3.maxIndex([NaN, NaN].map(box), unbox), -1); +it("maxIndex(array, f) returns -1 if the array contains no observed values", () => { + assert.strictEqual(maxIndex([].map(box), unbox), -1); + assert.strictEqual(maxIndex([null].map(box), unbox), -1); + assert.strictEqual(maxIndex([undefined].map(box), unbox), -1); + assert.strictEqual(maxIndex([NaN].map(box), unbox), -1); + assert.strictEqual(maxIndex([NaN, NaN].map(box), unbox), -1); }); -tape("maxIndex(array, f) passes the accessor d, i, and array", (test) => { +it("maxIndex(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.maxIndex(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + maxIndex(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("maxIndex(array, f) uses the global context", (test) => { +it("maxIndex(array, f) uses the undefined context", () => { const results = []; - d3.maxIndex([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + maxIndex([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/mean-test.js b/test/mean-test.js index f8f05f74..d55c8f64 100644 --- a/test/mean-test.js +++ b/test/mean-test.js @@ -1,86 +1,86 @@ -const tape = require("tape-await"); -const d3 = require("../"); -const OneTimeNumber = require("./OneTimeNumber"); +import assert from "assert"; +import {mean} from "../src/index.js"; +import {OneTimeNumber} from "./OneTimeNumber.js"; -tape("mean(array) returns the mean value for numbers", (test) => { - test.equal(d3.mean([1]), 1); - test.equal(d3.mean([5, 1, 2, 3, 4]), 3); - test.equal(d3.mean([20, 3]), 11.5); - test.equal(d3.mean([3, 20]), 11.5); +it("mean(array) returns the mean value for numbers", () => { + assert.strictEqual(mean([1]), 1); + assert.strictEqual(mean([5, 1, 2, 3, 4]), 3); + assert.strictEqual(mean([20, 3]), 11.5); + assert.strictEqual(mean([3, 20]), 11.5); }); -tape("mean(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.mean([NaN, 1, 2, 3, 4, 5]), 3); - test.equal(d3.mean([1, 2, 3, 4, 5, NaN]), 3); - test.equal(d3.mean([10, null, 3, undefined, 5, NaN]), 6); +it("mean(array) ignores null, undefined and NaN", () => { + assert.strictEqual(mean([NaN, 1, 2, 3, 4, 5]), 3); + assert.strictEqual(mean([1, 2, 3, 4, 5, NaN]), 3); + assert.strictEqual(mean([10, null, 3, undefined, 5, NaN]), 6); }); -tape("mean(array) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.mean([]), undefined); - test.equal(d3.mean([null]), undefined); - test.equal(d3.mean([undefined]), undefined); - test.equal(d3.mean([NaN]), undefined); - test.equal(d3.mean([NaN, NaN]), undefined); +it("mean(array) returns undefined if the array contains no observed values", () => { + assert.strictEqual(mean([]), undefined); + assert.strictEqual(mean([null]), undefined); + assert.strictEqual(mean([undefined]), undefined); + assert.strictEqual(mean([NaN]), undefined); + assert.strictEqual(mean([NaN, NaN]), undefined); }); -tape("mean(array) coerces values to numbers", (test) => { - test.equal(d3.mean(["1"]), 1); - test.equal(d3.mean(["5", "1", "2", "3", "4"]), 3); - test.equal(d3.mean(["20", "3"]), 11.5); - test.equal(d3.mean(["3", "20"]), 11.5); +it("mean(array) coerces values to numbers", () => { + assert.strictEqual(mean(["1"]), 1); + assert.strictEqual(mean(["5", "1", "2", "3", "4"]), 3); + assert.strictEqual(mean(["20", "3"]), 11.5); + assert.strictEqual(mean(["3", "20"]), 11.5); }); -tape("mean(array) coerces values exactly once", (test) => { +it("mean(array) coerces values exactly once", () => { const numbers = [1, new OneTimeNumber(3)]; - test.equal(d3.mean(numbers), 2); - test.equal(d3.mean(numbers), 1); + assert.strictEqual(mean(numbers), 2); + assert.strictEqual(mean(numbers), 1); }); -tape("mean(array, f) returns the mean value for numbers", (test) => { - test.equal(d3.mean([1].map(box), unbox), 1); - test.equal(d3.mean([5, 1, 2, 3, 4].map(box), unbox), 3); - test.equal(d3.mean([20, 3].map(box), unbox), 11.5); - test.equal(d3.mean([3, 20].map(box), unbox), 11.5); +it("mean(array, f) returns the mean value for numbers", () => { + assert.strictEqual(mean([1].map(box), unbox), 1); + assert.strictEqual(mean([5, 1, 2, 3, 4].map(box), unbox), 3); + assert.strictEqual(mean([20, 3].map(box), unbox), 11.5); + assert.strictEqual(mean([3, 20].map(box), unbox), 11.5); }); -tape("mean(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.mean([NaN, 1, 2, 3, 4, 5].map(box), unbox), 3); - test.equal(d3.mean([1, 2, 3, 4, 5, NaN].map(box), unbox), 3); - test.equal(d3.mean([10, null, 3, undefined, 5, NaN].map(box), unbox), 6); +it("mean(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(mean([NaN, 1, 2, 3, 4, 5].map(box), unbox), 3); + assert.strictEqual(mean([1, 2, 3, 4, 5, NaN].map(box), unbox), 3); + assert.strictEqual(mean([10, null, 3, undefined, 5, NaN].map(box), unbox), 6); }); -tape("mean(array, f) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.mean([].map(box), unbox), undefined); - test.equal(d3.mean([null].map(box), unbox), undefined); - test.equal(d3.mean([undefined].map(box), unbox), undefined); - test.equal(d3.mean([NaN].map(box), unbox), undefined); - test.equal(d3.mean([NaN, NaN].map(box), unbox), undefined); +it("mean(array, f) returns undefined if the array contains no observed values", () => { + assert.strictEqual(mean([].map(box), unbox), undefined); + assert.strictEqual(mean([null].map(box), unbox), undefined); + assert.strictEqual(mean([undefined].map(box), unbox), undefined); + assert.strictEqual(mean([NaN].map(box), unbox), undefined); + assert.strictEqual(mean([NaN, NaN].map(box), unbox), undefined); }); -tape("mean(array, f) coerces values to numbers", (test) => { - test.equal(d3.mean(["1"].map(box), unbox), 1); - test.equal(d3.mean(["5", "1", "2", "3", "4"].map(box), unbox), 3); - test.equal(d3.mean(["20", "3"].map(box), unbox), 11.5); - test.equal(d3.mean(["3", "20"].map(box), unbox), 11.5); +it("mean(array, f) coerces values to numbers", () => { + assert.strictEqual(mean(["1"].map(box), unbox), 1); + assert.strictEqual(mean(["5", "1", "2", "3", "4"].map(box), unbox), 3); + assert.strictEqual(mean(["20", "3"].map(box), unbox), 11.5); + assert.strictEqual(mean(["3", "20"].map(box), unbox), 11.5); }); -tape("mean(array, f) coerces values exactly once", (test) => { +it("mean(array, f) coerces values exactly once", () => { const numbers = [1, new OneTimeNumber(3)].map(box); - test.equal(d3.mean(numbers, unbox), 2); - test.equal(d3.mean(numbers, unbox), 1); + assert.strictEqual(mean(numbers, unbox), 2); + assert.strictEqual(mean(numbers, unbox), 1); }); -tape("mean(array, f) passes the accessor d, i, and array", (test) => { +it("mean(array, f) passes the accessor d, i, and array", () => { const results = []; const strings = ["a", "b", "c"]; - d3.mean(strings, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, strings], ["b", 1, strings], ["c", 2, strings]]); + mean(strings, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, strings], ["b", 1, strings], ["c", 2, strings]]); }); -tape("mean(array, f) uses the global context", (test) => { +it("mean(array, f) uses the undefined context", () => { const results = []; - d3.mean([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + mean([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/median-test.js b/test/median-test.js index e6fd79cb..b13c2342 100644 --- a/test/median-test.js +++ b/test/median-test.js @@ -1,101 +1,101 @@ -const tape = require("tape-await"); -const d3 = require("../"); -const OneTimeNumber = require("./OneTimeNumber"); - -tape("median(array) returns the median value for numbers", (test) => { - test.equal(d3.median([1]), 1); - test.equal(d3.median([5, 1, 2, 3]), 2.5); - test.equal(d3.median([5, 1, 2, 3, 4]), 3); - test.equal(d3.median([20, 3]), 11.5); - test.equal(d3.median([3, 20]), 11.5); +import assert from "assert"; +import {median} from "../src/index.js"; +import {OneTimeNumber} from "./OneTimeNumber.js"; + +it("median(array) returns the median value for numbers", () => { + assert.strictEqual(median([1]), 1); + assert.strictEqual(median([5, 1, 2, 3]), 2.5); + assert.strictEqual(median([5, 1, 2, 3, 4]), 3); + assert.strictEqual(median([20, 3]), 11.5); + assert.strictEqual(median([3, 20]), 11.5); }); -tape("median(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.median([NaN, 1, 2, 3, 4, 5]), 3); - test.equal(d3.median([1, 2, 3, 4, 5, NaN]), 3); - test.equal(d3.median([10, null, 3, undefined, 5, NaN]), 5); +it("median(array) ignores null, undefined and NaN", () => { + assert.strictEqual(median([NaN, 1, 2, 3, 4, 5]), 3); + assert.strictEqual(median([1, 2, 3, 4, 5, NaN]), 3); + assert.strictEqual(median([10, null, 3, undefined, 5, NaN]), 5); }); -tape("median(array) can handle large numbers without overflowing", (test) => { - test.equal(d3.median([Number.MAX_VALUE, Number.MAX_VALUE]), Number.MAX_VALUE); - test.equal(d3.median([-Number.MAX_VALUE, -Number.MAX_VALUE]), -Number.MAX_VALUE); +it("median(array) can handle large numbers without overflowing", () => { + assert.strictEqual(median([Number.MAX_VALUE, Number.MAX_VALUE]), Number.MAX_VALUE); + assert.strictEqual(median([-Number.MAX_VALUE, -Number.MAX_VALUE]), -Number.MAX_VALUE); }); -tape("median(array) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.median([]), undefined); - test.equal(d3.median([null]), undefined); - test.equal(d3.median([undefined]), undefined); - test.equal(d3.median([NaN]), undefined); - test.equal(d3.median([NaN, NaN]), undefined); +it("median(array) returns undefined if the array contains no observed values", () => { + assert.strictEqual(median([]), undefined); + assert.strictEqual(median([null]), undefined); + assert.strictEqual(median([undefined]), undefined); + assert.strictEqual(median([NaN]), undefined); + assert.strictEqual(median([NaN, NaN]), undefined); }); -tape("median(array) coerces strings to numbers", (test) => { - test.equal(d3.median(["1"]), 1); - test.equal(d3.median(["5", "1", "2", "3", "4"]), 3); - test.equal(d3.median(["20", "3"]), 11.5); - test.equal(d3.median(["3", "20"]), 11.5); - test.equal(d3.median(["2", "3", "20"]), 3); - test.equal(d3.median(["20", "3", "2"]), 3); +it("median(array) coerces strings to numbers", () => { + assert.strictEqual(median(["1"]), 1); + assert.strictEqual(median(["5", "1", "2", "3", "4"]), 3); + assert.strictEqual(median(["20", "3"]), 11.5); + assert.strictEqual(median(["3", "20"]), 11.5); + assert.strictEqual(median(["2", "3", "20"]), 3); + assert.strictEqual(median(["20", "3", "2"]), 3); }); -tape("median(array) coerces values exactly once", (test) => { +it("median(array) coerces values exactly once", () => { const array = [1, new OneTimeNumber(3)]; - test.equal(d3.median(array), 2); - test.equal(d3.median(array), 1); + assert.strictEqual(median(array), 2); + assert.strictEqual(median(array), 1); }); -tape("median(array, f) returns the median value for numbers", (test) => { - test.equal(d3.median([1].map(box), unbox), 1); - test.equal(d3.median([5, 1, 2, 3, 4].map(box), unbox), 3); - test.equal(d3.median([20, 3].map(box), unbox), 11.5); - test.equal(d3.median([3, 20].map(box), unbox), 11.5); +it("median(array, f) returns the median value for numbers", () => { + assert.strictEqual(median([1].map(box), unbox), 1); + assert.strictEqual(median([5, 1, 2, 3, 4].map(box), unbox), 3); + assert.strictEqual(median([20, 3].map(box), unbox), 11.5); + assert.strictEqual(median([3, 20].map(box), unbox), 11.5); }); -tape("median(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.median([NaN, 1, 2, 3, 4, 5].map(box), unbox), 3); - test.equal(d3.median([1, 2, 3, 4, 5, NaN].map(box), unbox), 3); - test.equal(d3.median([10, null, 3, undefined, 5, NaN].map(box), unbox), 5); +it("median(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(median([NaN, 1, 2, 3, 4, 5].map(box), unbox), 3); + assert.strictEqual(median([1, 2, 3, 4, 5, NaN].map(box), unbox), 3); + assert.strictEqual(median([10, null, 3, undefined, 5, NaN].map(box), unbox), 5); }); -tape("median(array, f) can handle large numbers without overflowing", (test) => { - test.equal(d3.median([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), Number.MAX_VALUE); - test.equal(d3.median([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), -Number.MAX_VALUE); +it("median(array, f) can handle large numbers without overflowing", () => { + assert.strictEqual(median([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), Number.MAX_VALUE); + assert.strictEqual(median([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), -Number.MAX_VALUE); }); -tape("median(array, f) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.median([].map(box), unbox), undefined); - test.equal(d3.median([null].map(box), unbox), undefined); - test.equal(d3.median([undefined].map(box), unbox), undefined); - test.equal(d3.median([NaN].map(box), unbox), undefined); - test.equal(d3.median([NaN, NaN].map(box), unbox), undefined); +it("median(array, f) returns undefined if the array contains no observed values", () => { + assert.strictEqual(median([].map(box), unbox), undefined); + assert.strictEqual(median([null].map(box), unbox), undefined); + assert.strictEqual(median([undefined].map(box), unbox), undefined); + assert.strictEqual(median([NaN].map(box), unbox), undefined); + assert.strictEqual(median([NaN, NaN].map(box), unbox), undefined); }); -tape("median(array, f) coerces strings to numbers", (test) => { - test.equal(d3.median(["1"].map(box), unbox), 1); - test.equal(d3.median(["5", "1", "2", "3", "4"].map(box), unbox), 3); - test.equal(d3.median(["20", "3"].map(box), unbox), 11.5); - test.equal(d3.median(["3", "20"].map(box), unbox), 11.5); - test.equal(d3.median(["2", "3", "20"].map(box), unbox), 3); - test.equal(d3.median(["20", "3", "2"].map(box), unbox), 3); +it("median(array, f) coerces strings to numbers", () => { + assert.strictEqual(median(["1"].map(box), unbox), 1); + assert.strictEqual(median(["5", "1", "2", "3", "4"].map(box), unbox), 3); + assert.strictEqual(median(["20", "3"].map(box), unbox), 11.5); + assert.strictEqual(median(["3", "20"].map(box), unbox), 11.5); + assert.strictEqual(median(["2", "3", "20"].map(box), unbox), 3); + assert.strictEqual(median(["20", "3", "2"].map(box), unbox), 3); }); -tape("median(array, f) coerces values exactly once", (test) => { +it("median(array, f) coerces values exactly once", () => { const array = [1, new OneTimeNumber(3)].map(box); - test.equal(d3.median(array, unbox), 2); - test.equal(d3.median(array, unbox), 1); + assert.strictEqual(median(array, unbox), 2); + assert.strictEqual(median(array, unbox), 1); }); -tape("median(array, f) passes the accessor d, i, and array", (test) => { +it("median(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.median(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + median(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("median(array, f) uses the global context", (test) => { +it("median(array, f) uses the undefined context", () => { const results = []; - d3.median([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + median([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/merge-test.js b/test/merge-test.js index 9526e7c3..8a0a6dee 100644 --- a/test/merge-test.js +++ b/test/merge-test.js @@ -1,44 +1,44 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {merge} from "../src/index.js"; -tape("merge(d3) merges an array of d3", (test) => { +it("merge(arrays) merges an array of arrays", () => { const a = {}, b = {}, c = {}, d = {}, e = {}, f = {}; - test.deepEqual(d3.merge([[a], [b, c], [d, e, f]]), [a, b, c, d, e, f]); + assert.deepStrictEqual(merge([[a], [b, c], [d, e, f]]), [a, b, c, d, e, f]); }); -tape("merge(d3) returns a new array when zero d3 are passed", (test) => { +it("merge(arrays) returns a new array when zero arrays are passed", () => { const input = []; - const output = d3.merge(input); - test.deepEqual(output, []); + const output = merge(input); + assert.deepStrictEqual(output, []); input.push([0.1]); - test.deepEqual(input, [[0.1]]); - test.deepEqual(output, []); + assert.deepStrictEqual(input, [[0.1]]); + assert.deepStrictEqual(output, []); }); -tape("merge(d3) returns a new array when one array is passed", (test) => { +it("merge(arrays) returns a new array when one array is passed", () => { const input = [[1, 2, 3]]; - const output = d3.merge(input); - test.deepEqual(output, [1, 2, 3]); + const output = merge(input); + assert.deepStrictEqual(output, [1, 2, 3]); input.push([4.1]); input[0].push(3.1); - test.deepEqual(input, [[1, 2, 3, 3.1], [4.1]]); - test.deepEqual(output, [1, 2, 3]); + assert.deepStrictEqual(input, [[1, 2, 3, 3.1], [4.1]]); + assert.deepStrictEqual(output, [1, 2, 3]); }); -tape("merge(d3) returns a new array when two or more d3 are passed", (test) => { +it("merge(arrays) returns a new array when two or more arrays are passed", () => { const input = [[1, 2, 3], [4, 5], [6]]; - const output = d3.merge(input); - test.deepEqual(output, [1, 2, 3, 4, 5, 6]); + const output = merge(input); + assert.deepStrictEqual(output, [1, 2, 3, 4, 5, 6]); input.push([7.1]); input[0].push(3.1); input[1].push(5.1); input[2].push(6.1); - test.deepEqual(input, [[1, 2, 3, 3.1], [4, 5, 5.1], [6, 6.1], [7.1]]); - test.deepEqual(output, [1, 2, 3, 4, 5, 6]); + assert.deepStrictEqual(input, [[1, 2, 3, 3.1], [4, 5, 5.1], [6, 6.1], [7.1]]); + assert.deepStrictEqual(output, [1, 2, 3, 4, 5, 6]); }); -tape("merge(d3) does not modify the input d3", (test) => { +it("merge(arrays) does not modify the input arrays", () => { const input = [[1, 2, 3], [4, 5], [6]]; - d3.merge(input); - test.deepEqual(input, [[1, 2, 3], [4, 5], [6]]); + merge(input); + assert.deepStrictEqual(input, [[1, 2, 3], [4, 5], [6]]); }); diff --git a/test/min-test.js b/test/min-test.js index b0fd1676..5ff8f595 100644 --- a/test/min-test.js +++ b/test/min-test.js @@ -1,93 +1,93 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {min} from "../src/index.js"; -tape("min(array) returns the least numeric value for numbers", (test) => { - test.deepEqual(d3.min([1]), 1); - test.deepEqual(d3.min([5, 1, 2, 3, 4]), 1); - test.deepEqual(d3.min([20, 3]), 3); - test.deepEqual(d3.min([3, 20]), 3); +it("min(array) returns the least numeric value for numbers", () => { + assert.deepStrictEqual(min([1]), 1); + assert.deepStrictEqual(min([5, 1, 2, 3, 4]), 1); + assert.deepStrictEqual(min([20, 3]), 3); + assert.deepStrictEqual(min([3, 20]), 3); }); -tape("min(array) returns the least lexicographic value for strings", (test) => { - test.deepEqual(d3.min(["c", "a", "b"]), "a"); - test.deepEqual(d3.min(["20", "3"]), "20"); - test.deepEqual(d3.min(["3", "20"]), "20"); +it("min(array) returns the least lexicographic value for strings", () => { + assert.deepStrictEqual(min(["c", "a", "b"]), "a"); + assert.deepStrictEqual(min(["20", "3"]), "20"); + assert.deepStrictEqual(min(["3", "20"]), "20"); }); -tape("min(array) ignores null, undefined and NaN", (test) => { +it("min(array) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.min([NaN, 1, 2, 3, 4, 5]), 1); - test.deepEqual(d3.min([o, 1, 2, 3, 4, 5]), 1); - test.deepEqual(d3.min([1, 2, 3, 4, 5, NaN]), 1); - test.deepEqual(d3.min([1, 2, 3, 4, 5, o]), 1); - test.deepEqual(d3.min([10, null, 3, undefined, 5, NaN]), 3); - test.deepEqual(d3.min([-1, null, -3, undefined, -5, NaN]), -5); + assert.deepStrictEqual(min([NaN, 1, 2, 3, 4, 5]), 1); + assert.deepStrictEqual(min([o, 1, 2, 3, 4, 5]), 1); + assert.deepStrictEqual(min([1, 2, 3, 4, 5, NaN]), 1); + assert.deepStrictEqual(min([1, 2, 3, 4, 5, o]), 1); + assert.deepStrictEqual(min([10, null, 3, undefined, 5, NaN]), 3); + assert.deepStrictEqual(min([-1, null, -3, undefined, -5, NaN]), -5); }); -tape("min(array) compares heterogenous types as numbers", (test) => { - test.equal(d3.min([20, "3"]), "3"); - test.equal(d3.min(["20", 3]), 3); - test.equal(d3.min([3, "20"]), 3); - test.equal(d3.min(["3", 20]), "3"); +it("min(array) compares heterogenous types as numbers", () => { + assert.strictEqual(min([20, "3"]), "3"); + assert.strictEqual(min(["20", 3]), 3); + assert.strictEqual(min([3, "20"]), 3); + assert.strictEqual(min(["3", 20]), "3"); }); -tape("min(array) returns undefined if the array contains no numbers", (test) => { - test.equal(d3.min([]), undefined); - test.equal(d3.min([null]), undefined); - test.equal(d3.min([undefined]), undefined); - test.equal(d3.min([NaN]), undefined); - test.equal(d3.min([NaN, NaN]), undefined); +it("min(array) returns undefined if the array contains no numbers", () => { + assert.strictEqual(min([]), undefined); + assert.strictEqual(min([null]), undefined); + assert.strictEqual(min([undefined]), undefined); + assert.strictEqual(min([NaN]), undefined); + assert.strictEqual(min([NaN, NaN]), undefined); }); -tape("min(array, f) returns the least numeric value for numbers", (test) => { - test.deepEqual(d3.min([1].map(box), unbox), 1); - test.deepEqual(d3.min([5, 1, 2, 3, 4].map(box), unbox), 1); - test.deepEqual(d3.min([20, 3].map(box), unbox), 3); - test.deepEqual(d3.min([3, 20].map(box), unbox), 3); +it("min(array, f) returns the least numeric value for numbers", () => { + assert.deepStrictEqual(min([1].map(box), unbox), 1); + assert.deepStrictEqual(min([5, 1, 2, 3, 4].map(box), unbox), 1); + assert.deepStrictEqual(min([20, 3].map(box), unbox), 3); + assert.deepStrictEqual(min([3, 20].map(box), unbox), 3); }); -tape("min(array, f) returns the least lexicographic value for strings", (test) => { - test.deepEqual(d3.min(["c", "a", "b"].map(box), unbox), "a"); - test.deepEqual(d3.min(["20", "3"].map(box), unbox), "20"); - test.deepEqual(d3.min(["3", "20"].map(box), unbox), "20"); +it("min(array, f) returns the least lexicographic value for strings", () => { + assert.deepStrictEqual(min(["c", "a", "b"].map(box), unbox), "a"); + assert.deepStrictEqual(min(["20", "3"].map(box), unbox), "20"); + assert.deepStrictEqual(min(["3", "20"].map(box), unbox), "20"); }); -tape("min(array, f) ignores null, undefined and NaN", (test) => { +it("min(array, f) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.min([NaN, 1, 2, 3, 4, 5].map(box), unbox), 1); - test.deepEqual(d3.min([o, 1, 2, 3, 4, 5].map(box), unbox), 1); - test.deepEqual(d3.min([1, 2, 3, 4, 5, NaN].map(box), unbox), 1); - test.deepEqual(d3.min([1, 2, 3, 4, 5, o].map(box), unbox), 1); - test.deepEqual(d3.min([10, null, 3, undefined, 5, NaN].map(box), unbox), 3); - test.deepEqual(d3.min([-1, null, -3, undefined, -5, NaN].map(box), unbox), -5); + assert.deepStrictEqual(min([NaN, 1, 2, 3, 4, 5].map(box), unbox), 1); + assert.deepStrictEqual(min([o, 1, 2, 3, 4, 5].map(box), unbox), 1); + assert.deepStrictEqual(min([1, 2, 3, 4, 5, NaN].map(box), unbox), 1); + assert.deepStrictEqual(min([1, 2, 3, 4, 5, o].map(box), unbox), 1); + assert.deepStrictEqual(min([10, null, 3, undefined, 5, NaN].map(box), unbox), 3); + assert.deepStrictEqual(min([-1, null, -3, undefined, -5, NaN].map(box), unbox), -5); }); -tape("min(array, f) compares heterogenous types as numbers", (test) => { - test.equal(d3.min([20, "3"].map(box), unbox), "3"); - test.equal(d3.min(["20", 3].map(box), unbox), 3); - test.equal(d3.min([3, "20"].map(box), unbox), 3); - test.equal(d3.min(["3", 20].map(box), unbox), "3"); +it("min(array, f) compares heterogenous types as numbers", () => { + assert.strictEqual(min([20, "3"].map(box), unbox), "3"); + assert.strictEqual(min(["20", 3].map(box), unbox), 3); + assert.strictEqual(min([3, "20"].map(box), unbox), 3); + assert.strictEqual(min(["3", 20].map(box), unbox), "3"); }); -tape("min(array, f) returns undefined if the array contains no observed values", (test) => { - test.equal(d3.min([].map(box), unbox), undefined); - test.equal(d3.min([null].map(box), unbox), undefined); - test.equal(d3.min([undefined].map(box), unbox), undefined); - test.equal(d3.min([NaN].map(box), unbox), undefined); - test.equal(d3.min([NaN, NaN].map(box), unbox), undefined); +it("min(array, f) returns undefined if the array contains no observed values", () => { + assert.strictEqual(min([].map(box), unbox), undefined); + assert.strictEqual(min([null].map(box), unbox), undefined); + assert.strictEqual(min([undefined].map(box), unbox), undefined); + assert.strictEqual(min([NaN].map(box), unbox), undefined); + assert.strictEqual(min([NaN, NaN].map(box), unbox), undefined); }); -tape("min(array, f) passes the accessor d, i, and array", (test) => { +it("min(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.min(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + min(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("min(array, f) uses the global context", (test) => { +it("min(array, f) uses the undefined context", () => { const results = []; - d3.min([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + min([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/minIndex-test.js b/test/minIndex-test.js index 378b07c2..a4a332dd 100644 --- a/test/minIndex-test.js +++ b/test/minIndex-test.js @@ -1,93 +1,93 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {minIndex} from "../src/index.js"; -tape("minIndex(array) returns the index of the least numeric value for numbers", (test) => { - test.deepEqual(d3.minIndex([1]), 0); - test.deepEqual(d3.minIndex([5, 1, 2, 3, 4]), 1); - test.deepEqual(d3.minIndex([20, 3]), 1); - test.deepEqual(d3.minIndex([3, 20]), 0); +it("minIndex(array) returns the index of the least numeric value for numbers", () => { + assert.deepStrictEqual(minIndex([1]), 0); + assert.deepStrictEqual(minIndex([5, 1, 2, 3, 4]), 1); + assert.deepStrictEqual(minIndex([20, 3]), 1); + assert.deepStrictEqual(minIndex([3, 20]), 0); }); -tape("minIndex(array) returns the index of the least lexicographic value for strings", (test) => { - test.deepEqual(d3.minIndex(["c", "a", "b"]), 1); - test.deepEqual(d3.minIndex(["20", "3"]), 0); - test.deepEqual(d3.minIndex(["3", "20"]), 1); +it("minIndex(array) returns the index of the least lexicographic value for strings", () => { + assert.deepStrictEqual(minIndex(["c", "a", "b"]), 1); + assert.deepStrictEqual(minIndex(["20", "3"]), 0); + assert.deepStrictEqual(minIndex(["3", "20"]), 1); }); -tape("minIndex(array) ignores null, undefined and NaN", (test) => { +it("minIndex(array) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.minIndex([NaN, 1, 2, 3, 4, 5]), 1); - test.deepEqual(d3.minIndex([o, 1, 2, 3, 4, 5]), 1); - test.deepEqual(d3.minIndex([1, 2, 3, 4, 5, NaN]), 0); - test.deepEqual(d3.minIndex([1, 2, 3, 4, 5, o]), 0); - test.deepEqual(d3.minIndex([10, null, 3, undefined, 5, NaN]), 2); - test.deepEqual(d3.minIndex([-1, null, -3, undefined, -5, NaN]), 4); + assert.deepStrictEqual(minIndex([NaN, 1, 2, 3, 4, 5]), 1); + assert.deepStrictEqual(minIndex([o, 1, 2, 3, 4, 5]), 1); + assert.deepStrictEqual(minIndex([1, 2, 3, 4, 5, NaN]), 0); + assert.deepStrictEqual(minIndex([1, 2, 3, 4, 5, o]), 0); + assert.deepStrictEqual(minIndex([10, null, 3, undefined, 5, NaN]), 2); + assert.deepStrictEqual(minIndex([-1, null, -3, undefined, -5, NaN]), 4); }); -tape("minIndex(array) compares heterogenous types as numbers", (test) => { - test.equal(d3.minIndex([20, "3"]), 1); - test.equal(d3.minIndex(["20", 3]), 1); - test.equal(d3.minIndex([3, "20"]), 0); - test.equal(d3.minIndex(["3", 20]), 0); +it("minIndex(array) compares heterogenous types as numbers", () => { + assert.strictEqual(minIndex([20, "3"]), 1); + assert.strictEqual(minIndex(["20", 3]), 1); + assert.strictEqual(minIndex([3, "20"]), 0); + assert.strictEqual(minIndex(["3", 20]), 0); }); -tape("minIndex(array) returns -1 if the array contains no numbers", (test) => { - test.equal(d3.minIndex([]), -1); - test.equal(d3.minIndex([null]), -1); - test.equal(d3.minIndex([undefined]), -1); - test.equal(d3.minIndex([NaN]), -1); - test.equal(d3.minIndex([NaN, NaN]), -1); +it("minIndex(array) returns -1 if the array contains no numbers", () => { + assert.strictEqual(minIndex([]), -1); + assert.strictEqual(minIndex([null]), -1); + assert.strictEqual(minIndex([undefined]), -1); + assert.strictEqual(minIndex([NaN]), -1); + assert.strictEqual(minIndex([NaN, NaN]), -1); }); -tape("minIndex(array, f) returns the index of the least numeric value for numbers", (test) => { - test.deepEqual(d3.minIndex([1].map(box), unbox), 0); - test.deepEqual(d3.minIndex([5, 1, 2, 3, 4].map(box), unbox), 1); - test.deepEqual(d3.minIndex([20, 3].map(box), unbox), 1); - test.deepEqual(d3.minIndex([3, 20].map(box), unbox), 0); +it("minIndex(array, f) returns the index of the least numeric value for numbers", () => { + assert.deepStrictEqual(minIndex([1].map(box), unbox), 0); + assert.deepStrictEqual(minIndex([5, 1, 2, 3, 4].map(box), unbox), 1); + assert.deepStrictEqual(minIndex([20, 3].map(box), unbox), 1); + assert.deepStrictEqual(minIndex([3, 20].map(box), unbox), 0); }); -tape("minIndex(array, f) returns the index of the least lexicographic value for strings", (test) => { - test.deepEqual(d3.minIndex(["c", "a", "b"].map(box), unbox), 1); - test.deepEqual(d3.minIndex(["20", "3"].map(box), unbox), 0); - test.deepEqual(d3.minIndex(["3", "20"].map(box), unbox), 1); +it("minIndex(array, f) returns the index of the least lexicographic value for strings", () => { + assert.deepStrictEqual(minIndex(["c", "a", "b"].map(box), unbox), 1); + assert.deepStrictEqual(minIndex(["20", "3"].map(box), unbox), 0); + assert.deepStrictEqual(minIndex(["3", "20"].map(box), unbox), 1); }); -tape("minIndex(array, f) ignores null, undefined and NaN", (test) => { +it("minIndex(array, f) ignores null, undefined and NaN", () => { const o = {valueOf: () => NaN}; - test.deepEqual(d3.minIndex([NaN, 1, 2, 3, 4, 5].map(box), unbox), 1); - test.deepEqual(d3.minIndex([o, 1, 2, 3, 4, 5].map(box), unbox), 1); - test.deepEqual(d3.minIndex([1, 2, 3, 4, 5, NaN].map(box), unbox), 0); - test.deepEqual(d3.minIndex([1, 2, 3, 4, 5, o].map(box), unbox), 0); - test.deepEqual(d3.minIndex([10, null, 3, undefined, 5, NaN].map(box), unbox), 2); - test.deepEqual(d3.minIndex([-1, null, -3, undefined, -5, NaN].map(box), unbox), 4); + assert.deepStrictEqual(minIndex([NaN, 1, 2, 3, 4, 5].map(box), unbox), 1); + assert.deepStrictEqual(minIndex([o, 1, 2, 3, 4, 5].map(box), unbox), 1); + assert.deepStrictEqual(minIndex([1, 2, 3, 4, 5, NaN].map(box), unbox), 0); + assert.deepStrictEqual(minIndex([1, 2, 3, 4, 5, o].map(box), unbox), 0); + assert.deepStrictEqual(minIndex([10, null, 3, undefined, 5, NaN].map(box), unbox), 2); + assert.deepStrictEqual(minIndex([-1, null, -3, undefined, -5, NaN].map(box), unbox), 4); }); -tape("minIndex(array, f) compares heterogenous types as numbers", (test) => { - test.equal(d3.minIndex([20, "3"].map(box), unbox), 1); - test.equal(d3.minIndex(["20", 3].map(box), unbox), 1); - test.equal(d3.minIndex([3, "20"].map(box), unbox), 0); - test.equal(d3.minIndex(["3", 20].map(box), unbox), 0); +it("minIndex(array, f) compares heterogenous types as numbers", () => { + assert.strictEqual(minIndex([20, "3"].map(box), unbox), 1); + assert.strictEqual(minIndex(["20", 3].map(box), unbox), 1); + assert.strictEqual(minIndex([3, "20"].map(box), unbox), 0); + assert.strictEqual(minIndex(["3", 20].map(box), unbox), 0); }); -tape("minIndex(array, f) returns -1 if the array contains no observed values", (test) => { - test.equal(d3.minIndex([].map(box), unbox), -1); - test.equal(d3.minIndex([null].map(box), unbox), -1); - test.equal(d3.minIndex([undefined].map(box), unbox), -1); - test.equal(d3.minIndex([NaN].map(box), unbox), -1); - test.equal(d3.minIndex([NaN, NaN].map(box), unbox), -1); +it("minIndex(array, f) returns -1 if the array contains no observed values", () => { + assert.strictEqual(minIndex([].map(box), unbox), -1); + assert.strictEqual(minIndex([null].map(box), unbox), -1); + assert.strictEqual(minIndex([undefined].map(box), unbox), -1); + assert.strictEqual(minIndex([NaN].map(box), unbox), -1); + assert.strictEqual(minIndex([NaN, NaN].map(box), unbox), -1); }); -tape("minIndex(array, f) passes the accessor d, i, and array", (test) => { +it("minIndex(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.minIndex(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + minIndex(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("minIndex(array, f) uses the global context", (test) => { +it("minIndex(array, f) uses the undefined context", () => { const results = []; - d3.minIndex([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + minIndex([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/nice-test.js b/test/nice-test.js index 7dd5a49e..bbc4f708 100644 --- a/test/nice-test.js +++ b/test/nice-test.js @@ -1,46 +1,46 @@ -const tape = require("tape-await"); -const array = require("../"); +import assert from "assert"; +import {nice} from "../src/index.js"; -tape("nice(start, stop, count) returns [start, stop] if any argument is NaN", (test) => { - test.deepEqual(array.nice(NaN, 1, 1), [NaN, 1]); - test.deepEqual(array.nice(0, NaN, 1), [0, NaN]); - test.deepEqual(array.nice(0, 1, NaN), [0, 1]); - test.deepEqual(array.nice(NaN, NaN, 1), [NaN, NaN]); - test.deepEqual(array.nice(0, NaN, NaN), [0, NaN]); - test.deepEqual(array.nice(NaN, 1, NaN), [NaN, 1]); - test.deepEqual(array.nice(NaN, NaN, NaN), [NaN, NaN]); +it("nice(start, stop, count) returns [start, stop] if any argument is NaN", () => { + assert.deepStrictEqual(nice(NaN, 1, 1), [NaN, 1]); + assert.deepStrictEqual(nice(0, NaN, 1), [0, NaN]); + assert.deepStrictEqual(nice(0, 1, NaN), [0, 1]); + assert.deepStrictEqual(nice(NaN, NaN, 1), [NaN, NaN]); + assert.deepStrictEqual(nice(0, NaN, NaN), [0, NaN]); + assert.deepStrictEqual(nice(NaN, 1, NaN), [NaN, 1]); + assert.deepStrictEqual(nice(NaN, NaN, NaN), [NaN, NaN]); }); -tape("nice(start, stop, count) returns [start, stop] if start === stop", (test) => { - test.deepEqual(array.nice(1, 1, -1), [1, 1]); - test.deepEqual(array.nice(1, 1, 0), [1, 1]); - test.deepEqual(array.nice(1, 1, NaN), [1, 1]); - test.deepEqual(array.nice(1, 1, 1), [1, 1]); - test.deepEqual(array.nice(1, 1, 10), [1, 1]); +it("nice(start, stop, count) returns [start, stop] if start === stop", () => { + assert.deepStrictEqual(nice(1, 1, -1), [1, 1]); + assert.deepStrictEqual(nice(1, 1, 0), [1, 1]); + assert.deepStrictEqual(nice(1, 1, NaN), [1, 1]); + assert.deepStrictEqual(nice(1, 1, 1), [1, 1]); + assert.deepStrictEqual(nice(1, 1, 10), [1, 1]); }); -tape("nice(start, stop, count) returns [start, stop] if count is not positive", (test) => { - test.deepEqual(array.nice(0, 1, -1), [0, 1]); - test.deepEqual(array.nice(0, 1, 0), [0, 1]); +it("nice(start, stop, count) returns [start, stop] if count is not positive", () => { + assert.deepStrictEqual(nice(0, 1, -1), [0, 1]); + assert.deepStrictEqual(nice(0, 1, 0), [0, 1]); }); -tape("nice(start, stop, count) returns [start, stop] if count is infinity", (test) => { - test.deepEqual(array.nice(0, 1, Infinity), [0, 1]); +it("nice(start, stop, count) returns [start, stop] if count is infinity", () => { + assert.deepStrictEqual(nice(0, 1, Infinity), [0, 1]); }); -tape("nice(start, stop, count) returns the expected values", (test) => { - test.deepEqual(array.nice(0.132, 0.876, 1000), [0.132, 0.876]); - test.deepEqual(array.nice(0.132, 0.876, 100), [0.13, 0.88]); - test.deepEqual(array.nice(0.132, 0.876, 30), [0.12, 0.88]); - test.deepEqual(array.nice(0.132, 0.876, 10), [0.1, 0.9]); - test.deepEqual(array.nice(0.132, 0.876, 6), [0.1, 0.9]); - test.deepEqual(array.nice(0.132, 0.876, 5), [0, 1]); - test.deepEqual(array.nice(0.132, 0.876, 1), [0, 1]); - test.deepEqual(array.nice(132, 876, 1000), [132, 876]); - test.deepEqual(array.nice(132, 876, 100), [130, 880]); - test.deepEqual(array.nice(132, 876, 30), [120, 880]); - test.deepEqual(array.nice(132, 876, 10), [100, 900]); - test.deepEqual(array.nice(132, 876, 6), [100, 900]); - test.deepEqual(array.nice(132, 876, 5), [0, 1000]); - test.deepEqual(array.nice(132, 876, 1), [0, 1000]); +it("nice(start, stop, count) returns the expected values", () => { + assert.deepStrictEqual(nice(0.132, 0.876, 1000), [0.132, 0.876]); + assert.deepStrictEqual(nice(0.132, 0.876, 100), [0.13, 0.88]); + assert.deepStrictEqual(nice(0.132, 0.876, 30), [0.12, 0.88]); + assert.deepStrictEqual(nice(0.132, 0.876, 10), [0.1, 0.9]); + assert.deepStrictEqual(nice(0.132, 0.876, 6), [0.1, 0.9]); + assert.deepStrictEqual(nice(0.132, 0.876, 5), [0, 1]); + assert.deepStrictEqual(nice(0.132, 0.876, 1), [0, 1]); + assert.deepStrictEqual(nice(132, 876, 1000), [132, 876]); + assert.deepStrictEqual(nice(132, 876, 100), [130, 880]); + assert.deepStrictEqual(nice(132, 876, 30), [120, 880]); + assert.deepStrictEqual(nice(132, 876, 10), [100, 900]); + assert.deepStrictEqual(nice(132, 876, 6), [100, 900]); + assert.deepStrictEqual(nice(132, 876, 5), [0, 1000]); + assert.deepStrictEqual(nice(132, 876, 1), [0, 1000]); }); diff --git a/test/pairs-test.js b/test/pairs-test.js index e7b7b41f..c99cd3f8 100644 --- a/test/pairs-test.js +++ b/test/pairs-test.js @@ -1,23 +1,23 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {pairs} from "../src/index.js"; -tape("pairs(array) returns the empty array if input array has fewer than two elements", (test) => { - test.deepEqual(d3.pairs([]), []); - test.deepEqual(d3.pairs([1]), []); +it("pairs(array) returns the empty array if input array has fewer than two elements", () => { + assert.deepStrictEqual(pairs([]), []); + assert.deepStrictEqual(pairs([1]), []); }); -tape("pairs(array) returns pairs of adjacent elements in the given array", (test) => { +it("pairs(array) returns pairs of adjacent elements in the given array", () => { const a = {}, b = {}, c = {}, d = {}; - test.deepEqual(d3.pairs([1, 2]), [[1, 2]]); - test.deepEqual(d3.pairs([1, 2, 3]), [[1, 2], [2, 3]]); - test.deepEqual(d3.pairs([a, b, c, d]), [[a, b], [b, c], [c, d]]); + assert.deepStrictEqual(pairs([1, 2]), [[1, 2]]); + assert.deepStrictEqual(pairs([1, 2, 3]), [[1, 2], [2, 3]]); + assert.deepStrictEqual(pairs([a, b, c, d]), [[a, b], [b, c], [c, d]]); }); -tape("pairs(array, f) invokes the function f for each pair of adjacent elements", (test) => { - test.deepEqual(d3.pairs([1, 3, 7], (a, b) => b - a), [2, 4]); +it("pairs(array, f) invokes the function f for each pair of adjacent elements", () => { + assert.deepStrictEqual(pairs([1, 3, 7], (a, b) => b - a), [2, 4]); }); -tape("pairs(array) includes null or undefined elements in pairs", (test) => { - test.deepEqual(d3.pairs([1, null, 2]), [[1, null], [null, 2]]); - test.deepEqual(d3.pairs([1, 2, undefined]), [[1, 2], [2, undefined]]); +it("pairs(array) includes null or undefined elements in pairs", () => { + assert.deepStrictEqual(pairs([1, null, 2]), [[1, null], [null, 2]]); + assert.deepStrictEqual(pairs([1, 2, undefined]), [[1, 2], [2, undefined]]); }); diff --git a/test/permute-test.js b/test/permute-test.js index 97d80c60..a8297472 100644 --- a/test/permute-test.js +++ b/test/permute-test.js @@ -1,50 +1,50 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {permute} from "../src/index.js"; -tape("permute(…) permutes according to the specified index", (test) => { - test.deepEqual(d3.permute([3, 4, 5], [2, 1, 0]), [5, 4, 3]); - test.deepEqual(d3.permute([3, 4, 5], [2, 0, 1]), [5, 3, 4]); - test.deepEqual(d3.permute([3, 4, 5], [0, 1, 2]), [3, 4, 5]); +it("permute(…) permutes according to the specified index", () => { + assert.deepStrictEqual(permute([3, 4, 5], [2, 1, 0]), [5, 4, 3]); + assert.deepStrictEqual(permute([3, 4, 5], [2, 0, 1]), [5, 3, 4]); + assert.deepStrictEqual(permute([3, 4, 5], [0, 1, 2]), [3, 4, 5]); }); -tape("permute(…) does not modify the input array", (test) => { +it("permute(…) does not modify the input array", () => { const input = [3, 4, 5]; - d3.permute(input, [2, 1, 0]); - test.deepEqual(input, [3, 4, 5]); + permute(input, [2, 1, 0]); + assert.deepStrictEqual(input, [3, 4, 5]); }); -tape("permute(…) can duplicate input values", (test) => { - test.deepEqual(d3.permute([3, 4, 5], [0, 1, 0]), [3, 4, 3]); - test.deepEqual(d3.permute([3, 4, 5], [2, 2, 2]), [5, 5, 5]); - test.deepEqual(d3.permute([3, 4, 5], [0, 1, 1]), [3, 4, 4]); +it("permute(…) can duplicate input values", () => { + assert.deepStrictEqual(permute([3, 4, 5], [0, 1, 0]), [3, 4, 3]); + assert.deepStrictEqual(permute([3, 4, 5], [2, 2, 2]), [5, 5, 5]); + assert.deepStrictEqual(permute([3, 4, 5], [0, 1, 1]), [3, 4, 4]); }); -tape("permute(…) can return more elements", (test) => { - test.deepEqual(d3.permute([3, 4, 5], [0, 0, 1, 2]), [3, 3, 4, 5]); - test.deepEqual(d3.permute([3, 4, 5], [0, 1, 1, 1]), [3, 4, 4, 4]); +it("permute(…) can return more elements", () => { + assert.deepStrictEqual(permute([3, 4, 5], [0, 0, 1, 2]), [3, 3, 4, 5]); + assert.deepStrictEqual(permute([3, 4, 5], [0, 1, 1, 1]), [3, 4, 4, 4]); }); -tape("permute(…) can return fewer elements", (test) => { - test.deepEqual(d3.permute([3, 4, 5], [0]), [3]); - test.deepEqual(d3.permute([3, 4, 5], [1, 2]), [4, 5]); - test.deepEqual(d3.permute([3, 4, 5], []), []); +it("permute(…) can return fewer elements", () => { + assert.deepStrictEqual(permute([3, 4, 5], [0]), [3]); + assert.deepStrictEqual(permute([3, 4, 5], [1, 2]), [4, 5]); + assert.deepStrictEqual(permute([3, 4, 5], []), []); }); -tape("permute(…) can return undefined elements", (test) => { - test.deepEqual(d3.permute([3, 4, 5], [10]), [undefined]); - test.deepEqual(d3.permute([3, 4, 5], [-1]), [undefined]); - test.deepEqual(d3.permute([3, 4, 5], [0, -1]), [3, undefined]); +it("permute(…) can return undefined elements", () => { + assert.deepStrictEqual(permute([3, 4, 5], [10]), [undefined]); + assert.deepStrictEqual(permute([3, 4, 5], [-1]), [undefined]); + assert.deepStrictEqual(permute([3, 4, 5], [0, -1]), [3, undefined]); }); -tape("permute(…) can take an object as the source", (test) => { - test.deepEqual(d3.permute({foo: 1, bar: 2}, ["bar", "foo"]), [2, 1]); +it("permute(…) can take an object as the source", () => { + assert.deepStrictEqual(permute({foo: 1, bar: 2}, ["bar", "foo"]), [2, 1]); }); -tape("permute(…) can take a typed array as the source", (test) => { - test.deepEqual(d3.permute(Float32Array.of(1, 2), [0, 0, 1, 0]), [1, 1, 2, 1]); - test.equal(Array.isArray(d3.permute(Float32Array.of(1, 2), [0])), true); +it("permute(…) can take a typed array as the source", () => { + assert.deepStrictEqual(permute(Float32Array.of(1, 2), [0, 0, 1, 0]), [1, 1, 2, 1]); + assert.strictEqual(Array.isArray(permute(Float32Array.of(1, 2), [0])), true); }); -tape("permute(…) can take an iterable as the keys", (test) => { - test.deepEqual(d3.permute({foo: 1, bar: 2}, new Set(["bar", "foo"])), [2, 1]); +it("permute(…) can take an iterable as the keys", () => { + assert.deepStrictEqual(permute({foo: 1, bar: 2}, new Set(["bar", "foo"])), [2, 1]); }); diff --git a/test/quantile-test.js b/test/quantile-test.js index 8564cd4b..a00a07b3 100644 --- a/test/quantile-test.js +++ b/test/quantile-test.js @@ -1,86 +1,86 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {quantile, quantileSorted} from "../src/index.js"; -tape("quantileSorted(array, p) requires sorted numeric input, quantile doesn't", (test) => { - test.equal(d3.quantileSorted([1, 2, 3, 4], 0), 1); - test.equal(d3.quantileSorted([1, 2, 3, 4], 1), 4); - test.equal(d3.quantileSorted([4, 3, 2, 1], 0), 4); - test.equal(d3.quantileSorted([4, 3, 2, 1], 1), 1); - test.equal(d3.quantile([1, 2, 3, 4], 0), 1); - test.equal(d3.quantile([1, 2, 3, 4], 1), 4); - test.equal(d3.quantile([4, 3, 2, 1], 0), 1); - test.equal(d3.quantile([4, 3, 2, 1], 1), 4); +it("quantileSorted(array, p) requires sorted numeric input, quantile doesn't", () => { + assert.strictEqual(quantileSorted([1, 2, 3, 4], 0), 1); + assert.strictEqual(quantileSorted([1, 2, 3, 4], 1), 4); + assert.strictEqual(quantileSorted([4, 3, 2, 1], 0), 4); + assert.strictEqual(quantileSorted([4, 3, 2, 1], 1), 1); + assert.strictEqual(quantile([1, 2, 3, 4], 0), 1); + assert.strictEqual(quantile([1, 2, 3, 4], 1), 4); + assert.strictEqual(quantile([4, 3, 2, 1], 0), 1); + assert.strictEqual(quantile([4, 3, 2, 1], 1), 4); }); -tape("quantile() accepts an iterable", (test) => { - test.equal(d3.quantile(new Set([1, 2, 3, 4]), 1), 4); +it("quantile() accepts an iterable", () => { + assert.strictEqual(quantile(new Set([1, 2, 3, 4]), 1), 4); }); -tape("quantile(array, p) uses the R-7 method", (test) => { +it("quantile(array, p) uses the R-7 method", () => { const even = [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]; - test.equal(d3.quantile(even, 0), 3); - test.equal(d3.quantile(even, 0.25), 7.25); - test.equal(d3.quantile(even, 0.5), 9); - test.equal(d3.quantile(even, 0.75), 14.5); - test.equal(d3.quantile(even, 1), 20); + assert.strictEqual(quantile(even, 0), 3); + assert.strictEqual(quantile(even, 0.25), 7.25); + assert.strictEqual(quantile(even, 0.5), 9); + assert.strictEqual(quantile(even, 0.75), 14.5); + assert.strictEqual(quantile(even, 1), 20); const odd = [3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20]; - test.equal(d3.quantile(odd, 0), 3); - test.equal(d3.quantile(odd, 0.25), 7.5); - test.equal(d3.quantile(odd, 0.5), 9); - test.equal(d3.quantile(odd, 0.75), 14); - test.equal(d3.quantile(odd, 1), 20); + assert.strictEqual(quantile(odd, 0), 3); + assert.strictEqual(quantile(odd, 0.25), 7.5); + assert.strictEqual(quantile(odd, 0.5), 9); + assert.strictEqual(quantile(odd, 0.75), 14); + assert.strictEqual(quantile(odd, 1), 20); }); -tape("quantile(array, p) coerces values to numbers", (test) => { +it("quantile(array, p) coerces values to numbers", () => { const strings = ["1", "2", "3", "4"]; - test.equal(d3.quantile(strings, 1 / 3), 2); - test.equal(d3.quantile(strings, 1 / 2), 2.5); - test.equal(d3.quantile(strings, 2 / 3), 3); + assert.strictEqual(quantile(strings, 1 / 3), 2); + assert.strictEqual(quantile(strings, 1 / 2), 2.5); + assert.strictEqual(quantile(strings, 2 / 3), 3); const dates = [new Date(Date.UTC(2011, 0, 1)), new Date(Date.UTC(2012, 0, 1))]; - test.equal(d3.quantile(dates, 0), +new Date(Date.UTC(2011, 0, 1))); - test.equal(d3.quantile(dates, 1 / 2), +new Date(Date.UTC(2011, 6, 2, 12))); - test.equal(d3.quantile(dates, 1), +new Date(Date.UTC(2012, 0, 1))); + assert.strictEqual(quantile(dates, 0), +new Date(Date.UTC(2011, 0, 1))); + assert.strictEqual(quantile(dates, 1 / 2), +new Date(Date.UTC(2011, 6, 2, 12))); + assert.strictEqual(quantile(dates, 1), +new Date(Date.UTC(2012, 0, 1))); }); -tape("quantile(array, p) returns an exact value for integer p-values", (test) => { +it("quantile(array, p) returns an exact value for integer p-values", () => { const data = [1, 2, 3, 4]; - test.equal(d3.quantile(data, 1 / 3), 2); - test.equal(d3.quantile(data, 2 / 3), 3); + assert.strictEqual(quantile(data, 1 / 3), 2); + assert.strictEqual(quantile(data, 2 / 3), 3); }); -tape("quantile(array, p) returns the expected value for integer or fractional p", (test) => { +it("quantile(array, p) returns the expected value for integer or fractional p", () => { const data = [3, 1, 2, 4, 0]; - test.equal(d3.quantile(data, 0 / 4), 0); - test.equal(d3.quantile(data, 0.1 / 4), 0.1); - test.equal(d3.quantile(data, 1 / 4), 1); - test.equal(d3.quantile(data, 1.5 / 4), 1.5); - test.equal(d3.quantile(data, 2 / 4), 2); - test.equal(d3.quantile(data, 2.5 / 4), 2.5); - test.equal(d3.quantile(data, 3 / 4), 3); - test.equal(d3.quantile(data, 3.2 / 4), 3.2); - test.equal(d3.quantile(data, 4 / 4), 4); + assert.strictEqual(quantile(data, 0 / 4), 0); + assert.strictEqual(quantile(data, 0.1 / 4), 0.1); + assert.strictEqual(quantile(data, 1 / 4), 1); + assert.strictEqual(quantile(data, 1.5 / 4), 1.5); + assert.strictEqual(quantile(data, 2 / 4), 2); + assert.strictEqual(quantile(data, 2.5 / 4), 2.5); + assert.strictEqual(quantile(data, 3 / 4), 3); + assert.strictEqual(quantile(data, 3.2 / 4), 3.2); + assert.strictEqual(quantile(data, 4 / 4), 4); }); -tape("quantile(array, p) returns the first value for p = 0", (test) => { +it("quantile(array, p) returns the first value for p = 0", () => { const data = [1, 2, 3, 4]; - test.equal(d3.quantile(data, 0), 1); + assert.strictEqual(quantile(data, 0), 1); }); -tape("quantile(array, p) returns the last value for p = 1", (test) => { +it("quantile(array, p) returns the last value for p = 1", () => { const data = [1, 2, 3, 4]; - test.equal(d3.quantile(data, 1), 4); + assert.strictEqual(quantile(data, 1), 4); }); -tape("quantile(array, p, f) observes the specified accessor", (test) => { - test.equal(d3.quantile([1, 2, 3, 4].map(box), 0.5, unbox), 2.5); - test.equal(d3.quantile([1, 2, 3, 4].map(box), 0, unbox), 1); - test.equal(d3.quantile([1, 2, 3, 4].map(box), 1, unbox), 4); - test.equal(d3.quantile([2].map(box), 0, unbox), 2); - test.equal(d3.quantile([2].map(box), 0.5, unbox), 2); - test.equal(d3.quantile([2].map(box), 1, unbox), 2); - test.equal(d3.quantile([], 0, unbox), undefined); - test.equal(d3.quantile([], 0.5, unbox), undefined); - test.equal(d3.quantile([], 1, unbox), undefined); +it("quantile(array, p, f) observes the specified accessor", () => { + assert.strictEqual(quantile([1, 2, 3, 4].map(box), 0.5, unbox), 2.5); + assert.strictEqual(quantile([1, 2, 3, 4].map(box), 0, unbox), 1); + assert.strictEqual(quantile([1, 2, 3, 4].map(box), 1, unbox), 4); + assert.strictEqual(quantile([2].map(box), 0, unbox), 2); + assert.strictEqual(quantile([2].map(box), 0.5, unbox), 2); + assert.strictEqual(quantile([2].map(box), 1, unbox), 2); + assert.strictEqual(quantile([], 0, unbox), undefined); + assert.strictEqual(quantile([], 0.5, unbox), undefined); + assert.strictEqual(quantile([], 1, unbox), undefined); }); function box(value) { diff --git a/test/range-test.js b/test/range-test.js index 1ddc8414..306f5787 100644 --- a/test/range-test.js +++ b/test/range-test.js @@ -1,124 +1,125 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {range} from "../src/index.js"; -tape("range(stop) returns [0, 1, 2, … stop - 1]", (test) => { - test.deepEqual(d3.range(5), [0, 1, 2, 3, 4]); - test.deepEqual(d3.range(2.01), [0, 1, 2]); - test.deepEqual(d3.range(1), [0]); - test.deepEqual(d3.range(.5), [0]); +it("range(stop) returns [0, 1, 2, … stop - 1]", () => { + assert.deepStrictEqual(range(5), [0, 1, 2, 3, 4]); + assert.deepStrictEqual(range(2.01), [0, 1, 2]); + assert.deepStrictEqual(range(1), [0]); + assert.deepStrictEqual(range(.5), [0]); }); -tape("range(stop) returns an empty array if stop <= 0", (test) => { - test.deepEqual(d3.range(0), []); - test.deepEqual(d3.range(-0.5), []); - test.deepEqual(d3.range(-1), []); +it("range(stop) returns an empty array if stop <= 0", () => { + assert.deepStrictEqual(range(0), []); + assert.deepStrictEqual(range(-0.5), []); + assert.deepStrictEqual(range(-1), []); }); -tape("range(stop) returns an empty array if stop is NaN", (test) => { - test.deepEqual(d3.range(NaN), []); - test.deepEqual(d3.range(), []); +it("range(stop) returns an empty array if stop is NaN", () => { + assert.deepStrictEqual(range(NaN), []); + assert.deepStrictEqual(range(), []); }); -tape("range(start, stop) returns [start, start + 1, … stop - 1]", (test) => { - test.deepEqual(d3.range(0, 5), [0, 1, 2, 3, 4]); - test.deepEqual(d3.range(2, 5), [2, 3, 4]); - test.deepEqual(d3.range(2.5, 5), [2.5, 3.5, 4.5]); - test.deepEqual(d3.range(-1, 3), [-1, 0, 1, 2]); +it("range(start, stop) returns [start, start + 1, … stop - 1]", () => { + assert.deepStrictEqual(range(0, 5), [0, 1, 2, 3, 4]); + assert.deepStrictEqual(range(2, 5), [2, 3, 4]); + assert.deepStrictEqual(range(2.5, 5), [2.5, 3.5, 4.5]); + assert.deepStrictEqual(range(-1, 3), [-1, 0, 1, 2]); }); -tape("range(start, stop) returns an empty array if start or stop is NaN", (test) => { - test.deepEqual(d3.range(0, NaN), []); - test.deepEqual(d3.range(1, NaN), []); - test.deepEqual(d3.range(-1, NaN), []); - test.deepEqual(d3.range(0, undefined), []); - test.deepEqual(d3.range(1, undefined), []); - test.deepEqual(d3.range(-1, undefined), []); - test.deepEqual(d3.range(NaN, 0), []); - test.deepEqual(d3.range(NaN, 1), []); - test.deepEqual(d3.range(NaN, -1), []); - test.deepEqual(d3.range(undefined, 0), []); - test.deepEqual(d3.range(undefined, 1), []); - test.deepEqual(d3.range(undefined, -1), []); - test.deepEqual(d3.range(NaN, NaN), []); - test.deepEqual(d3.range(undefined, undefined), []); +it("range(start, stop) returns an empty array if start or stop is NaN", () => { + assert.deepStrictEqual(range(0, NaN), []); + assert.deepStrictEqual(range(1, NaN), []); + assert.deepStrictEqual(range(-1, NaN), []); + assert.deepStrictEqual(range(0, undefined), []); + assert.deepStrictEqual(range(1, undefined), []); + assert.deepStrictEqual(range(-1, undefined), []); + assert.deepStrictEqual(range(NaN, 0), []); + assert.deepStrictEqual(range(NaN, 1), []); + assert.deepStrictEqual(range(NaN, -1), []); + assert.deepStrictEqual(range(undefined, 0), []); + assert.deepStrictEqual(range(undefined, 1), []); + assert.deepStrictEqual(range(undefined, -1), []); + assert.deepStrictEqual(range(NaN, NaN), []); + assert.deepStrictEqual(range(undefined, undefined), []); }); -tape("range(start, stop) returns an empty array if start >= stop", (test) => { - test.deepEqual(d3.range(0, 0), []); - test.deepEqual(d3.range(5, 5), []); - test.deepEqual(d3.range(6, 5), []); - test.deepEqual(d3.range(10, 10), []); - test.deepEqual(d3.range(20, 10), []); +it("range(start, stop) returns an empty array if start >= stop", () => { + assert.deepStrictEqual(range(0, 0), []); + assert.deepStrictEqual(range(5, 5), []); + assert.deepStrictEqual(range(6, 5), []); + assert.deepStrictEqual(range(10, 10), []); + assert.deepStrictEqual(range(20, 10), []); }); -tape("range(start, stop, step) returns [start, start + step, start + 2 * step, … stop - step]", (test) => { - test.deepEqual(d3.range(0, 5, 1), [0, 1, 2, 3, 4]); - test.deepEqual(d3.range(0, 5, 2), [0, 2, 4]); - test.deepEqual(d3.range(2, 5, 2), [2, 4]); - test.deepEqual(d3.range(-1, 3, 2), [-1, 1]); +it("range(start, stop, step) returns [start, start + step, start + 2 * step, … stop - step]", () => { + assert.deepStrictEqual(range(0, 5, 1), [0, 1, 2, 3, 4]); + assert.deepStrictEqual(range(0, 5, 2), [0, 2, 4]); + assert.deepStrictEqual(range(2, 5, 2), [2, 4]); + assert.deepStrictEqual(range(-1, 3, 2), [-1, 1]); }); -tape("range(start, stop, step) allows a negative step", (test) => { - test.deepEqual(d3.range(5, 0, -1), [5, 4, 3, 2, 1]); - test.deepEqual(d3.range(5, 0, -2), [5, 3, 1]); - test.deepEqual(d3.range(5, 2, -2), [5, 3]); - test.deepEqual(d3.range(3, -1, -2), [3, 1]); +it("range(start, stop, step) allows a negative step", () => { + assert.deepStrictEqual(range(5, 0, -1), [5, 4, 3, 2, 1]); + assert.deepStrictEqual(range(5, 0, -2), [5, 3, 1]); + assert.deepStrictEqual(range(5, 2, -2), [5, 3]); + assert.deepStrictEqual(range(3, -1, -2), [3, 1]); }); -tape("range(start, stop, step) returns an empty array if start >= stop and step > 0", (test) => { - test.deepEqual(d3.range(5, 5, 2), []); - test.deepEqual(d3.range(6, 5, 2), []); - test.deepEqual(d3.range(10, 10, 1), []); - test.deepEqual(d3.range(10, 10, 0.5), []); - test.deepEqual(d3.range(0, 0, 1), []); - test.deepEqual(d3.range(0, 0, 0.5), []); - test.deepEqual(d3.range(20, 10, 2), []); - test.deepEqual(d3.range(20, 10, 1), []); - test.deepEqual(d3.range(20, 10, 0.5), []); +it("range(start, stop, step) returns an empty array if start >= stop and step > 0", () => { + assert.deepStrictEqual(range(5, 5, 2), []); + assert.deepStrictEqual(range(6, 5, 2), []); + assert.deepStrictEqual(range(10, 10, 1), []); + assert.deepStrictEqual(range(10, 10, 0.5), []); + assert.deepStrictEqual(range(0, 0, 1), []); + assert.deepStrictEqual(range(0, 0, 0.5), []); + assert.deepStrictEqual(range(20, 10, 2), []); + assert.deepStrictEqual(range(20, 10, 1), []); + assert.deepStrictEqual(range(20, 10, 0.5), []); }); -tape("range(start, stop, step) returns an empty array if start >= stop and step < 0", (test) => { - test.deepEqual(d3.range(5, 5, -2), []); - test.deepEqual(d3.range(5, 6, -2), []); - test.deepEqual(d3.range(10, 10, -1), []); - test.deepEqual(d3.range(10, 10, -0.5), []); - test.deepEqual(d3.range(0, 0, -1), []); - test.deepEqual(d3.range(0, 0, -0.5), []); - test.deepEqual(d3.range(10, 20, -2), []); - test.deepEqual(d3.range(10, 20, -1), []); - test.deepEqual(d3.range(10, 20, -0.5), []); +it("range(start, stop, step) returns an empty array if start >= stop and step < 0", () => { + assert.deepStrictEqual(range(5, 5, -2), []); + assert.deepStrictEqual(range(5, 6, -2), []); + assert.deepStrictEqual(range(10, 10, -1), []); + assert.deepStrictEqual(range(10, 10, -0.5), []); + assert.deepStrictEqual(range(0, 0, -1), []); + assert.deepStrictEqual(range(0, 0, -0.5), []); + assert.deepStrictEqual(range(10, 20, -2), []); + assert.deepStrictEqual(range(10, 20, -1), []); + assert.deepStrictEqual(range(10, 20, -0.5), []); }); -tape("range(start, stop, step) returns an empty array if start, stop or step is NaN", (test) => { - test.deepEqual(d3.range(NaN, 3, 2), []); - test.deepEqual(d3.range(3, NaN, 2), []); - test.deepEqual(d3.range(0, 5, NaN), []); - test.deepEqual(d3.range(NaN, NaN, NaN), []); - test.deepEqual(d3.range(NaN, NaN, NaN), []); - test.deepEqual(d3.range(undefined, undefined, undefined), []); - test.deepEqual(d3.range(0, 10, NaN), []); - test.deepEqual(d3.range(10, 0, NaN), []); - test.deepEqual(d3.range(0, 10, undefined), []); - test.deepEqual(d3.range(10, 0, undefined), []); +it("range(start, stop, step) returns an empty array if start, stop or step is NaN", () => { + assert.deepStrictEqual(range(NaN, 3, 2), []); + assert.deepStrictEqual(range(3, NaN, 2), []); + assert.deepStrictEqual(range(0, 5, NaN), []); + assert.deepStrictEqual(range(NaN, NaN, NaN), []); + assert.deepStrictEqual(range(NaN, NaN, NaN), []); + assert.deepStrictEqual(range(undefined, undefined, undefined), []); + assert.deepStrictEqual(range(0, 10, NaN), []); + assert.deepStrictEqual(range(10, 0, NaN), []); + assert.deepStrictEqual(range(0, 10, undefined), []); + assert.deepStrictEqual(range(10, 0, undefined), []); }); -tape("range(start, stop, step) returns an empty array if step is zero", (test) => { - test.deepEqual(d3.range(0, 5, 0), []); +it("range(start, stop, step) returns an empty array if step is zero", () => { + assert.deepStrictEqual(range(0, 5, 0), []); }); -tape("range(start, stop, step) returns exactly [start + step * i, …] for fractional steps", (test) => { - test.deepEqual(d3.range(0, 0.5, 0.1), [0 + 0.1 * 0, 0 + 0.1 * 1, 0 + 0.1 * 2, 0 + 0.1 * 3, 0 + 0.1 * 4]); - test.deepEqual(d3.range(0.5, 0, -0.1), [0.5 - 0.1 * 0, 0.5 - 0.1 * 1, 0.5 - 0.1 * 2, 0.5 - 0.1 * 3, 0.5 - 0.1 * 4]); - test.deepEqual(d3.range(-2, -1.2, 0.1), [-2 + 0.1 * 0, -2 + 0.1 * 1, -2 + 0.1 * 2, -2 + 0.1 * 3, -2 + 0.1 * 4, -2 + 0.1 * 5, -2 + 0.1 * 6, -2 + 0.1 * 7]); - test.deepEqual(d3.range(-1.2, -2, -0.1), [-1.2 - 0.1 * 0, -1.2 - 0.1 * 1, -1.2 - 0.1 * 2, -1.2 - 0.1 * 3, -1.2 - 0.1 * 4, -1.2 - 0.1 * 5, -1.2 - 0.1 * 6, -1.2 - 0.1 * 7]); +it("range(start, stop, step) returns exactly [start + step * i, …] for fractional steps", () => { + assert.deepStrictEqual(range(0, 0.5, 0.1), [0 + 0.1 * 0, 0 + 0.1 * 1, 0 + 0.1 * 2, 0 + 0.1 * 3, 0 + 0.1 * 4]); + assert.deepStrictEqual(range(0.5, 0, -0.1), [0.5 - 0.1 * 0, 0.5 - 0.1 * 1, 0.5 - 0.1 * 2, 0.5 - 0.1 * 3, 0.5 - 0.1 * 4]); + assert.deepStrictEqual(range(-2, -1.2, 0.1), [-2 + 0.1 * 0, -2 + 0.1 * 1, -2 + 0.1 * 2, -2 + 0.1 * 3, -2 + 0.1 * 4, -2 + 0.1 * 5, -2 + 0.1 * 6, -2 + 0.1 * 7]); + assert.deepStrictEqual(range(-1.2, -2, -0.1), [-1.2 - 0.1 * 0, -1.2 - 0.1 * 1, -1.2 - 0.1 * 2, -1.2 - 0.1 * 3, -1.2 - 0.1 * 4, -1.2 - 0.1 * 5, -1.2 - 0.1 * 6, -1.2 - 0.1 * 7]); }); -tape("range(start, stop, step) returns exactly [start + step * i, …] for very small fractional steps", (test) => { - test.deepEqual(d3.range(2.1e-31, 5e-31, 1.1e-31), [2.1e-31 + 1.1e-31 * 0, 2.1e-31 + 1.1e-31 * 1, 2.1e-31 + 1.1e-31 * 2]); - test.deepEqual(d3.range(5e-31, 2.1e-31, -1.1e-31), [5e-31 - 1.1e-31 * 0, 5e-31 - 1.1e-31 * 1, 5e-31 - 1.1e-31 * 2]); +it("range(start, stop, step) returns exactly [start + step * i, …] for very small fractional steps", () => { + assert.deepStrictEqual(range(2.1e-31, 5e-31, 1.1e-31), [2.1e-31 + 1.1e-31 * 0, 2.1e-31 + 1.1e-31 * 1, 2.1e-31 + 1.1e-31 * 2]); + assert.deepStrictEqual(range(5e-31, 2.1e-31, -1.1e-31), [5e-31 - 1.1e-31 * 0, 5e-31 - 1.1e-31 * 1, 5e-31 - 1.1e-31 * 2]); }); -tape("range(start, stop, step) returns exactly [start + step * i, …] for very large fractional steps", (test) => { - test.deepEqual(d3.range(1e300, 2e300, 0.3e300), [1e300 + 0.3e300 * 0, 1e300 + 0.3e300 * 1, 1e300 + 0.3e300 * 2, 1e300 + 0.3e300 * 3]); - test.deepEqual(d3.range(2e300, 1e300, -0.3e300), [2e300 - 0.3e300 * 0, 2e300 - 0.3e300 * 1, 2e300 - 0.3e300 * 2, 2e300 - 0.3e300 * 3]); +it("range(start, stop, step) returns exactly [start + step * i, …] for very large fractional steps", () => { + assert.deepStrictEqual(range(1e300, 2e300, 0.3e300), [1e300 + 0.3e300 * 0, 1e300 + 0.3e300 * 1, 1e300 + 0.3e300 * 2, 1e300 + 0.3e300 * 3]); + assert.deepStrictEqual(range(2e300, 1e300, -0.3e300), [2e300 - 0.3e300 * 0, 2e300 - 0.3e300 * 1, 2e300 - 0.3e300 * 2, 2e300 - 0.3e300 * 3]); }); +`` diff --git a/test/reduce-test.js b/test/reduce-test.js index e853af83..d521c56d 100644 --- a/test/reduce-test.js +++ b/test/reduce-test.js @@ -1,60 +1,59 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {reduce} from "../src/index.js"; -tape("reduce(values, reducer) returns the reduced value", (test) => { - test.strictEqual(d3.reduce([1, 2, 3, 2, 1], (p, v) => p + v), 9); - test.strictEqual(d3.reduce([1, 2], (p, v) => p + v), 3); - test.strictEqual(d3.reduce([1], (p, v) => p + v), 1); - test.strictEqual(d3.reduce([], (p, v) => p + v), undefined); +it("reduce(values, reducer) returns the reduced value", () => { + assert.strictEqual(reduce([1, 2, 3, 2, 1], (p, v) => p + v), 9); + assert.strictEqual(reduce([1, 2], (p, v) => p + v), 3); + assert.strictEqual(reduce([1], (p, v) => p + v), 1); + assert.strictEqual(reduce([], (p, v) => p + v), undefined); }); -tape("reduce(values, reducer, initial) returns the reduced value", (test) => { - test.strictEqual(d3.reduce([1, 2, 3, 2, 1], (p, v) => p + v, 0), 9); - test.strictEqual(d3.reduce([1], (p, v) => p + v, 0), 1); - test.strictEqual(d3.reduce([], (p, v) => p + v, 0), 0); - test.deepEqual(d3.reduce([1, 2, 3, 2, 1], (p, v) => p.concat(v), []), [1, 2, 3, 2, 1]); +it("reduce(values, reducer, initial) returns the reduced value", () => { + assert.strictEqual(reduce([1, 2, 3, 2, 1], (p, v) => p + v, 0), 9); + assert.strictEqual(reduce([1], (p, v) => p + v, 0), 1); + assert.strictEqual(reduce([], (p, v) => p + v, 0), 0); + assert.deepStrictEqual(reduce([1, 2, 3, 2, 1], (p, v) => p.concat(v), []), [1, 2, 3, 2, 1]); }); -tape("reduce(values, reducer) accepts an iterable", (test) => { - test.strictEqual(d3.reduce(new Set([1, 2, 3, 2, 1]), (p, v) => p + v), 6); - test.strictEqual(d3.reduce((function*() { yield* [1, 2, 3, 2, 1]; })(), (p, v) => p + v), 9); - test.strictEqual(d3.reduce(Uint8Array.of(1, 2, 3, 2, 1), (p, v) => p + v), 9); +it("reduce(values, reducer) accepts an iterable", () => { + assert.strictEqual(reduce(new Set([1, 2, 3, 2, 1]), (p, v) => p + v), 6); + assert.strictEqual(reduce((function*() { yield* [1, 2, 3, 2, 1]; })(), (p, v) => p + v), 9); + assert.strictEqual(reduce(Uint8Array.of(1, 2, 3, 2, 1), (p, v) => p + v), 9); }); -tape("reduce(values, reducer) enforces that test is a function", (test) => { - test.throws(() => d3.reduce([]), TypeError); +it("reduce(values, reducer) enforces that test is a function", () => { + assert.throws(() => reduce([]), TypeError); }); -tape("reduce(values, reducer) enforces that values is iterable", (test) => { - test.throws(() => d3.reduce({}, () => true), TypeError); +it("reduce(values, reducer) enforces that values is iterable", () => { + assert.throws(() => reduce({}, () => true), TypeError); }); -tape("reduce(values, reducer) passes reducer (reduced, value, index, values)", (test) => { +it("reduce(values, reducer) passes reducer (reduced, value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); - d3.reduce(values, function(p, v) { calls.push([this, ...arguments]); return p + v; }); - test.deepEqual(calls, [ - [global, 5, 4, 1, values], - [global, 9, 3, 2, values], - [global, 12, 2, 3, values], - [global, 14, 1, 4, values] + reduce(values, function(p, v) { calls.push([this, ...arguments]); return p + v; }); + assert.deepStrictEqual(calls, [ + [undefined, 5, 4, 1, values], + [undefined, 9, 3, 2, values], + [undefined, 12, 2, 3, values], + [undefined, 14, 1, 4, values] ]); }); -tape("reduce(values, reducer, initial) passes reducer (reduced, value, index, values)", (test) => { +it("reduce(values, reducer, initial) passes reducer (reduced, value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); - d3.reduce(values, function(p, v) { calls.push([this, ...arguments]); return p + v; }, 0); - test.deepEqual(calls, [ - [global, 0, 5, 0, values], - [global, 5, 4, 1, values], - [global, 9, 3, 2, values], - [global, 12, 2, 3, values], - [global, 14, 1, 4, values] + reduce(values, function(p, v) { calls.push([this, ...arguments]); return p + v; }, 0); + assert.deepStrictEqual(calls, [ + [undefined, 0, 5, 0, values], + [undefined, 5, 4, 1, values], + [undefined, 9, 3, 2, values], + [undefined, 12, 2, 3, values], + [undefined, 14, 1, 4, values] ]); }); -tape("reduce(values, reducer, initial) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.strictEqual(d3.reduce([, 1, 2,,], (p, v) => p + (v === undefined ? -1 : v), 0), 1); +it("reduce(values, reducer, initial) does not skip sparse elements", () => { + assert.strictEqual(reduce([, 1, 2,, ], (p, v) => p + (v === undefined ? -1 : v), 0), 1); }); diff --git a/test/reverse-test.js b/test/reverse-test.js index e27f6f4c..7c766846 100644 --- a/test/reverse-test.js +++ b/test/reverse-test.js @@ -1,27 +1,26 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {reverse} from "../src/index.js"; -tape("reverse(values) returns a reversed copy", (test) => { +it("reverse(values) returns a reversed copy", () => { const input = [1, 3, 2, 5, 4]; - test.deepEqual(d3.reverse(input), [4, 5, 2, 3, 1]); - test.deepEqual(input, [1, 3, 2, 5, 4]); // does not mutate + assert.deepStrictEqual(reverse(input), [4, 5, 2, 3, 1]); + assert.deepStrictEqual(input, [1, 3, 2, 5, 4]); // does not mutate }); -tape("reverse(values) returns an array", (test) => { - test.strictEqual(Array.isArray(d3.reverse(Uint8Array.of(1, 2))), true); +it("reverse(values) returns an array", () => { + assert.strictEqual(Array.isArray(reverse(Uint8Array.of(1, 2))), true); }); -tape("reverse(values) accepts an iterable", (test) => { - test.deepEqual(d3.reverse(new Set([1, 2, 3, 2, 1])), [3, 2, 1]); - test.deepEqual(d3.reverse((function*() { yield* [1, 3, 2, 5, 4]; })()), [4, 5, 2, 3, 1]); - test.deepEqual(d3.reverse(Uint8Array.of(1, 3, 2, 5, 4)), [4, 5, 2, 3, 1]); +it("reverse(values) accepts an iterable", () => { + assert.deepStrictEqual(reverse(new Set([1, 2, 3, 2, 1])), [3, 2, 1]); + assert.deepStrictEqual(reverse((function*() { yield* [1, 3, 2, 5, 4]; })()), [4, 5, 2, 3, 1]); + assert.deepStrictEqual(reverse(Uint8Array.of(1, 3, 2, 5, 4)), [4, 5, 2, 3, 1]); }); -tape("reverse(values) enforces that values is iterable", (test) => { - test.throws(() => d3.reverse({}), TypeError); +it("reverse(values) enforces that values is iterable", () => { + assert.throws(() => reverse({}), TypeError); }); -tape("reverse(values) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.reverse([, 1, 2,,]), [undefined, 2, 1, undefined]); +it("reverse(values) does not skip sparse elements", () => { + assert.deepStrictEqual(reverse([, 1, 2,, ]), [undefined, 2, 1, undefined]); }); diff --git a/test/rollup-test.js b/test/rollup-test.js index ecf2a1eb..d8d0d685 100644 --- a/test/rollup-test.js +++ b/test/rollup-test.js @@ -1,5 +1,5 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {rollup, sum} from "../src/index.js"; const data = [ {name: "jim", amount: "3400", date: "11/12/2015"}, @@ -8,17 +8,17 @@ const data = [ {name: "stacy", amount: "3405", date: "01/04/2016"} ]; -tape("rollup(data, reduce, accessor) returns the expected map", (test) => { - test.deepEqual( - entries(d3.rollup(data, v => v.length, d => d.name), 1), +it("rollup(data, reduce, accessor) returns the expected map", () => { + assert.deepStrictEqual( + entries(rollup(data, v => v.length, d => d.name), 1), [ ["jim", 1], ["carl", 1], ["stacy", 2] ] ); - test.deepEqual( - entries(d3.rollup(data, v => d3.sum(v, d => d.amount), d => d.name), 1), + assert.deepStrictEqual( + entries(rollup(data, v => sum(v, d => d.amount), d => d.name), 1), [ ["jim", 3400], ["carl", 12011], @@ -27,9 +27,9 @@ tape("rollup(data, reduce, accessor) returns the expected map", (test) => { ); }); -tape("rollup(data, reduce, accessor, accessor) returns the expected map", (test) => { - test.deepEqual( - entries(d3.rollup(data, v => v.length, d => d.name, d => d.amount), 2), +it("rollup(data, reduce, accessor, accessor) returns the expected map", () => { + assert.deepStrictEqual( + entries(rollup(data, v => v.length, d => d.name, d => d.amount), 2), [ [ "jim", diff --git a/test/rollups-test.js b/test/rollups-test.js index 416030e5..868da6f9 100644 --- a/test/rollups-test.js +++ b/test/rollups-test.js @@ -1,5 +1,5 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {rollups, sum} from "../src/index.js"; const data = [ {name: "jim", amount: "3400", date: "11/12/2015"}, @@ -8,17 +8,17 @@ const data = [ {name: "stacy", amount: "3405", date: "01/04/2016"} ]; -tape("rollups(data, reduce, accessor) returns the expected array", (test) => { - test.deepEqual( - d3.rollups(data, v => v.length, d => d.name), +it("rollups(data, reduce, accessor) returns the expected array", () => { + assert.deepStrictEqual( + rollups(data, v => v.length, d => d.name), [ ["jim", 1], ["carl", 1], ["stacy", 2] ] ); - test.deepEqual( - d3.rollups(data, v => d3.sum(v, d => d.amount), d => d.name), + assert.deepStrictEqual( + rollups(data, v => sum(v, d => d.amount), d => d.name), [ ["jim", 3400], ["carl", 12011], @@ -27,9 +27,9 @@ tape("rollups(data, reduce, accessor) returns the expected array", (test) => { ); }); -tape("rollups(data, reduce, accessor, accessor) returns the expected array", (test) => { - test.deepEqual( - d3.rollups(data, v => v.length, d => d.name, d => d.amount), +it("rollups(data, reduce, accessor, accessor) returns the expected array", () => { + assert.deepStrictEqual( + rollups(data, v => v.length, d => d.name, d => d.amount), [ [ "jim", diff --git a/test/run.sh b/test/run.sh deleted file mode 100755 index e5f8ed89..00000000 --- a/test/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -tape ${@:-'test/**/*-test.js'} && eslint src diff --git a/test/scan-test.js b/test/scan-test.js index 557bb254..29734784 100644 --- a/test/scan-test.js +++ b/test/scan-test.js @@ -1,41 +1,41 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {descending, scan} from "../src/index.js"; -tape("scan(array) compares using natural order", (test) => { - test.strictEqual(d3.scan([0, 1]), 0); - test.strictEqual(d3.scan([1, 0]), 1); - test.strictEqual(d3.scan([0, "1"]), 0); - test.strictEqual(d3.scan(["1", 0]), 1); - test.strictEqual(d3.scan(["10", "2"]), 0); - test.strictEqual(d3.scan(["2", "10"]), 1); - test.strictEqual(d3.scan(["10", "2", NaN]), 0); - test.strictEqual(d3.scan([NaN, "10", "2"]), 1); - test.strictEqual(d3.scan(["2", NaN, "10"]), 2); - test.strictEqual(d3.scan([2, NaN, 10]), 0); - test.strictEqual(d3.scan([10, 2, NaN]), 1); - test.strictEqual(d3.scan([NaN, 10, 2]), 2); +it("scan(array) compares using natural order", () => { + assert.strictEqual(scan([0, 1]), 0); + assert.strictEqual(scan([1, 0]), 1); + assert.strictEqual(scan([0, "1"]), 0); + assert.strictEqual(scan(["1", 0]), 1); + assert.strictEqual(scan(["10", "2"]), 0); + assert.strictEqual(scan(["2", "10"]), 1); + assert.strictEqual(scan(["10", "2", NaN]), 0); + assert.strictEqual(scan([NaN, "10", "2"]), 1); + assert.strictEqual(scan(["2", NaN, "10"]), 2); + assert.strictEqual(scan([2, NaN, 10]), 0); + assert.strictEqual(scan([10, 2, NaN]), 1); + assert.strictEqual(scan([NaN, 10, 2]), 2); }); -tape("scan(array, compare) compares using the specified compare function", (test) => { +it("scan(array, compare) compares using the specified compare function", () => { var a = {name: "a"}, b = {name: "b"}; - test.strictEqual(d3.scan([a, b], (a, b) => a.name.localeCompare(b.name)), 0); - test.strictEqual(d3.scan([1, 0], d3.descending), 0); - test.strictEqual(d3.scan(["1", 0], d3.descending), 0); - test.strictEqual(d3.scan(["2", "10"], d3.descending), 0); - test.strictEqual(d3.scan(["2", NaN, "10"], d3.descending), 0); - test.strictEqual(d3.scan([2, NaN, 10], d3.descending), 2); + assert.strictEqual(scan([a, b], (a, b) => a.name.localeCompare(b.name)), 0); + assert.strictEqual(scan([1, 0], descending), 0); + assert.strictEqual(scan(["1", 0], descending), 0); + assert.strictEqual(scan(["2", "10"], descending), 0); + assert.strictEqual(scan(["2", NaN, "10"], descending), 0); + assert.strictEqual(scan([2, NaN, 10], descending), 2); }); -tape("scan(array) returns undefined if the array is empty", (test) => { - test.strictEqual(d3.scan([]), undefined); +it("scan(array) returns undefined if the array is empty", () => { + assert.strictEqual(scan([]), undefined); }); -tape("scan(array) returns undefined if the array contains only incomparable values", (test) => { - test.strictEqual(d3.scan([NaN, undefined]), undefined); - test.strictEqual(d3.scan([NaN, "foo"], (a, b) => a - b), undefined); +it("scan(array) returns undefined if the array contains only incomparable values", () => { + assert.strictEqual(scan([NaN, undefined]), undefined); + assert.strictEqual(scan([NaN, "foo"], (a, b) => a - b), undefined); }); -tape("scan(array) returns the first of equal values", (test) => { - test.strictEqual(d3.scan([2, 2, 1, 1, 0, 0, 0, 3, 0]), 4); - test.strictEqual(d3.scan([3, 2, 2, 1, 1, 0, 0, 0, 3, 0], d3.descending), 0); +it("scan(array) returns the first of equal values", () => { + assert.strictEqual(scan([2, 2, 1, 1, 0, 0, 0, 3, 0]), 4); + assert.strictEqual(scan([3, 2, 2, 1, 1, 0, 0, 0, 3, 0], descending), 0); }); diff --git a/test/setEqual.js b/test/setEqual.js deleted file mode 100644 index 0c38521d..00000000 --- a/test/setEqual.js +++ /dev/null @@ -1,17 +0,0 @@ -const tape = require("tape-await"); - -tape.Test.prototype.setEqual = function(actual, expected) { - this._assert(setEqual(actual, expected), { - message: "should be equal", - operator: "setEqual", - actual, - expected - }); -}; - -function setEqual(A, B) { - if (!(A instanceof Set)) throw new Error("not a set"); - for (const a of A) if (!B.has(a)) return false; - for (const b of B) if (!A.has(b)) return false; - return true; -} diff --git a/test/shuffle-test.js b/test/shuffle-test.js index d5c1da36..40f40523 100644 --- a/test/shuffle-test.js +++ b/test/shuffle-test.js @@ -1,30 +1,31 @@ -const tape = require("tape-await"); -const d3 = Object.assign({}, require("../"), require("d3-random")); +import assert from "assert"; +import {randomLcg} from "d3-random"; +import {pairs, shuffler} from "../src/index.js"; -tape("shuffle(array) shuffles the array in-place", (test) => { +it("shuffle(array) shuffles the array in-place", () => { const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const shuffle = d3.shuffler(d3.randomLcg(0.9051667019185816)); - test.equal(shuffle(numbers), numbers); - test.true(d3.pairs(numbers).some(([a, b]) => a > b)); // shuffled + const shuffle = shuffler(randomLcg(0.9051667019185816)); + assert.strictEqual(shuffle(numbers), numbers); + assert(pairs(numbers).some(([a, b]) => a > b)); // shuffled }); -tape("shuffler(random)(array) shuffles the array in-place", (test) => { +it("shuffler(random)(array) shuffles the array in-place", () => { const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const shuffle = d3.shuffler(d3.randomLcg(0.9051667019185816)); - test.equal(shuffle(numbers), numbers); - test.deepEqual(numbers, [7, 4, 5, 3, 9, 0, 6, 1, 2, 8]); + const shuffle = shuffler(randomLcg(0.9051667019185816)); + assert.strictEqual(shuffle(numbers), numbers); + assert.deepStrictEqual(numbers, [7, 4, 5, 3, 9, 0, 6, 1, 2, 8]); }); -tape("shuffler(random)(array, start) shuffles the subset array[start:] in-place", (test) => { +it("shuffler(random)(array, start) shuffles the subset array[start:] in-place", () => { const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const shuffle = d3.shuffler(d3.randomLcg(0.9051667019185816)); - test.equal(shuffle(numbers, 4), numbers); - test.deepEqual(numbers, [0, 1, 2, 3, 8, 7, 6, 4, 5, 9]); + const shuffle = shuffler(randomLcg(0.9051667019185816)); + assert.strictEqual(shuffle(numbers, 4), numbers); + assert.deepStrictEqual(numbers, [0, 1, 2, 3, 8, 7, 6, 4, 5, 9]); }); -tape("shuffler(random)(array, start, end) shuffles the subset array[start:end] in-place", (test) => { +it("shuffler(random)(array, start, end) shuffles the subset array[start:end] in-place", () => { const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const shuffle = d3.shuffler(d3.randomLcg(0.9051667019185816)); - test.equal(shuffle(numbers, 3, 8), numbers); - test.deepEqual(numbers, [0, 1, 2, 5, 6, 3, 4, 7, 8, 9]); + const shuffle = shuffler(randomLcg(0.9051667019185816)); + assert.strictEqual(shuffle(numbers, 3, 8), numbers); + assert.deepStrictEqual(numbers, [0, 1, 2, 5, 6, 3, 4, 7, 8, 9]); }); diff --git a/test/some-test.js b/test/some-test.js index 39cd1659..fcb164d5 100644 --- a/test/some-test.js +++ b/test/some-test.js @@ -1,51 +1,50 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {some} from "../src/index.js"; -tape("some(values, test) returns true if any test passes", (test) => { - test.strictEqual(d3.some([1, 2, 3, 2, 1], x => x & 1), true); - test.strictEqual(d3.some([1, 2, 3, 2, 1], x => x > 3), false); +it("some(values, test) returns true if any test passes", () => { + assert.strictEqual(some([1, 2, 3, 2, 1], x => x & 1), true); + assert.strictEqual(some([1, 2, 3, 2, 1], x => x > 3), false); }); -tape("some(values, test) returns false if values is empty", (test) => { - test.strictEqual(d3.some([], () => true), false); +it("some(values, test) returns false if values is empty", () => { + assert.strictEqual(some([], () => true), false); }); -tape("some(values, test) accepts an iterable", (test) => { - test.strictEqual(d3.some(new Set([1, 2, 3, 2, 1]), x => x >= 3), true); - test.strictEqual(d3.some((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x >= 3), true); - test.strictEqual(d3.some(Uint8Array.of(1, 2, 3, 2, 1), x => x >= 3), true); +it("some(values, test) accepts an iterable", () => { + assert.strictEqual(some(new Set([1, 2, 3, 2, 1]), x => x >= 3), true); + assert.strictEqual(some((function*() { yield* [1, 2, 3, 2, 1]; })(), x => x >= 3), true); + assert.strictEqual(some(Uint8Array.of(1, 2, 3, 2, 1), x => x >= 3), true); }); -tape("some(values, test) enforces that test is a function", (test) => { - test.throws(() => d3.some([]), TypeError); +it("some(values, test) enforces that test is a function", () => { + assert.throws(() => some([]), TypeError); }); -tape("some(values, test) enforces that values is iterable", (test) => { - test.throws(() => d3.some({}, () => true), TypeError); +it("some(values, test) enforces that values is iterable", () => { + assert.throws(() => some({}, () => true), TypeError); }); -tape("some(values, test) passes test (value, index, values)", (test) => { +it("some(values, test) passes test (value, index, values)", () => { const calls = []; const values = new Set([5, 4, 3, 2, 1]); - d3.some(values, function() { calls.push([this, ...arguments]); }); - test.deepEqual(calls, [ - [global, 5, 0, values], - [global, 4, 1, values], - [global, 3, 2, values], - [global, 2, 3, values], - [global, 1, 4, values] + some(values, function() { calls.push([this, ...arguments]); }); + assert.deepStrictEqual(calls, [ + [undefined, 5, 0, values], + [undefined, 4, 1, values], + [undefined, 3, 2, values], + [undefined, 2, 3, values], + [undefined, 1, 4, values] ]); }); -tape("some(values, test) short-circuts when test returns truthy", (test) => { +it("some(values, test) short-circuts when test returns truthy", () => { let calls = 0; - test.strictEqual(d3.some([1, 2, 3], x => (++calls, x >= 2)), true); - test.strictEqual(calls, 2); - test.strictEqual(d3.some([1, 2, 3], x => (++calls, x - 1)), true); - test.strictEqual(calls, 4); + assert.strictEqual(some([1, 2, 3], x => (++calls, x >= 2)), true); + assert.strictEqual(calls, 2); + assert.strictEqual(some([1, 2, 3], x => (++calls, x - 1)), true); + assert.strictEqual(calls, 4); }); -tape("some(values, test) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.some([, 1, 2,,], x => x === undefined), true); +it("some(values, test) does not skip sparse elements", () => { + assert.deepStrictEqual(some([, 1, 2,, ], x => x === undefined), true); }); diff --git a/test/sort-test.js b/test/sort-test.js index f4a7777c..bdae60ae 100644 --- a/test/sort-test.js +++ b/test/sort-test.js @@ -1,50 +1,49 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {descending, sort} from "../src/index.js"; -tape("sort(values) returns a sorted copy", (test) => { +it("sort(values) returns a sorted copy", () => { const input = [1, 3, 2, 5, 4]; - test.deepEqual(d3.sort(input), [1, 2, 3, 4, 5]); - test.deepEqual(input, [1, 3, 2, 5, 4]); // does not mutate + assert.deepStrictEqual(sort(input), [1, 2, 3, 4, 5]); + assert.deepStrictEqual(input, [1, 3, 2, 5, 4]); // does not mutate }); -tape("sort(values) defaults to ascending, not lexicographic", (test) => { +it("sort(values) defaults to ascending, not lexicographic", () => { const input = [1, "10", 2]; - test.deepEqual(d3.sort(input), [1, 2, "10"]); + assert.deepStrictEqual(sort(input), [1, 2, "10"]); }); -tape("sort(values, accessor) uses the specified accessor in natural order", (test) => { - test.deepEqual(d3.sort([1, 3, 2, 5, 4], d => d), [1, 2, 3, 4, 5]); - test.deepEqual(d3.sort([1, 3, 2, 5, 4], d => -d), [5, 4, 3, 2, 1]); +it("sort(values, accessor) uses the specified accessor in natural order", () => { + assert.deepStrictEqual(sort([1, 3, 2, 5, 4], d => d), [1, 2, 3, 4, 5]); + assert.deepStrictEqual(sort([1, 3, 2, 5, 4], d => -d), [5, 4, 3, 2, 1]); }); -tape("sort(values, ...accessors) accepts multiple accessors", (test) => { - test.deepEqual(d3.sort([[1, 0], [2, 1], [2, 0], [1, 1], [3, 0]], ([x]) => x, ([, y]) => y), [[1, 0], [1, 1], [2, 0], [2, 1], [3, 0]]); - test.deepEqual(d3.sort([{x: 1, y: 0}, {x: 2, y: 1}, {x: 2, y: 0}, {x: 1, y: 1}, {x: 3, y: 0}], ({x}) => x, ({y}) => y), [{x: 1, y: 0}, {x: 1, y: 1}, {x: 2, y: 0}, {x: 2, y: 1}, {x: 3, y: 0}]); +it("sort(values, ...accessors) accepts multiple accessors", () => { + assert.deepStrictEqual(sort([[1, 0], [2, 1], [2, 0], [1, 1], [3, 0]], ([x]) => x, ([, y]) => y), [[1, 0], [1, 1], [2, 0], [2, 1], [3, 0]]); + assert.deepStrictEqual(sort([{x: 1, y: 0}, {x: 2, y: 1}, {x: 2, y: 0}, {x: 1, y: 1}, {x: 3, y: 0}], ({x}) => x, ({y}) => y), [{x: 1, y: 0}, {x: 1, y: 1}, {x: 2, y: 0}, {x: 2, y: 1}, {x: 3, y: 0}]); }); -tape("sort(values, comparator) uses the specified comparator", (test) => { - test.deepEqual(d3.sort([1, 3, 2, 5, 4], d3.descending), [5, 4, 3, 2, 1]); +it("sort(values, comparator) uses the specified comparator", () => { + assert.deepStrictEqual(sort([1, 3, 2, 5, 4], descending), [5, 4, 3, 2, 1]); }); -tape("sort(values) returns an array", (test) => { - test.strictEqual(Array.isArray(d3.sort(Uint8Array.of(1, 2))), true); +it("sort(values) returns an array", () => { + assert.strictEqual(Array.isArray(sort(Uint8Array.of(1, 2))), true); }); -tape("sort(values) accepts an iterable", (test) => { - test.deepEqual(d3.sort(new Set([1, 3, 2, 1, 2])), [1, 2, 3]); - test.deepEqual(d3.sort((function*() { yield* [1, 3, 2, 5, 4]; })()), [1, 2, 3, 4, 5]); - test.deepEqual(d3.sort(Uint8Array.of(1, 3, 2, 5, 4)), [1, 2, 3, 4, 5]); +it("sort(values) accepts an iterable", () => { + assert.deepStrictEqual(sort(new Set([1, 3, 2, 1, 2])), [1, 2, 3]); + assert.deepStrictEqual(sort((function*() { yield* [1, 3, 2, 5, 4]; })()), [1, 2, 3, 4, 5]); + assert.deepStrictEqual(sort(Uint8Array.of(1, 3, 2, 5, 4)), [1, 2, 3, 4, 5]); }); -tape("sort(values) enforces that values is iterable", (test) => { - test.throws(() => d3.sort({}), TypeError); +it("sort(values) enforces that values is iterable", () => { + assert.throws(() => sort({}), TypeError); }); -tape("sort(values, comparator) enforces that comparator is a function", (test) => { - test.throws(() => d3.sort([], {}), TypeError); +it("sort(values, comparator) enforces that comparator is a function", () => { + assert.throws(() => sort([], {}), TypeError); }); -tape("sort(values) does not skip sparse elements", (test) => { - // eslint-disable-next-line no-sparse-arrays - test.deepEqual(d3.sort([, 1, 2,,]), [1, 2, undefined, undefined]); +it("sort(values) does not skip sparse elements", () => { + assert.deepStrictEqual(sort([, 1, 2,, ]), [1, 2, undefined, undefined]); }); diff --git a/test/subset-test.js b/test/subset-test.js index b3551256..3fa801b1 100644 --- a/test/subset-test.js +++ b/test/subset-test.js @@ -1,8 +1,8 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {subset} from "../src/index.js"; -tape("subset(values, other) returns true if values is a subset of others", (test) => { - test.equal(d3.subset([2], [1, 2]), true); - test.equal(d3.subset([3, 4], [2, 3]), false); - test.equal(d3.subset([], [1]), true); +it("subset(values, other) returns true if values is a subset of others", () => { + assert.strictEqual(subset([2], [1, 2]), true); + assert.strictEqual(subset([3, 4], [2, 3]), false); + assert.strictEqual(subset([], [1]), true); }); diff --git a/test/sum-test.js b/test/sum-test.js index 4d4c2e2a..93d7485d 100644 --- a/test/sum-test.js +++ b/test/sum-test.js @@ -1,87 +1,87 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {sum} from "../src/index.js"; -tape("sum(array) returns the sum of the specified numbers", (test) => { - test.equal(d3.sum([1]), 1); - test.equal(d3.sum([5, 1, 2, 3, 4]), 15); - test.equal(d3.sum([20, 3]), 23); - test.equal(d3.sum([3, 20]), 23); +it("sum(array) returns the sum of the specified numbers", () => { + assert.strictEqual(sum([1]), 1); + assert.strictEqual(sum([5, 1, 2, 3, 4]), 15); + assert.strictEqual(sum([20, 3]), 23); + assert.strictEqual(sum([3, 20]), 23); }); -tape("sum(array) observes values that can be coerced to numbers", (test) => { - test.equal(d3.sum(["20", "3"]), 23); - test.equal(d3.sum(["3", "20"]), 23); - test.equal(d3.sum(["3", 20]), 23); - test.equal(d3.sum([20, "3"]), 23); - test.equal(d3.sum([3, "20"]), 23); - test.equal(d3.sum(["20", 3]), 23); +it("sum(array) observes values that can be coerced to numbers", () => { + assert.strictEqual(sum(["20", "3"]), 23); + assert.strictEqual(sum(["3", "20"]), 23); + assert.strictEqual(sum(["3", 20]), 23); + assert.strictEqual(sum([20, "3"]), 23); + assert.strictEqual(sum([3, "20"]), 23); + assert.strictEqual(sum(["20", 3]), 23); }); -tape("sum(array) ignores non-numeric values", (test) => { - test.equal(d3.sum(["a", "b", "c"]), 0); - test.equal(d3.sum(["a", 1, "2"]), 3); +it("sum(array) ignores non-numeric values", () => { + assert.strictEqual(sum(["a", "b", "c"]), 0); + assert.strictEqual(sum(["a", 1, "2"]), 3); }); -tape("sum(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.sum([NaN, 1, 2, 3, 4, 5]), 15); - test.equal(d3.sum([1, 2, 3, 4, 5, NaN]), 15); - test.equal(d3.sum([10, null, 3, undefined, 5, NaN]), 18); +it("sum(array) ignores null, undefined and NaN", () => { + assert.strictEqual(sum([NaN, 1, 2, 3, 4, 5]), 15); + assert.strictEqual(sum([1, 2, 3, 4, 5, NaN]), 15); + assert.strictEqual(sum([10, null, 3, undefined, 5, NaN]), 18); }); -tape("sum(array) returns zero if there are no numbers", (test) => { - test.equal(d3.sum([]), 0); - test.equal(d3.sum([NaN]), 0); - test.equal(d3.sum([undefined]), 0); - test.equal(d3.sum([undefined, NaN]), 0); - test.equal(d3.sum([undefined, NaN, {}]), 0); +it("sum(array) returns zero if there are no numbers", () => { + assert.strictEqual(sum([]), 0); + assert.strictEqual(sum([NaN]), 0); + assert.strictEqual(sum([undefined]), 0); + assert.strictEqual(sum([undefined, NaN]), 0); + assert.strictEqual(sum([undefined, NaN, {}]), 0); }); -tape("sum(array, f) returns the sum of the specified numbers", (test) => { - test.equal(d3.sum([1].map(box), unbox), 1); - test.equal(d3.sum([5, 1, 2, 3, 4].map(box), unbox), 15); - test.equal(d3.sum([20, 3].map(box), unbox), 23); - test.equal(d3.sum([3, 20].map(box), unbox), 23); +it("sum(array, f) returns the sum of the specified numbers", () => { + assert.strictEqual(sum([1].map(box), unbox), 1); + assert.strictEqual(sum([5, 1, 2, 3, 4].map(box), unbox), 15); + assert.strictEqual(sum([20, 3].map(box), unbox), 23); + assert.strictEqual(sum([3, 20].map(box), unbox), 23); }); -tape("sum(array, f) observes values that can be coerced to numbers", (test) => { - test.equal(d3.sum(["20", "3"].map(box), unbox), 23); - test.equal(d3.sum(["3", "20"].map(box), unbox), 23); - test.equal(d3.sum(["3", 20].map(box), unbox), 23); - test.equal(d3.sum([20, "3"].map(box), unbox), 23); - test.equal(d3.sum([3, "20"].map(box), unbox), 23); - test.equal(d3.sum(["20", 3].map(box), unbox), 23); +it("sum(array, f) observes values that can be coerced to numbers", () => { + assert.strictEqual(sum(["20", "3"].map(box), unbox), 23); + assert.strictEqual(sum(["3", "20"].map(box), unbox), 23); + assert.strictEqual(sum(["3", 20].map(box), unbox), 23); + assert.strictEqual(sum([20, "3"].map(box), unbox), 23); + assert.strictEqual(sum([3, "20"].map(box), unbox), 23); + assert.strictEqual(sum(["20", 3].map(box), unbox), 23); }); -tape("sum(array, f) ignores non-numeric values", (test) => { - test.equal(d3.sum(["a", "b", "c"].map(box), unbox), 0); - test.equal(d3.sum(["a", 1, "2"].map(box), unbox), 3); +it("sum(array, f) ignores non-numeric values", () => { + assert.strictEqual(sum(["a", "b", "c"].map(box), unbox), 0); + assert.strictEqual(sum(["a", 1, "2"].map(box), unbox), 3); }); -tape("sum(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.sum([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); - test.equal(d3.sum([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); - test.equal(d3.sum([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); +it("sum(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(sum([NaN, 1, 2, 3, 4, 5].map(box), unbox), 15); + assert.strictEqual(sum([1, 2, 3, 4, 5, NaN].map(box), unbox), 15); + assert.strictEqual(sum([10, null, 3, undefined, 5, NaN].map(box), unbox), 18); }); -tape("sum(array, f) returns zero if there are no numbers", (test) => { - test.equal(d3.sum([].map(box), unbox), 0); - test.equal(d3.sum([NaN].map(box), unbox), 0); - test.equal(d3.sum([undefined].map(box), unbox), 0); - test.equal(d3.sum([undefined, NaN].map(box), unbox), 0); - test.equal(d3.sum([undefined, NaN, {}].map(box), unbox), 0); +it("sum(array, f) returns zero if there are no numbers", () => { + assert.strictEqual(sum([].map(box), unbox), 0); + assert.strictEqual(sum([NaN].map(box), unbox), 0); + assert.strictEqual(sum([undefined].map(box), unbox), 0); + assert.strictEqual(sum([undefined, NaN].map(box), unbox), 0); + assert.strictEqual(sum([undefined, NaN, {}].map(box), unbox), 0); }); -tape("sum(array, f) passes the accessor d, i, and array", (test) => { +it("sum(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.sum(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + sum(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("sum(array, f) uses the global context", (test) => { +it("sum(array, f) uses the undefined context", () => { const results = []; - d3.sum([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + sum([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/superset-test.js b/test/superset-test.js index d0dbd4db..ffac4b4a 100644 --- a/test/superset-test.js +++ b/test/superset-test.js @@ -1,18 +1,18 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {superset} from "../src/index.js"; -tape("superset(values, other) returns true if values is a superset of others", (test) => { - test.equal(d3.superset([1, 2], [2]), true); - test.equal(d3.superset([2, 3], [3, 4]), false); - test.equal(d3.superset([1], []), true); +it("superset(values, other) returns true if values is a superset of others", () => { + assert.strictEqual(superset([1, 2], [2]), true); + assert.strictEqual(superset([2, 3], [3, 4]), false); + assert.strictEqual(superset([1], []), true); }); -tape("superset(values, other) allows values to be infinite", (test) => { - test.equal(d3.superset(odds(), [1, 3, 5]), true); +it("superset(values, other) allows values to be infinite", () => { + assert.strictEqual(superset(odds(), [1, 3, 5]), true); }); -tape("superset(values, other) allows other to be infinite", (test) => { - test.equal(d3.superset([1, 3, 5], repeat(1, 3, 2)), false); +it("superset(values, other) allows other to be infinite", () => { + assert.strictEqual(superset([1, 3, 5], repeat(1, 3, 2)), false); }); function* odds() { diff --git a/test/threshold/freedmanDiaconic-test.js b/test/threshold/freedmanDiaconic-test.js index 801f166e..bd11f965 100644 --- a/test/threshold/freedmanDiaconic-test.js +++ b/test/threshold/freedmanDiaconic-test.js @@ -1,6 +1,6 @@ -const tape = require("tape-await"); -const d3 = require("../../"); +import assert from "assert"; +import {thresholdFreedmanDiaconis} from "../../src/index.js"; -tape("thresholdFreedmanDiaconis(values, min, max) returns the expected result", (test) => { - test.equal(d3.thresholdFreedmanDiaconis([4, 3, 2, 1, NaN], 1, 4), 2); +it("thresholdFreedmanDiaconis(values, min, max) returns the expected result", () => { + assert.strictEqual(thresholdFreedmanDiaconis([4, 3, 2, 1, NaN], 1, 4), 2); }); diff --git a/test/threshold/scott-test.js b/test/threshold/scott-test.js index f0627c32..e85c400c 100644 --- a/test/threshold/scott-test.js +++ b/test/threshold/scott-test.js @@ -1,6 +1,6 @@ -const tape = require("tape-await"); -const d3 = require("../../"); +import assert from "assert"; +import {thresholdScott} from "../../src/index.js"; -tape("thresholdScott(values, min, max) returns the expected result", (test) => { - test.equal(d3.thresholdScott([4, 3, 2, 1, NaN], 1, 4), 2); +it("thresholdScott(values, min, max) returns the expected result", () => { + assert.strictEqual(thresholdScott([4, 3, 2, 1, NaN], 1, 4), 2); }); diff --git a/test/threshold/sturges-test.js b/test/threshold/sturges-test.js index add27a3d..7e57995e 100644 --- a/test/threshold/sturges-test.js +++ b/test/threshold/sturges-test.js @@ -1,6 +1,6 @@ -const tape = require("tape-await"); -const d3 = require("../../"); +import assert from "assert"; +import {thresholdSturges} from "../../src/index.js"; -tape("thresholdSturges(values, min, max) returns the expected result", (test) => { - test.equal(d3.thresholdSturges([4, 3, 2, 1, NaN], 1, 4), 3); +it("thresholdSturges(values, min, max) returns the expected result", () => { + assert.strictEqual(thresholdSturges([4, 3, 2, 1, NaN], 1, 4), 3); }); diff --git a/test/tickIncrement-test.js b/test/tickIncrement-test.js index c14c0fb1..68c64ded 100644 --- a/test/tickIncrement-test.js +++ b/test/tickIncrement-test.js @@ -1,62 +1,62 @@ -const tape = require("tape-await"); -const array = require("../"); +import assert from "assert"; +import {tickIncrement} from "../src/index.js"; -tape("tickIncrement(start, stop, count) returns NaN if any argument is NaN", (test) => { - test.ok(isNaN(array.tickIncrement(NaN, 1, 1))); - test.ok(isNaN(array.tickIncrement(0, NaN, 1))); - test.ok(isNaN(array.tickIncrement(0, 1, NaN))); - test.ok(isNaN(array.tickIncrement(NaN, NaN, 1))); - test.ok(isNaN(array.tickIncrement(0, NaN, NaN))); - test.ok(isNaN(array.tickIncrement(NaN, 1, NaN))); - test.ok(isNaN(array.tickIncrement(NaN, NaN, NaN))); +it("tickIncrement(start, stop, count) returns NaN if any argument is NaN", () => { + assert(isNaN(tickIncrement(NaN, 1, 1))); + assert(isNaN(tickIncrement(0, NaN, 1))); + assert(isNaN(tickIncrement(0, 1, NaN))); + assert(isNaN(tickIncrement(NaN, NaN, 1))); + assert(isNaN(tickIncrement(0, NaN, NaN))); + assert(isNaN(tickIncrement(NaN, 1, NaN))); + assert(isNaN(tickIncrement(NaN, NaN, NaN))); }); -tape("tickIncrement(start, stop, count) returns NaN or -Infinity if start === stop", (test) => { - test.ok(isNaN(array.tickIncrement(1, 1, -1))); - test.ok(isNaN(array.tickIncrement(1, 1, 0))); - test.ok(isNaN(array.tickIncrement(1, 1, NaN))); - test.equal(array.tickIncrement(1, 1, 1), -Infinity); - test.equal(array.tickIncrement(1, 1, 10), -Infinity); +it("tickIncrement(start, stop, count) returns NaN or -Infinity if start === stop", () => { + assert(isNaN(tickIncrement(1, 1, -1))); + assert(isNaN(tickIncrement(1, 1, 0))); + assert(isNaN(tickIncrement(1, 1, NaN))); + assert.strictEqual(tickIncrement(1, 1, 1), -Infinity); + assert.strictEqual(tickIncrement(1, 1, 10), -Infinity); }); -tape("tickIncrement(start, stop, count) returns 0 or Infinity if count is not positive", (test) => { - test.equal(array.tickIncrement(0, 1, -1), Infinity); - test.equal(array.tickIncrement(0, 1, 0), Infinity); +it("tickIncrement(start, stop, count) returns 0 or Infinity if count is not positive", () => { + assert.strictEqual(tickIncrement(0, 1, -1), Infinity); + assert.strictEqual(tickIncrement(0, 1, 0), Infinity); }); -tape("tickIncrement(start, stop, count) returns -Infinity if count is infinity", (test) => { - test.equal(array.tickIncrement(0, 1, Infinity), -Infinity); +it("tickIncrement(start, stop, count) returns -Infinity if count is infinity", () => { + assert.strictEqual(tickIncrement(0, 1, Infinity), -Infinity); }); -tape("tickIncrement(start, stop, count) returns approximately count + 1 tickIncrement when start < stop", (test) => { - test.equal(array.tickIncrement( 0, 1, 10), -10); - test.equal(array.tickIncrement( 0, 1, 9), -10); - test.equal(array.tickIncrement( 0, 1, 8), -10); - test.equal(array.tickIncrement( 0, 1, 7), -5); - test.equal(array.tickIncrement( 0, 1, 6), -5); - test.equal(array.tickIncrement( 0, 1, 5), -5); - test.equal(array.tickIncrement( 0, 1, 4), -5); - test.equal(array.tickIncrement( 0, 1, 3), -2); - test.equal(array.tickIncrement( 0, 1, 2), -2); - test.equal(array.tickIncrement( 0, 1, 1), 1); - test.equal(array.tickIncrement( 0, 10, 10), 1); - test.equal(array.tickIncrement( 0, 10, 9), 1); - test.equal(array.tickIncrement( 0, 10, 8), 1); - test.equal(array.tickIncrement( 0, 10, 7), 2); - test.equal(array.tickIncrement( 0, 10, 6), 2); - test.equal(array.tickIncrement( 0, 10, 5), 2); - test.equal(array.tickIncrement( 0, 10, 4), 2); - test.equal(array.tickIncrement( 0, 10, 3), 5); - test.equal(array.tickIncrement( 0, 10, 2), 5); - test.equal(array.tickIncrement( 0, 10, 1), 10); - test.equal(array.tickIncrement(-10, 10, 10), 2); - test.equal(array.tickIncrement(-10, 10, 9), 2); - test.equal(array.tickIncrement(-10, 10, 8), 2); - test.equal(array.tickIncrement(-10, 10, 7), 2); - test.equal(array.tickIncrement(-10, 10, 6), 5); - test.equal(array.tickIncrement(-10, 10, 5), 5); - test.equal(array.tickIncrement(-10, 10, 4), 5); - test.equal(array.tickIncrement(-10, 10, 3), 5); - test.equal(array.tickIncrement(-10, 10, 2), 10); - test.equal(array.tickIncrement(-10, 10, 1), 20); +it("tickIncrement(start, stop, count) returns approximately count + 1 tickIncrement when start < stop", () => { + assert.strictEqual(tickIncrement( 0, 1, 10), -10); + assert.strictEqual(tickIncrement( 0, 1, 9), -10); + assert.strictEqual(tickIncrement( 0, 1, 8), -10); + assert.strictEqual(tickIncrement( 0, 1, 7), -5); + assert.strictEqual(tickIncrement( 0, 1, 6), -5); + assert.strictEqual(tickIncrement( 0, 1, 5), -5); + assert.strictEqual(tickIncrement( 0, 1, 4), -5); + assert.strictEqual(tickIncrement( 0, 1, 3), -2); + assert.strictEqual(tickIncrement( 0, 1, 2), -2); + assert.strictEqual(tickIncrement( 0, 1, 1), 1); + assert.strictEqual(tickIncrement( 0, 10, 10), 1); + assert.strictEqual(tickIncrement( 0, 10, 9), 1); + assert.strictEqual(tickIncrement( 0, 10, 8), 1); + assert.strictEqual(tickIncrement( 0, 10, 7), 2); + assert.strictEqual(tickIncrement( 0, 10, 6), 2); + assert.strictEqual(tickIncrement( 0, 10, 5), 2); + assert.strictEqual(tickIncrement( 0, 10, 4), 2); + assert.strictEqual(tickIncrement( 0, 10, 3), 5); + assert.strictEqual(tickIncrement( 0, 10, 2), 5); + assert.strictEqual(tickIncrement( 0, 10, 1), 10); + assert.strictEqual(tickIncrement(-10, 10, 10), 2); + assert.strictEqual(tickIncrement(-10, 10, 9), 2); + assert.strictEqual(tickIncrement(-10, 10, 8), 2); + assert.strictEqual(tickIncrement(-10, 10, 7), 2); + assert.strictEqual(tickIncrement(-10, 10, 6), 5); + assert.strictEqual(tickIncrement(-10, 10, 5), 5); + assert.strictEqual(tickIncrement(-10, 10, 4), 5); + assert.strictEqual(tickIncrement(-10, 10, 3), 5); + assert.strictEqual(tickIncrement(-10, 10, 2), 10); + assert.strictEqual(tickIncrement(-10, 10, 1), 20); }); diff --git a/test/tickStep-test.js b/test/tickStep-test.js index 78cf8bc7..79b7ca72 100644 --- a/test/tickStep-test.js +++ b/test/tickStep-test.js @@ -1,95 +1,95 @@ -const tape = require("tape-await"); -const array = require("../"); +import assert from "assert"; +import {tickStep} from "../src/index.js"; -tape("tickStep(start, stop, count) returns NaN if any argument is NaN", (test) => { - test.ok(isNaN(array.tickStep(NaN, 1, 1))); - test.ok(isNaN(array.tickStep(0, NaN, 1))); - test.ok(isNaN(array.tickStep(0, 1, NaN))); - test.ok(isNaN(array.tickStep(NaN, NaN, 1))); - test.ok(isNaN(array.tickStep(0, NaN, NaN))); - test.ok(isNaN(array.tickStep(NaN, 1, NaN))); - test.ok(isNaN(array.tickStep(NaN, NaN, NaN))); +it("tickStep(start, stop, count) returns NaN if any argument is NaN", () => { + assert(isNaN(tickStep(NaN, 1, 1))); + assert(isNaN(tickStep(0, NaN, 1))); + assert(isNaN(tickStep(0, 1, NaN))); + assert(isNaN(tickStep(NaN, NaN, 1))); + assert(isNaN(tickStep(0, NaN, NaN))); + assert(isNaN(tickStep(NaN, 1, NaN))); + assert(isNaN(tickStep(NaN, NaN, NaN))); }); -tape("tickStep(start, stop, count) returns NaN or 0 if start === stop", (test) => { - test.ok(isNaN(array.tickStep(1, 1, -1))); - test.ok(isNaN(array.tickStep(1, 1, 0))); - test.ok(isNaN(array.tickStep(1, 1, NaN))); - test.equal(array.tickStep(1, 1, 1), 0); - test.equal(array.tickStep(1, 1, 10), 0); +it("tickStep(start, stop, count) returns NaN or 0 if start === stop", () => { + assert(isNaN(tickStep(1, 1, -1))); + assert(isNaN(tickStep(1, 1, 0))); + assert(isNaN(tickStep(1, 1, NaN))); + assert.strictEqual(tickStep(1, 1, 1), 0); + assert.strictEqual(tickStep(1, 1, 10), 0); }); -tape("tickStep(start, stop, count) returns 0 or Infinity if count is not positive", (test) => { - test.equal(array.tickStep(0, 1, -1), Infinity); - test.equal(array.tickStep(0, 1, 0), Infinity); +it("tickStep(start, stop, count) returns 0 or Infinity if count is not positive", () => { + assert.strictEqual(tickStep(0, 1, -1), Infinity); + assert.strictEqual(tickStep(0, 1, 0), Infinity); }); -tape("tickStep(start, stop, count) returns 0 if count is infinity", (test) => { - test.equal(array.tickStep(0, 1, Infinity), 0); +it("tickStep(start, stop, count) returns 0 if count is infinity", () => { + assert.strictEqual(tickStep(0, 1, Infinity), 0); }); -tape("tickStep(start, stop, count) returns approximately count + 1 tickStep when start < stop", (test) => { - test.equal(array.tickStep( 0, 1, 10), 0.1); - test.equal(array.tickStep( 0, 1, 9), 0.1); - test.equal(array.tickStep( 0, 1, 8), 0.1); - test.equal(array.tickStep( 0, 1, 7), 0.2); - test.equal(array.tickStep( 0, 1, 6), 0.2); - test.equal(array.tickStep( 0, 1, 5), 0.2); - test.equal(array.tickStep( 0, 1, 4), 0.2); - test.equal(array.tickStep( 0, 1, 3), 0.5); - test.equal(array.tickStep( 0, 1, 2), 0.5); - test.equal(array.tickStep( 0, 1, 1), 1.0); - test.equal(array.tickStep( 0, 10, 10), 1); - test.equal(array.tickStep( 0, 10, 9), 1); - test.equal(array.tickStep( 0, 10, 8), 1); - test.equal(array.tickStep( 0, 10, 7), 2); - test.equal(array.tickStep( 0, 10, 6), 2); - test.equal(array.tickStep( 0, 10, 5), 2); - test.equal(array.tickStep( 0, 10, 4), 2); - test.equal(array.tickStep( 0, 10, 3), 5); - test.equal(array.tickStep( 0, 10, 2), 5); - test.equal(array.tickStep( 0, 10, 1), 10); - test.equal(array.tickStep(-10, 10, 10), 2); - test.equal(array.tickStep(-10, 10, 9), 2); - test.equal(array.tickStep(-10, 10, 8), 2); - test.equal(array.tickStep(-10, 10, 7), 2); - test.equal(array.tickStep(-10, 10, 6), 5); - test.equal(array.tickStep(-10, 10, 5), 5); - test.equal(array.tickStep(-10, 10, 4), 5); - test.equal(array.tickStep(-10, 10, 3), 5); - test.equal(array.tickStep(-10, 10, 2), 10); - test.equal(array.tickStep(-10, 10, 1), 20); +it("tickStep(start, stop, count) returns approximately count + 1 tickStep when start < stop", () => { + assert.strictEqual(tickStep( 0, 1, 10), 0.1); + assert.strictEqual(tickStep( 0, 1, 9), 0.1); + assert.strictEqual(tickStep( 0, 1, 8), 0.1); + assert.strictEqual(tickStep( 0, 1, 7), 0.2); + assert.strictEqual(tickStep( 0, 1, 6), 0.2); + assert.strictEqual(tickStep( 0, 1, 5), 0.2); + assert.strictEqual(tickStep( 0, 1, 4), 0.2); + assert.strictEqual(tickStep( 0, 1, 3), 0.5); + assert.strictEqual(tickStep( 0, 1, 2), 0.5); + assert.strictEqual(tickStep( 0, 1, 1), 1.0); + assert.strictEqual(tickStep( 0, 10, 10), 1); + assert.strictEqual(tickStep( 0, 10, 9), 1); + assert.strictEqual(tickStep( 0, 10, 8), 1); + assert.strictEqual(tickStep( 0, 10, 7), 2); + assert.strictEqual(tickStep( 0, 10, 6), 2); + assert.strictEqual(tickStep( 0, 10, 5), 2); + assert.strictEqual(tickStep( 0, 10, 4), 2); + assert.strictEqual(tickStep( 0, 10, 3), 5); + assert.strictEqual(tickStep( 0, 10, 2), 5); + assert.strictEqual(tickStep( 0, 10, 1), 10); + assert.strictEqual(tickStep(-10, 10, 10), 2); + assert.strictEqual(tickStep(-10, 10, 9), 2); + assert.strictEqual(tickStep(-10, 10, 8), 2); + assert.strictEqual(tickStep(-10, 10, 7), 2); + assert.strictEqual(tickStep(-10, 10, 6), 5); + assert.strictEqual(tickStep(-10, 10, 5), 5); + assert.strictEqual(tickStep(-10, 10, 4), 5); + assert.strictEqual(tickStep(-10, 10, 3), 5); + assert.strictEqual(tickStep(-10, 10, 2), 10); + assert.strictEqual(tickStep(-10, 10, 1), 20); }); -tape("tickStep(start, stop, count) returns -tickStep(stop, start, count)", (test) => { - test.equal(array.tickStep( 0, 1, 10), -array.tickStep( 1, 0, 10)); - test.equal(array.tickStep( 0, 1, 9), -array.tickStep( 1, 0, 9)); - test.equal(array.tickStep( 0, 1, 8), -array.tickStep( 1, 0, 8)); - test.equal(array.tickStep( 0, 1, 7), -array.tickStep( 1, 0, 7)); - test.equal(array.tickStep( 0, 1, 6), -array.tickStep( 1, 0, 6)); - test.equal(array.tickStep( 0, 1, 5), -array.tickStep( 1, 0, 5)); - test.equal(array.tickStep( 0, 1, 4), -array.tickStep( 1, 0, 4)); - test.equal(array.tickStep( 0, 1, 3), -array.tickStep( 1, 0, 3)); - test.equal(array.tickStep( 0, 1, 2), -array.tickStep( 1, 0, 2)); - test.equal(array.tickStep( 0, 1, 1), -array.tickStep( 1, 0, 1)); - test.equal(array.tickStep( 0, 10, 10), -array.tickStep(10, 0, 10)); - test.equal(array.tickStep( 0, 10, 9), -array.tickStep(10, 0, 9)); - test.equal(array.tickStep( 0, 10, 8), -array.tickStep(10, 0, 8)); - test.equal(array.tickStep( 0, 10, 7), -array.tickStep(10, 0, 7)); - test.equal(array.tickStep( 0, 10, 6), -array.tickStep(10, 0, 6)); - test.equal(array.tickStep( 0, 10, 5), -array.tickStep(10, 0, 5)); - test.equal(array.tickStep( 0, 10, 4), -array.tickStep(10, 0, 4)); - test.equal(array.tickStep( 0, 10, 3), -array.tickStep(10, 0, 3)); - test.equal(array.tickStep( 0, 10, 2), -array.tickStep(10, 0, 2)); - test.equal(array.tickStep( 0, 10, 1), -array.tickStep(10, 0, 1)); - test.equal(array.tickStep(-10, 10, 10), -array.tickStep(10, -10, 10)); - test.equal(array.tickStep(-10, 10, 9), -array.tickStep(10, -10, 9)); - test.equal(array.tickStep(-10, 10, 8), -array.tickStep(10, -10, 8)); - test.equal(array.tickStep(-10, 10, 7), -array.tickStep(10, -10, 7)); - test.equal(array.tickStep(-10, 10, 6), -array.tickStep(10, -10, 6)); - test.equal(array.tickStep(-10, 10, 5), -array.tickStep(10, -10, 5)); - test.equal(array.tickStep(-10, 10, 4), -array.tickStep(10, -10, 4)); - test.equal(array.tickStep(-10, 10, 3), -array.tickStep(10, -10, 3)); - test.equal(array.tickStep(-10, 10, 2), -array.tickStep(10, -10, 2)); - test.equal(array.tickStep(-10, 10, 1), -array.tickStep(10, -10, 1)); +it("tickStep(start, stop, count) returns -tickStep(stop, start, count)", () => { + assert.strictEqual(tickStep( 0, 1, 10), -tickStep( 1, 0, 10)); + assert.strictEqual(tickStep( 0, 1, 9), -tickStep( 1, 0, 9)); + assert.strictEqual(tickStep( 0, 1, 8), -tickStep( 1, 0, 8)); + assert.strictEqual(tickStep( 0, 1, 7), -tickStep( 1, 0, 7)); + assert.strictEqual(tickStep( 0, 1, 6), -tickStep( 1, 0, 6)); + assert.strictEqual(tickStep( 0, 1, 5), -tickStep( 1, 0, 5)); + assert.strictEqual(tickStep( 0, 1, 4), -tickStep( 1, 0, 4)); + assert.strictEqual(tickStep( 0, 1, 3), -tickStep( 1, 0, 3)); + assert.strictEqual(tickStep( 0, 1, 2), -tickStep( 1, 0, 2)); + assert.strictEqual(tickStep( 0, 1, 1), -tickStep( 1, 0, 1)); + assert.strictEqual(tickStep( 0, 10, 10), -tickStep(10, 0, 10)); + assert.strictEqual(tickStep( 0, 10, 9), -tickStep(10, 0, 9)); + assert.strictEqual(tickStep( 0, 10, 8), -tickStep(10, 0, 8)); + assert.strictEqual(tickStep( 0, 10, 7), -tickStep(10, 0, 7)); + assert.strictEqual(tickStep( 0, 10, 6), -tickStep(10, 0, 6)); + assert.strictEqual(tickStep( 0, 10, 5), -tickStep(10, 0, 5)); + assert.strictEqual(tickStep( 0, 10, 4), -tickStep(10, 0, 4)); + assert.strictEqual(tickStep( 0, 10, 3), -tickStep(10, 0, 3)); + assert.strictEqual(tickStep( 0, 10, 2), -tickStep(10, 0, 2)); + assert.strictEqual(tickStep( 0, 10, 1), -tickStep(10, 0, 1)); + assert.strictEqual(tickStep(-10, 10, 10), -tickStep(10, -10, 10)); + assert.strictEqual(tickStep(-10, 10, 9), -tickStep(10, -10, 9)); + assert.strictEqual(tickStep(-10, 10, 8), -tickStep(10, -10, 8)); + assert.strictEqual(tickStep(-10, 10, 7), -tickStep(10, -10, 7)); + assert.strictEqual(tickStep(-10, 10, 6), -tickStep(10, -10, 6)); + assert.strictEqual(tickStep(-10, 10, 5), -tickStep(10, -10, 5)); + assert.strictEqual(tickStep(-10, 10, 4), -tickStep(10, -10, 4)); + assert.strictEqual(tickStep(-10, 10, 3), -tickStep(10, -10, 3)); + assert.strictEqual(tickStep(-10, 10, 2), -tickStep(10, -10, 2)); + assert.strictEqual(tickStep(-10, 10, 1), -tickStep(10, -10, 1)); }); diff --git a/test/ticks-test.js b/test/ticks-test.js index 2adfe6cb..3b4fd985 100644 --- a/test/ticks-test.js +++ b/test/ticks-test.js @@ -1,111 +1,111 @@ -const tape = require("tape-await"); -const array = require("../"); +import assert from "assert"; +import {ticks} from "../src/index.js"; -tape("ticks(start, stop, count) returns the empty array if any argument is NaN", (test) => { - test.deepEqual(array.ticks(NaN, 1, 1), []); - test.deepEqual(array.ticks(0, NaN, 1), []); - test.deepEqual(array.ticks(0, 1, NaN), []); - test.deepEqual(array.ticks(NaN, NaN, 1), []); - test.deepEqual(array.ticks(0, NaN, NaN), []); - test.deepEqual(array.ticks(NaN, 1, NaN), []); - test.deepEqual(array.ticks(NaN, NaN, NaN), []); +it("ticks(start, stop, count) returns the empty array if any argument is NaN", () => { + assert.deepStrictEqual(ticks(NaN, 1, 1), []); + assert.deepStrictEqual(ticks(0, NaN, 1), []); + assert.deepStrictEqual(ticks(0, 1, NaN), []); + assert.deepStrictEqual(ticks(NaN, NaN, 1), []); + assert.deepStrictEqual(ticks(0, NaN, NaN), []); + assert.deepStrictEqual(ticks(NaN, 1, NaN), []); + assert.deepStrictEqual(ticks(NaN, NaN, NaN), []); }); -tape("ticks(start, stop, count) returns the empty array if start === stop and count is non-positive", (test) => { - test.deepEqual(array.ticks(1, 1, -1), []); - test.deepEqual(array.ticks(1, 1, 0), []); - test.deepEqual(array.ticks(1, 1, NaN), []); +it("ticks(start, stop, count) returns the empty array if start === stop and count is non-positive", () => { + assert.deepStrictEqual(ticks(1, 1, -1), []); + assert.deepStrictEqual(ticks(1, 1, 0), []); + assert.deepStrictEqual(ticks(1, 1, NaN), []); }); -tape("ticks(start, stop, count) returns the empty array if start === stop and count is positive", (test) => { - test.deepEqual(array.ticks(1, 1, 1), [1]); - test.deepEqual(array.ticks(1, 1, 10), [1]); +it("ticks(start, stop, count) returns the empty array if start === stop and count is positive", () => { + assert.deepStrictEqual(ticks(1, 1, 1), [1]); + assert.deepStrictEqual(ticks(1, 1, 10), [1]); }); -tape("ticks(start, stop, count) returns the empty array if count is not positive", (test) => { - test.deepEqual(array.ticks(0, 1, 0), []); - test.deepEqual(array.ticks(0, 1, -1), []); - test.deepEqual(array.ticks(0, 1, NaN), []); +it("ticks(start, stop, count) returns the empty array if count is not positive", () => { + assert.deepStrictEqual(ticks(0, 1, 0), []); + assert.deepStrictEqual(ticks(0, 1, -1), []); + assert.deepStrictEqual(ticks(0, 1, NaN), []); }); -tape("ticks(start, stop, count) returns the empty array if count is infinity", (test) => { - test.deepEqual(array.ticks(0, 1, Infinity), []); +it("ticks(start, stop, count) returns the empty array if count is infinity", () => { + assert.deepStrictEqual(ticks(0, 1, Infinity), []); }); -tape("ticks(start, stop, count) does not include negative zero", (test) => { - test.equal(1 / array.ticks(-1, 0, 5).pop(), Infinity); +it("ticks(start, stop, count) does not include negative zero", () => { + assert.strictEqual(1 / ticks(-1, 0, 5).pop(), Infinity); }); -tape("ticks(start, stop, count) remains within the domain", (test) => { - test.deepEqual(array.ticks(0, 2.2, 3), [0, 1, 2]); +it("ticks(start, stop, count) remains within the domain", () => { + assert.deepStrictEqual(ticks(0, 2.2, 3), [0, 1, 2]); }); -tape("ticks(start, stop, count) returns approximately count + 1 ticks when start < stop", (test) => { - test.deepEqual(array.ticks( 0, 1, 10), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); - test.deepEqual(array.ticks( 0, 1, 9), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); - test.deepEqual(array.ticks( 0, 1, 8), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); - test.deepEqual(array.ticks( 0, 1, 7), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); - test.deepEqual(array.ticks( 0, 1, 6), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); - test.deepEqual(array.ticks( 0, 1, 5), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); - test.deepEqual(array.ticks( 0, 1, 4), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); - test.deepEqual(array.ticks( 0, 1, 3), [0.0, 0.5, 1.0]); - test.deepEqual(array.ticks( 0, 1, 2), [0.0, 0.5, 1.0]); - test.deepEqual(array.ticks( 0, 1, 1), [0.0, 1.0]); - test.deepEqual(array.ticks( 0, 10, 10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - test.deepEqual(array.ticks( 0, 10, 9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - test.deepEqual(array.ticks( 0, 10, 8), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); - test.deepEqual(array.ticks( 0, 10, 7), [0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks( 0, 10, 6), [0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks( 0, 10, 5), [0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks( 0, 10, 4), [0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks( 0, 10, 3), [0, 5, 10]); - test.deepEqual(array.ticks( 0, 10, 2), [0, 5, 10]); - test.deepEqual(array.ticks( 0, 10, 1), [0, 10]); - test.deepEqual(array.ticks(-10, 10, 10), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks(-10, 10, 9), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks(-10, 10, 8), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks(-10, 10, 7), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); - test.deepEqual(array.ticks(-10, 10, 6), [-10, -5, 0, 5, 10]); - test.deepEqual(array.ticks(-10, 10, 5), [-10, -5, 0, 5, 10]); - test.deepEqual(array.ticks(-10, 10, 4), [-10, -5, 0, 5, 10]); - test.deepEqual(array.ticks(-10, 10, 3), [-10, -5, 0, 5, 10]); - test.deepEqual(array.ticks(-10, 10, 2), [-10, 0, 10]); - test.deepEqual(array.ticks(-10, 10, 1), [ 0, ]); +it("ticks(start, stop, count) returns approximately count + 1 ticks when start < stop", () => { + assert.deepStrictEqual(ticks( 0, 1, 10), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 9), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 8), [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 7), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 6), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 5), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 4), [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 3), [0.0, 0.5, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 2), [0.0, 0.5, 1.0]); + assert.deepStrictEqual(ticks( 0, 1, 1), [0.0, 1.0]); + assert.deepStrictEqual(ticks( 0, 10, 10), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + assert.deepStrictEqual(ticks( 0, 10, 9), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + assert.deepStrictEqual(ticks( 0, 10, 8), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + assert.deepStrictEqual(ticks( 0, 10, 7), [0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks( 0, 10, 6), [0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks( 0, 10, 5), [0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks( 0, 10, 4), [0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks( 0, 10, 3), [0, 5, 10]); + assert.deepStrictEqual(ticks( 0, 10, 2), [0, 5, 10]); + assert.deepStrictEqual(ticks( 0, 10, 1), [0, 10]); + assert.deepStrictEqual(ticks(-10, 10, 10), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks(-10, 10, 9), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks(-10, 10, 8), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks(-10, 10, 7), [-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10]); + assert.deepStrictEqual(ticks(-10, 10, 6), [-10, -5, 0, 5, 10]); + assert.deepStrictEqual(ticks(-10, 10, 5), [-10, -5, 0, 5, 10]); + assert.deepStrictEqual(ticks(-10, 10, 4), [-10, -5, 0, 5, 10]); + assert.deepStrictEqual(ticks(-10, 10, 3), [-10, -5, 0, 5, 10]); + assert.deepStrictEqual(ticks(-10, 10, 2), [-10, 0, 10]); + assert.deepStrictEqual(ticks(-10, 10, 1), [ 0, ]); }); -tape("ticks(start, stop, count) returns the reverse of ticks(stop, start, count)", (test) => { - test.deepEqual(array.ticks( 1, 0, 10), array.ticks( 0, 1, 10).reverse()); - test.deepEqual(array.ticks( 1, 0, 9), array.ticks( 0, 1, 9).reverse()); - test.deepEqual(array.ticks( 1, 0, 8), array.ticks( 0, 1, 8).reverse()); - test.deepEqual(array.ticks( 1, 0, 7), array.ticks( 0, 1, 7).reverse()); - test.deepEqual(array.ticks( 1, 0, 6), array.ticks( 0, 1, 6).reverse()); - test.deepEqual(array.ticks( 1, 0, 5), array.ticks( 0, 1, 5).reverse()); - test.deepEqual(array.ticks( 1, 0, 4), array.ticks( 0, 1, 4).reverse()); - test.deepEqual(array.ticks( 1, 0, 3), array.ticks( 0, 1, 3).reverse()); - test.deepEqual(array.ticks( 1, 0, 2), array.ticks( 0, 1, 2).reverse()); - test.deepEqual(array.ticks( 1, 0, 1), array.ticks( 0, 1, 1).reverse()); - test.deepEqual(array.ticks(10, 0, 10), array.ticks( 0, 10, 10).reverse()); - test.deepEqual(array.ticks(10, 0, 9), array.ticks( 0, 10, 9).reverse()); - test.deepEqual(array.ticks(10, 0, 8), array.ticks( 0, 10, 8).reverse()); - test.deepEqual(array.ticks(10, 0, 7), array.ticks( 0, 10, 7).reverse()); - test.deepEqual(array.ticks(10, 0, 6), array.ticks( 0, 10, 6).reverse()); - test.deepEqual(array.ticks(10, 0, 5), array.ticks( 0, 10, 5).reverse()); - test.deepEqual(array.ticks(10, 0, 4), array.ticks( 0, 10, 4).reverse()); - test.deepEqual(array.ticks(10, 0, 3), array.ticks( 0, 10, 3).reverse()); - test.deepEqual(array.ticks(10, 0, 2), array.ticks( 0, 10, 2).reverse()); - test.deepEqual(array.ticks(10, 0, 1), array.ticks( 0, 10, 1).reverse()); - test.deepEqual(array.ticks(10, -10, 10), array.ticks(-10, 10, 10).reverse()); - test.deepEqual(array.ticks(10, -10, 9), array.ticks(-10, 10, 9).reverse()); - test.deepEqual(array.ticks(10, -10, 8), array.ticks(-10, 10, 8).reverse()); - test.deepEqual(array.ticks(10, -10, 7), array.ticks(-10, 10, 7).reverse()); - test.deepEqual(array.ticks(10, -10, 6), array.ticks(-10, 10, 6).reverse()); - test.deepEqual(array.ticks(10, -10, 5), array.ticks(-10, 10, 5).reverse()); - test.deepEqual(array.ticks(10, -10, 4), array.ticks(-10, 10, 4).reverse()); - test.deepEqual(array.ticks(10, -10, 3), array.ticks(-10, 10, 3).reverse()); - test.deepEqual(array.ticks(10, -10, 2), array.ticks(-10, 10, 2).reverse()); - test.deepEqual(array.ticks(10, -10, 1), array.ticks(-10, 10, 1).reverse()); +it("ticks(start, stop, count) returns the reverse of ticks(stop, start, count)", () => { + assert.deepStrictEqual(ticks( 1, 0, 10), ticks( 0, 1, 10).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 9), ticks( 0, 1, 9).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 8), ticks( 0, 1, 8).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 7), ticks( 0, 1, 7).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 6), ticks( 0, 1, 6).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 5), ticks( 0, 1, 5).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 4), ticks( 0, 1, 4).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 3), ticks( 0, 1, 3).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 2), ticks( 0, 1, 2).reverse()); + assert.deepStrictEqual(ticks( 1, 0, 1), ticks( 0, 1, 1).reverse()); + assert.deepStrictEqual(ticks(10, 0, 10), ticks( 0, 10, 10).reverse()); + assert.deepStrictEqual(ticks(10, 0, 9), ticks( 0, 10, 9).reverse()); + assert.deepStrictEqual(ticks(10, 0, 8), ticks( 0, 10, 8).reverse()); + assert.deepStrictEqual(ticks(10, 0, 7), ticks( 0, 10, 7).reverse()); + assert.deepStrictEqual(ticks(10, 0, 6), ticks( 0, 10, 6).reverse()); + assert.deepStrictEqual(ticks(10, 0, 5), ticks( 0, 10, 5).reverse()); + assert.deepStrictEqual(ticks(10, 0, 4), ticks( 0, 10, 4).reverse()); + assert.deepStrictEqual(ticks(10, 0, 3), ticks( 0, 10, 3).reverse()); + assert.deepStrictEqual(ticks(10, 0, 2), ticks( 0, 10, 2).reverse()); + assert.deepStrictEqual(ticks(10, 0, 1), ticks( 0, 10, 1).reverse()); + assert.deepStrictEqual(ticks(10, -10, 10), ticks(-10, 10, 10).reverse()); + assert.deepStrictEqual(ticks(10, -10, 9), ticks(-10, 10, 9).reverse()); + assert.deepStrictEqual(ticks(10, -10, 8), ticks(-10, 10, 8).reverse()); + assert.deepStrictEqual(ticks(10, -10, 7), ticks(-10, 10, 7).reverse()); + assert.deepStrictEqual(ticks(10, -10, 6), ticks(-10, 10, 6).reverse()); + assert.deepStrictEqual(ticks(10, -10, 5), ticks(-10, 10, 5).reverse()); + assert.deepStrictEqual(ticks(10, -10, 4), ticks(-10, 10, 4).reverse()); + assert.deepStrictEqual(ticks(10, -10, 3), ticks(-10, 10, 3).reverse()); + assert.deepStrictEqual(ticks(10, -10, 2), ticks(-10, 10, 2).reverse()); + assert.deepStrictEqual(ticks(10, -10, 1), ticks(-10, 10, 1).reverse()); }); -tape("ticks(start, stop, count) handles precision problems", (test) => { - test.deepEqual(array.ticks(0.98, 1.14, 10), [0.98, 1, 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14]); +it("ticks(start, stop, count) handles precision problems", () => { + assert.deepStrictEqual(ticks(0.98, 1.14, 10), [0.98, 1, 1.02, 1.04, 1.06, 1.08, 1.1, 1.12, 1.14]); }); diff --git a/test/transpose-test.js b/test/transpose-test.js index 3eb8ff0d..341eb551 100644 --- a/test/transpose-test.js +++ b/test/transpose-test.js @@ -1,31 +1,31 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {transpose} from "../src/index.js"; -tape("transpose([]) and transpose([[]]) return an empty array", (test) => { - test.deepEqual(d3.transpose([]), []); - test.deepEqual(d3.transpose([[]]), []); +it("transpose([]) and transpose([[]]) return an empty array", () => { + assert.deepStrictEqual(transpose([]), []); + assert.deepStrictEqual(transpose([[]]), []); }); -tape("transpose([[a, b, …]]) returns [[a], [b], …]", (test) => { - test.deepEqual(d3.transpose([[1, 2, 3, 4, 5]]), [[1], [2], [3], [4], [5]]); +it("transpose([[a, b, …]]) returns [[a], [b], …]", () => { + assert.deepStrictEqual(transpose([[1, 2, 3, 4, 5]]), [[1], [2], [3], [4], [5]]); }); -tape("transpose([[a1, b1, …], [a2, b2, …]]) returns [[a1, a2], [b1, b2], …]", (test) => { - test.deepEqual(d3.transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); - test.deepEqual(d3.transpose([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]]), [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]); +it("transpose([[a1, b1, …], [a2, b2, …]]) returns [[a1, a2], [b1, b2], …]", () => { + assert.deepStrictEqual(transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); + assert.deepStrictEqual(transpose([[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]]), [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]); }); -tape("transpose([[a1, b1, …], [a2, b2, …], [a3, b3, …]]) returns [[a1, a2, a3], [b1, b2, b3], …]", (test) => { - test.deepEqual(d3.transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); +it("transpose([[a1, b1, …], [a2, b2, …], [a3, b3, …]]) returns [[a1, a2, a3], [b1, b2, b3], …]", () => { + assert.deepStrictEqual(transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); }); -tape("transpose(…) ignores extra elements given an irregular matrix", (test) => { - test.deepEqual(d3.transpose([[1, 2], [3, 4], [5, 6, 7]]), [[1, 3, 5], [2, 4, 6]]); +it("transpose(…) ignores extra elements given an irregular matrix", () => { + assert.deepStrictEqual(transpose([[1, 2], [3, 4], [5, 6, 7]]), [[1, 3, 5], [2, 4, 6]]); }); -tape("transpose(…) returns a copy", (test) => { +it("transpose(…) returns a copy", () => { const matrix = [[1, 2], [3, 4]]; - const tranpose = d3.transpose(matrix); + const t = transpose(matrix); matrix[0][0] = matrix[0][1] = matrix[1][0] = matrix[1][1] = 0; - test.deepEqual(tranpose, [[1, 3], [2, 4]]); + assert.deepStrictEqual(t, [[1, 3], [2, 4]]); }); diff --git a/test/union-test.js b/test/union-test.js index 69d05a76..00635ae2 100644 --- a/test/union-test.js +++ b/test/union-test.js @@ -1,21 +1,19 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import {union} from "../src/index.js"; +import {assertSetEqual} from "./asserts.js"; -require("./setEqual"); - -tape("union(values) returns a set of values", (test) => { - test.setEqual(d3.union([1, 2, 3, 2, 1]), new Set([1, 2, 3])); +it("union(values) returns a set of values", () => { + assertSetEqual(union([1, 2, 3, 2, 1]), new Set([1, 2, 3])); }); -tape("union(values, other) returns a set of values", (test) => { - test.setEqual(d3.union([1, 2], [2, 3, 1]), new Set([1, 2, 3])); +it("union(values, other) returns a set of values", () => { + assertSetEqual(union([1, 2], [2, 3, 1]), new Set([1, 2, 3])); }); -tape("union(...values) returns a set of values", (test) => { - test.setEqual(d3.union([1], [2], [2, 3], [1]), new Set([1, 2, 3])); +it("union(...values) returns a set of values", () => { + assertSetEqual(union([1], [2], [2, 3], [1]), new Set([1, 2, 3])); }); -tape("union(...values) accepts iterables", (test) => { - test.setEqual(d3.union(new Set([1, 2, 3])), new Set([1, 2, 3])); - test.setEqual(d3.union(Uint8Array.of(1, 2, 3)), new Set([1, 2, 3])); +it("union(...values) accepts iterables", () => { + assertSetEqual(union(new Set([1, 2, 3])), new Set([1, 2, 3])); + assertSetEqual(union(Uint8Array.of(1, 2, 3)), new Set([1, 2, 3])); }); diff --git a/test/variance-test.js b/test/variance-test.js index a1602dad..97fa5959 100644 --- a/test/variance-test.js +++ b/test/variance-test.js @@ -1,69 +1,69 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {variance} from "../src/index.js"; -tape("variance(array) returns the variance of the specified numbers", (test) => { - test.equal(d3.variance([5, 1, 2, 3, 4]), 2.5); - test.equal(d3.variance([20, 3]), 144.5); - test.equal(d3.variance([3, 20]), 144.5); +it("variance(array) returns the variance of the specified numbers", () => { + assert.strictEqual(variance([5, 1, 2, 3, 4]), 2.5); + assert.strictEqual(variance([20, 3]), 144.5); + assert.strictEqual(variance([3, 20]), 144.5); }); -tape("variance(array) ignores null, undefined and NaN", (test) => { - test.equal(d3.variance([NaN, 1, 2, 3, 4, 5]), 2.5); - test.equal(d3.variance([1, 2, 3, 4, 5, NaN]), 2.5); - test.equal(d3.variance([10, null, 3, undefined, 5, NaN]), 13); +it("variance(array) ignores null, undefined and NaN", () => { + assert.strictEqual(variance([NaN, 1, 2, 3, 4, 5]), 2.5); + assert.strictEqual(variance([1, 2, 3, 4, 5, NaN]), 2.5); + assert.strictEqual(variance([10, null, 3, undefined, 5, NaN]), 13); }); -tape("variance(array) can handle large numbers without overflowing", (test) => { - test.equal(d3.variance([Number.MAX_VALUE, Number.MAX_VALUE]), 0); - test.equal(d3.variance([-Number.MAX_VALUE, -Number.MAX_VALUE]), 0); +it("variance(array) can handle large numbers without overflowing", () => { + assert.strictEqual(variance([Number.MAX_VALUE, Number.MAX_VALUE]), 0); + assert.strictEqual(variance([-Number.MAX_VALUE, -Number.MAX_VALUE]), 0); }); -tape("variance(array) returns undefined if the array has fewer than two numbers", (test) => { - test.equal(d3.variance([1]), undefined); - test.equal(d3.variance([]), undefined); - test.equal(d3.variance([null]), undefined); - test.equal(d3.variance([undefined]), undefined); - test.equal(d3.variance([NaN]), undefined); - test.equal(d3.variance([NaN, NaN]), undefined); +it("variance(array) returns undefined if the array has fewer than two numbers", () => { + assert.strictEqual(variance([1]), undefined); + assert.strictEqual(variance([]), undefined); + assert.strictEqual(variance([null]), undefined); + assert.strictEqual(variance([undefined]), undefined); + assert.strictEqual(variance([NaN]), undefined); + assert.strictEqual(variance([NaN, NaN]), undefined); }); -tape("variance(array, f) returns the variance of the specified numbers", (test) => { - test.equal(d3.variance([5, 1, 2, 3, 4].map(box), unbox), 2.5); - test.equal(d3.variance([20, 3].map(box), unbox), 144.5); - test.equal(d3.variance([3, 20].map(box), unbox), 144.5); +it("variance(array, f) returns the variance of the specified numbers", () => { + assert.strictEqual(variance([5, 1, 2, 3, 4].map(box), unbox), 2.5); + assert.strictEqual(variance([20, 3].map(box), unbox), 144.5); + assert.strictEqual(variance([3, 20].map(box), unbox), 144.5); }); -tape("variance(array, f) ignores null, undefined and NaN", (test) => { - test.equal(d3.variance([NaN, 1, 2, 3, 4, 5].map(box), unbox), 2.5); - test.equal(d3.variance([1, 2, 3, 4, 5, NaN].map(box), unbox), 2.5); - test.equal(d3.variance([10, null, 3, undefined, 5, NaN].map(box), unbox), 13); +it("variance(array, f) ignores null, undefined and NaN", () => { + assert.strictEqual(variance([NaN, 1, 2, 3, 4, 5].map(box), unbox), 2.5); + assert.strictEqual(variance([1, 2, 3, 4, 5, NaN].map(box), unbox), 2.5); + assert.strictEqual(variance([10, null, 3, undefined, 5, NaN].map(box), unbox), 13); }); -tape("variance(array, f) can handle large numbers without overflowing", (test) => { - test.equal(d3.variance([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), 0); - test.equal(d3.variance([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), 0); +it("variance(array, f) can handle large numbers without overflowing", () => { + assert.strictEqual(variance([Number.MAX_VALUE, Number.MAX_VALUE].map(box), unbox), 0); + assert.strictEqual(variance([-Number.MAX_VALUE, -Number.MAX_VALUE].map(box), unbox), 0); }); -tape("variance(array, f) returns undefined if the array has fewer than two numbers", (test) => { - test.equal(d3.variance([1].map(box), unbox), undefined); - test.equal(d3.variance([].map(box), unbox), undefined); - test.equal(d3.variance([null].map(box), unbox), undefined); - test.equal(d3.variance([undefined].map(box), unbox), undefined); - test.equal(d3.variance([NaN].map(box), unbox), undefined); - test.equal(d3.variance([NaN, NaN].map(box), unbox), undefined); +it("variance(array, f) returns undefined if the array has fewer than two numbers", () => { + assert.strictEqual(variance([1].map(box), unbox), undefined); + assert.strictEqual(variance([].map(box), unbox), undefined); + assert.strictEqual(variance([null].map(box), unbox), undefined); + assert.strictEqual(variance([undefined].map(box), unbox), undefined); + assert.strictEqual(variance([NaN].map(box), unbox), undefined); + assert.strictEqual(variance([NaN, NaN].map(box), unbox), undefined); }); -tape("variance(array, f) passes the accessor d, i, and array", (test) => { +it("variance(array, f) passes the accessor d, i, and array", () => { const results = []; const array = ["a", "b", "c"]; - d3.variance(array, (d, i, array) => results.push([d, i, array])); - test.deepEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); + variance(array, (d, i, array) => results.push([d, i, array])); + assert.deepStrictEqual(results, [["a", 0, array], ["b", 1, array], ["c", 2, array]]); }); -tape("variance(array, f) uses the global context", (test) => { +it("variance(array, f) uses the undefined context", () => { const results = []; - d3.variance([1, 2], function() { results.push(this); }); - test.deepEqual(results, [global, global]); + variance([1, 2], function() { results.push(this); }); + assert.deepStrictEqual(results, [undefined, undefined]); }); function box(value) { diff --git a/test/zip-test.js b/test/zip-test.js index c3e4f87b..91c66ad3 100644 --- a/test/zip-test.js +++ b/test/zip-test.js @@ -1,24 +1,24 @@ -const tape = require("tape-await"); -const d3 = require("../"); +import assert from "assert"; +import {zip} from "../src/index.js"; -tape("zip() and zip([]) return an empty array", (test) => { - test.deepEqual(d3.zip(), []); - test.deepEqual(d3.zip([]), []); +it("zip() and zip([]) return an empty array", () => { + assert.deepStrictEqual(zip(), []); + assert.deepStrictEqual(zip([]), []); }); -tape("zip([a, b, …]) returns [[a], [b], …]", (test) => { - test.deepEqual(d3.zip([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]]); +it("zip([a, b, …]) returns [[a], [b], …]", () => { + assert.deepStrictEqual(zip([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]]); }); -tape("zip([a1, b1, …], [a2, b2, …]) returns [[a1, a2], [b1, b2], …]", (test) => { - test.deepEqual(d3.zip([1, 2], [3, 4]), [[1, 3], [2, 4]]); - test.deepEqual(d3.zip([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]), [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]); +it("zip([a1, b1, …], [a2, b2, …]) returns [[a1, a2], [b1, b2], …]", () => { + assert.deepStrictEqual(zip([1, 2], [3, 4]), [[1, 3], [2, 4]]); + assert.deepStrictEqual(zip([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]), [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]); }); -tape("zip([a1, b1, …], [a2, b2, …], [a3, b3, …]) returns [[a1, a2, a3], [b1, b2, b3], …]", (test) => { - test.deepEqual(d3.zip([1, 2, 3], [4, 5, 6], [7, 8, 9]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); +it("zip([a1, b1, …], [a2, b2, …], [a3, b3, …]) returns [[a1, a2, a3], [b1, b2, b3], …]", () => { + assert.deepStrictEqual(zip([1, 2, 3], [4, 5, 6], [7, 8, 9]), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); }); -tape("zip(…) ignores extra elements given an irregular matrix", (test) => { - test.deepEqual(d3.zip([1, 2], [3, 4], [5, 6, 7]), [[1, 3, 5], [2, 4, 6]]); +it("zip(…) ignores extra elements given an irregular matrix", () => { + assert.deepStrictEqual(zip([1, 2], [3, 4], [5, 6, 7]), [[1, 3, 5], [2, 4, 6]]); }); diff --git a/yarn.lock b/yarn.lock index 40b20791..d6448ad7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,39 +16,39 @@ dependencies: "@babel/highlight" "^7.12.13" -"@babel/helper-validator-identifier@^7.12.11": - version "7.12.11" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" - integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== +"@babel/helper-validator-identifier@^7.14.0": + version "7.14.0" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.0.tgz#d26cad8a47c65286b15df1547319a5d0bcf27288" + integrity sha512-V3ts7zMSu5lfiwWDVWzRDGIN+lnCEUdaXgtVHJgLb1rGaA6jMrtB9EmE7L18foXJIE8Un/A/h6NJfGQp/e1J4A== "@babel/highlight@^7.10.4", "@babel/highlight@^7.12.13": - version "7.13.10" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.13.10.tgz#a8b2a66148f5b27d666b15d81774347a731d52d1" - integrity sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg== + version "7.14.0" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.14.0.tgz#3197e375711ef6bf834e67d0daec88e4f46113cf" + integrity sha512-YSCOwxvTYEIMSGaBQb5kDDsCopDdiUGsqpatp3fOlI4+2HQSkTmEVWnVuySdAC5EWCqSWWTv0ib63RjR7dTBdg== dependencies: - "@babel/helper-validator-identifier" "^7.12.11" + "@babel/helper-validator-identifier" "^7.14.0" chalk "^2.0.0" js-tokens "^4.0.0" -"@eslint/eslintrc@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.0.tgz#99cc0a0584d72f1df38b900fb062ba995f395547" - integrity sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog== +"@eslint/eslintrc@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.2.tgz#f63d0ef06f5c0c57d76c4ab5f63d3835c51b0179" + integrity sha512-8nmGq/4ycLpIwzvhI4tNDmQztZ8sp+hI7cyG8i1nQDhkAbRzHpXPidRAHlNvCZQpJTKw5ItIpMw9RSToGF00mg== dependencies: ajv "^6.12.4" debug "^4.1.1" espree "^7.3.0" - globals "^12.1.0" + globals "^13.9.0" ignore "^4.0.6" import-fresh "^3.2.1" js-yaml "^3.13.1" minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@rollup/plugin-node-resolve@11": - version "11.2.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.0.tgz#a5ab88c35bb7622d115f44984dee305112b6f714" - integrity sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA== +"@rollup/plugin-node-resolve@13": + version "13.0.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.0.0.tgz#352f07e430ff377809ec8ec8a6fd636547162dc4" + integrity sha512-41X411HJ3oikIDivT5OKe9EZ6ud6DXudtfNrGbC4nniaxx2esiWjkLOzgnZsWq1IM8YIeL2rzRGLZLBjlhnZtQ== dependencies: "@rollup/pluginutils" "^3.1.0" "@types/resolve" "1.17.1" @@ -66,15 +66,20 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@tootallnate/once@1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== + "@types/estree@0.0.39": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== "@types/node@*": - version "14.14.33" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.33.tgz#9e4f8c64345522e4e8ce77b334a8aaa64e2b6c78" - integrity sha512-oJqcTrgPUF29oUP8AsUqbXGJNuPutsetaa9kTQAQce5Lx5dTYWV02ScBiT/k1BX/Z7pKeqedmvp39Wu4zR7N7g== + version "15.12.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.1.tgz#9b60797dee1895383a725f828a869c86c6caa5c2" + integrity sha512-zyxJM8I1c9q5sRMtVF+zdd13Jt6RU4r4qfhTd7lQubyThvLfx6yYekWSQjGCGV2Tkecgxnlpl/DNlb6Hg+dmEw== "@types/resolve@1.17.1": version "1.17.1" @@ -83,6 +88,11 @@ dependencies: "@types/node" "*" +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== + abab@^2.0.3, abab@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a" @@ -111,12 +121,19 @@ acorn@^7.1.1, acorn@^7.4.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.0.5: - version "8.1.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.1.0.tgz#52311fd7037ae119cbb134309e901aa46295b3fe" - integrity sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA== +acorn@^8.2.4: + version "8.3.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.3.0.tgz#1193f9b96c4e8232f00b11a9edff81b2c8b98b88" + integrity sha512-tqPKHZ5CaBJw0Xmy0ZZvLs1qTV+BNFSyvn77ASXkpBNfIRk8ev26fKrD9iLGwGA9zedPao52GSHzq8lyZG0NUw== + +agent-base@6: + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: +ajv@^6.10.0, ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -126,21 +143,26 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^7.0.2: - version "7.2.1" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-7.2.1.tgz#a5ac226171912447683524fa2f1248fcf8bac83d" - integrity sha512-+nu0HDv7kNSOua9apAVc979qd932rrZeb3WOvoiD31A/p1mIE5/9bN2027pE2rOPYEdS3UHzsvof4hY+lM9/WQ== +ajv@^8.0.1: + version "8.5.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.5.0.tgz#695528274bcb5afc865446aa275484049a18ae4b" + integrity sha512-Y2l399Tt1AguU3BPRP9Fn4eN+Or+StUGWCUpbnFyXSo8NZ9S4uj+AG2pjs5apK+ZMOwYOz1+a+VKvKH7CudXgQ== dependencies: fast-deep-equal "^3.1.1" json-schema-traverse "^1.0.0" require-from-string "^2.0.2" uri-js "^4.2.2" -ansi-colors@^4.1.1: +ansi-colors@4.1.1, ansi-colors@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + ansi-regex@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" @@ -160,6 +182,14 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +anymatch@~3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" + integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -167,17 +197,10 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -asn1@~0.2.3: - version "0.2.4" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" - integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== - dependencies: - safer-buffer "~2.1.0" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== astral-regex@^2.0.0: version "2.0.0" @@ -189,27 +212,15 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= -aws-sign2@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= - -aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== - balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -bcrypt-pbkdf@^1.0.0: version "1.0.2" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= - dependencies: - tweetnacl "^0.14.3" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== brace-expansion@^1.1.7: version "1.1.11" @@ -219,11 +230,23 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + browser-process-hrtime@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -234,23 +257,15 @@ builtin-modules@^3.1.0: resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.2.0.tgz#45d5db99e7ee5e6bc4f362e008bf917ab5049887" integrity sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA== -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== -caseless@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= +camelcase@^6.0.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" + integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== chalk@^2.0.0: version "2.4.2" @@ -262,13 +277,37 @@ chalk@^2.0.0: supports-color "^5.3.0" chalk@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + version "4.1.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" + integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== dependencies: ansi-styles "^4.1.0" supports-color "^7.1.0" +chokidar@3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" + integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.5.0" + optionalDependencies: + fsevents "~2.3.1" + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" @@ -293,7 +332,7 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== -combined-stream@^1.0.6, combined-stream@~1.0.6: +combined-stream@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== @@ -310,11 +349,6 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -core-util-is@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= - cross-spawn@^7.0.2: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -341,17 +375,10 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -d3-random@2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/d3-random/-/d3-random-2.2.2.tgz#5eebd209ef4e45a2b362b019c1fb21c2c98cbb6e" - integrity sha512-0D9P8TRj6qDAtHhRQn6EfdOtHMfsUWanl3yb/84C4DqpZ+VsgfI5iTVRNRbELCfNvRfpMr8OrqqUTQ6ANGCijw== - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= - dependencies: - assert-plus "^1.0.0" +"d3-random@2 - 3": + version "3.0.0" + resolved "https://registry.yarnpkg.com/d3-random/-/d3-random-3.0.0.tgz#432091257c85d83d4c4ecd4e85dbd4bcd64edbfc" + integrity sha512-BsMgLaCOUlQrfcCZl6O99kDjwl6iISiD17fmE1v5M88e9k7rVsdJ7byS1oeZ05mF+Ocaanvepq99A8HFmjUwug== data-urls@^2.0.0: version "2.0.0" @@ -362,30 +389,23 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" -debug@^4.0.1, debug@^4.1.1: +debug@4, debug@4.3.1, debug@^4.0.1, debug@^4.1.1: version "4.3.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== dependencies: ms "2.1.2" +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + decimal.js@^10.2.1: version "10.2.1" resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.2.1.tgz#238ae7b0f0c793d3e3cea410108b35a2c01426a3" integrity sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw== -deep-equal@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" - integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== - dependencies: - is-arguments "^1.0.4" - is-date-object "^1.0.1" - is-regex "^1.0.4" - object-is "^1.0.1" - object-keys "^1.1.1" - regexp.prototype.flags "^1.2.0" - deep-is@^0.1.3, deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -396,23 +416,16 @@ deepmerge@^4.2.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== -define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== - dependencies: - object-keys "^1.0.12" - -defined@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" - integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= - delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -427,21 +440,6 @@ domexception@^2.0.1: dependencies: webidl-conversions "^5.0.0" -dotignore@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/dotignore/-/dotignore-0.1.2.tgz#f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905" - integrity sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw== - dependencies: - minimatch "^3.0.4" - -ecc-jsbn@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= - dependencies: - jsbn "~0.1.0" - safer-buffer "^2.1.0" - emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -454,36 +452,15 @@ enquirer@^2.3.5: dependencies: ansi-colors "^4.1.1" -es-abstract@^1.18.0-next.2: - version "1.18.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0.tgz#ab80b359eecb7ede4c298000390bc5ac3ec7b5a4" - integrity sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw== - dependencies: - call-bind "^1.0.2" - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - get-intrinsic "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.2" - is-callable "^1.2.3" - is-negative-zero "^2.0.1" - is-regex "^1.1.2" - is-string "^1.0.5" - object-inspect "^1.9.0" - object-keys "^1.1.1" - object.assign "^4.1.2" - string.prototype.trimend "^1.0.4" - string.prototype.trimstart "^1.0.4" - unbox-primitive "^1.0.0" - -es-to-primitive@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" - integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== - dependencies: - is-callable "^1.1.4" - is-date-object "^1.0.1" - is-symbol "^1.0.2" +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== escape-string-regexp@^1.0.5: version "1.0.5" @@ -523,33 +500,35 @@ eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== eslint-visitor-keys@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" - integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== eslint@7: - version "7.21.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.21.0.tgz#4ecd5b8c5b44f5dedc9b8a110b01bbfeb15d1c83" - integrity sha512-W2aJbXpMNofUp0ztQaF40fveSsJBjlSCSWpy//gzfTvwC+USs/nceBrKmlJOiM8r1bLwP2EuYkCqArn/6QTIgg== + version "7.28.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.28.0.tgz#435aa17a0b82c13bb2be9d51408b617e49c1e820" + integrity sha512-UMfH0VSjP0G4p3EWirscJEQ/cHqnT/iuH6oNZOB94nBjWbMnhGEPxsZm1eyIW0C/9jLI0Fow4W5DXLjEI7mn1g== dependencies: "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.0" + "@eslint/eslintrc" "^0.4.2" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.0.1" doctrine "^3.0.0" enquirer "^2.3.5" + escape-string-regexp "^4.0.0" eslint-scope "^5.1.1" eslint-utils "^2.1.0" eslint-visitor-keys "^2.0.0" espree "^7.3.1" esquery "^1.4.0" esutils "^2.0.2" + fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" - globals "^12.1.0" + glob-parent "^5.1.2" + globals "^13.6.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" @@ -557,7 +536,7 @@ eslint@7: js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" - lodash "^4.17.20" + lodash.merge "^4.6.2" minimatch "^3.0.4" natural-compare "^1.4.0" optionator "^0.9.1" @@ -566,7 +545,7 @@ eslint@7: semver "^7.2.1" strip-ansi "^6.0.0" strip-json-comments "^3.1.0" - table "^6.0.4" + table "^6.0.9" text-table "^0.2.0" v8-compile-cache "^2.0.3" @@ -618,22 +597,7 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -extend@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== - -extsprintf@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= - -extsprintf@^1.2.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" - integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= - -fast-deep-equal@^3.1.1: +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== @@ -655,6 +619,21 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -663,30 +642,23 @@ flat-cache@^3.0.4: flatted "^3.1.0" rimraf "^3.0.2" +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + flatted@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== -for-each@~0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" - integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== - dependencies: - is-callable "^1.1.3" - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= - -form-data@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" - integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== dependencies: asynckit "^0.4.0" - combined-stream "^1.0.6" + combined-stream "^1.0.8" mime-types "^2.1.12" fs.realpath@^1.0.0: @@ -699,7 +671,7 @@ fsevents@~2.3.1: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -function-bind@^1.1.1, function-bind@~1.1.1: +function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== @@ -709,30 +681,19 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= - dependencies: - assert-plus "^1.0.0" +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -glob-parent@^5.0.0: +glob-parent@^5.1.2, glob-parent@~5.1.0: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@^7.1.3, glob@~7.1.6: +glob@7.1.6: version "7.1.6" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== @@ -744,30 +705,29 @@ glob@^7.1.3, glob@~7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^12.1.0: - version "12.4.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" - integrity sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg== +glob@^7.1.3: + version "7.1.7" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" + integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== dependencies: - type-fest "^0.8.1" - -har-schema@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" -har-validator@~5.1.3: - version "5.1.5" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" - integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== +globals@^13.6.0, globals@^13.9.0: + version "13.9.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.9.0.tgz#4bf2bf635b334a173fb1daf7c5e6b218ecdc06cb" + integrity sha512-74/FduwI/JaIrr1H8e71UbDE+5x7pIPs1C2rrwC52SszOo043CsWOZEMW7o2Y58xwm9b+0RBKDxY5n2sUpEFxA== dependencies: - ajv "^6.12.3" - har-schema "^2.0.0" + type-fest "^0.20.2" -has-bigints@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" - integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== has-flag@^3.0.0: version "3.0.0" @@ -779,18 +739,18 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.0, has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" - integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== - -has@^1.0.3, has@~1.0.3: +has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: function-bind "^1.1.1" +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + html-encoding-sniffer@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz#42a6dc4fd33f00281176e8b23759ca4e4fa185f3" @@ -798,14 +758,22 @@ html-encoding-sniffer@^2.0.1: dependencies: whatwg-encoding "^1.0.5" -http-signature@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= +http-proxy-agent@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" + integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== dependencies: - assert-plus "^1.0.0" - jsprim "^1.2.2" - sshpk "^1.7.0" + "@tootallnate/once" "1" + agent-base "6" + debug "4" + +https-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" + integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== + dependencies: + agent-base "6" + debug "4" iconv-lite@0.4.24: version "0.4.24" @@ -840,63 +808,46 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@~2.0.4: +inherits@2: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -internmap@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/internmap/-/internmap-1.0.1.tgz#0017cc8a3b99605f0302f2b198d272e015e5df95" - integrity sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw== - -is-arguments@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.0.tgz#62353031dfbee07ceb34656a6bde59efecae8dd9" - integrity sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg== - dependencies: - call-bind "^1.0.0" - -is-bigint@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.1.tgz#6923051dfcbc764278540b9ce0e6b3213aa5ebc2" - integrity sha512-J0ELF4yHFxHy0cmSxZuheDOz2luOdVvqjwmEcj8H/L1JHeuEDSDbeRP+Dk9kFVk5RTFzbucJ2Kb9F7ixY2QaCg== +"internmap@1 - 2": + version "2.0.0" + resolved "https://registry.yarnpkg.com/internmap/-/internmap-2.0.0.tgz#cc38ce0c33eaf4501c07c990673c07caa782179a" + integrity sha512-XpWRFi4iwmWoSbMQQPUL7c3Qze/wfEnJxtpMC32awNzo7QC06vNZ6xXz/bLZyHxmMGoiX93eSxXEyTFQB83ukQ== -is-boolean-object@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.0.tgz#e2aaad3a3a8fca34c28f6eee135b156ed2587ff0" - integrity sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA== +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: - call-bind "^1.0.0" - -is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.3.tgz#8b1e0500b73a1d76c70487636f368e519de8db8e" - integrity sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ== + binary-extensions "^2.0.0" is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== + version "2.4.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1" + integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A== dependencies: has "^1.0.3" -is-date-object@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" - integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== - is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + is-fullwidth-code-point@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-glob@^4.0.0, is-glob@^4.0.1: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== @@ -908,63 +859,26 @@ is-module@^1.0.0: resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= -is-negative-zero@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" - integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== - -is-number-object@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" - integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== - -is-potential-custom-element-name@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397" - integrity sha1-DFLlS8yjkbssSUsh6GJtczbG45c= - -is-regex@^1.0.4, is-regex@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.2.tgz#81c8ebde4db142f2cf1c53fc86d6a45788266251" - integrity sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg== - dependencies: - call-bind "^1.0.2" - has-symbols "^1.0.1" - -is-regex@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" - integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== - dependencies: - has "^1.0.3" - -is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-symbol@^1.0.2, is-symbol@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" - integrity sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ== - dependencies: - has-symbols "^1.0.1" +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= +is-potential-custom-element-name@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" + integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= - jest-worker@^26.2.1: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" @@ -979,6 +893,13 @@ js-tokens@^4.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +js-yaml@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== + dependencies: + argparse "^2.0.1" + js-yaml@^3.13.1: version "3.14.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" @@ -987,18 +908,13 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -jsbn@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= - jsdom@16: - version "16.5.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.5.0.tgz#9e453505600cc5a70b385750d35256f380730cc4" - integrity sha512-QxZH0nmDTnTTVI0YDm4RUlaUPl5dcyn62G5TMDNfMmTW+J1u1v9gCR8WR+WZ6UghAa7nKJjDOFaI00eMMWvJFQ== + version "16.6.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.6.0.tgz#f79b3786682065492a3da6a60a4695da983805ac" + integrity sha512-Ty1vmF4NHJkolaEmdjtxTfSfkdb8Ywarwf63f+F8/mDD1uLSSWDxDuMiZxiPhwunLrn9LOSVItWj4bLYsLN3Dg== dependencies: abab "^2.0.5" - acorn "^8.0.5" + acorn "^8.2.4" acorn-globals "^6.0.0" cssom "^0.4.4" cssstyle "^2.3.0" @@ -1006,12 +922,13 @@ jsdom@16: decimal.js "^10.2.1" domexception "^2.0.1" escodegen "^2.0.0" + form-data "^3.0.0" html-encoding-sniffer "^2.0.1" - is-potential-custom-element-name "^1.0.0" + http-proxy-agent "^4.0.1" + https-proxy-agent "^5.0.0" + is-potential-custom-element-name "^1.0.1" nwsapi "^2.2.0" parse5 "6.0.1" - request "^2.88.2" - request-promise-native "^1.0.9" saxes "^5.0.1" symbol-tree "^3.2.4" tough-cookie "^4.0.0" @@ -1020,8 +937,8 @@ jsdom@16: webidl-conversions "^6.1.0" whatwg-encoding "^1.0.5" whatwg-mimetype "^2.3.0" - whatwg-url "^8.0.0" - ws "^7.4.4" + whatwg-url "^8.5.0" + ws "^7.4.5" xml-name-validator "^3.0.0" json-schema-traverse@^0.4.1: @@ -1034,31 +951,11 @@ json-schema-traverse@^1.0.0: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= - json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= - -jsprim@^1.2.2: - version "1.4.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" - integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.2.3" - verror "1.10.0" - levn@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" @@ -1075,16 +972,40 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -lodash.sortby@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" - integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg= +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8= + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lodash.truncate@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" + integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= -lodash@^4.17.19, lodash@^4.17.20: +lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== +log-symbols@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== + dependencies: + chalk "^4.0.0" + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -1097,83 +1018,86 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -mime-db@1.46.0: - version "1.46.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.46.0.tgz#6267748a7f799594de3cbc8cde91def349661cee" - integrity sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ== +mime-db@1.48.0: + version "1.48.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d" + integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ== -mime-types@^2.1.12, mime-types@~2.1.19: - version "2.1.29" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.29.tgz#1d4ab77da64b91f5f72489df29236563754bb1b2" - integrity sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ== +mime-types@^2.1.12: + version "2.1.31" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b" + integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg== dependencies: - mime-db "1.46.0" + mime-db "1.48.0" -minimatch@^3.0.4: +minimatch@3.0.4, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" -minimist@~1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== +mocha@8: + version "8.4.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.4.0.tgz#677be88bf15980a3cae03a73e10a0fc3997f0cff" + integrity sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.1" + debug "4.3.1" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.1.6" + growl "1.10.5" + he "1.2.0" + js-yaml "4.0.0" + log-symbols "4.0.0" + minimatch "3.0.4" + ms "2.1.3" + nanoid "3.1.20" + serialize-javascript "5.0.1" + strip-json-comments "3.1.1" + supports-color "8.1.1" + which "2.0.2" + wide-align "1.1.3" + workerpool "6.1.0" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nanoid@3.1.20: + version "3.1.20" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788" + integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + nwsapi@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.0.tgz#204879a9e3d068ff2a55139c2c772780681a38b7" integrity sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ== -oauth-sign@~0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" - integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== - -object-inspect@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.9.0.tgz#c90521d74e1127b67266ded3394ad6116986533a" - integrity sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw== - -object-inspect@~1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" - integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== - -object-is@^1.0.1: - version "1.1.5" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" - integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -object-keys@^1.0.12, object-keys@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" - integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== - -object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== - dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" - object-keys "^1.1.1" - once@^1.3.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -1205,6 +1129,20 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -1217,6 +1155,11 @@ parse5@6.0.1: resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1228,19 +1171,14 @@ path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== - -performance-now@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== -picomatch@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" - integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2: + version "2.3.0" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" + integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== prelude-ls@^1.2.1: version "1.2.1" @@ -1257,7 +1195,7 @@ progress@^2.0.0: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -psl@^1.1.28, psl@^1.1.33: +psl@^1.1.33: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== @@ -1267,11 +1205,6 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" @@ -1279,60 +1212,22 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" -regexp.prototype.flags@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz#7ef352ae8d159e758c0eadca6f8fcb4eef07be26" - integrity sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA== +readdirp@~3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" + integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" + picomatch "^2.2.1" regexpp@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== -request-promise-core@1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.4.tgz#3eedd4223208d419867b78ce815167d10593a22f" - integrity sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw== - dependencies: - lodash "^4.17.19" - -request-promise-native@^1.0.9: - version "1.0.9" - resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.9.tgz#e407120526a5efdc9a39b28a5679bf47b9d9dc28" - integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== - dependencies: - request-promise-core "1.1.4" - stealthy-require "^1.1.1" - tough-cookie "^2.3.3" - -request@^2.88.2: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= require-from-string@^2.0.2: version "2.0.2" @@ -1352,20 +1247,6 @@ resolve@^1.19.0: is-core-module "^2.2.0" path-parse "^1.0.6" -resolve@~1.17.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== - dependencies: - path-parse "^1.0.6" - -resumer@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" - integrity sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k= - dependencies: - through "~2.3.4" - rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" @@ -1384,18 +1265,18 @@ rollup-plugin-terser@7: terser "^5.0.0" rollup@2: - version "2.41.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.41.0.tgz#b2a398bbabbf227738dedaef099e494aed468982" - integrity sha512-Gk76XHTggulWPH95q8V62bw6uqDH6UGvbD6LOa3QUyhuMF3eOuaeDHR7SLm1T9faitkpNrqzUAVYx47klcMnlA== + version "2.50.6" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.50.6.tgz#24e2211caf9031081656e98a5e5e94d3b5e786e2" + integrity sha512-6c5CJPLVgo0iNaZWWliNu1Kl43tjP9LZcp6D/tkf2eLH2a9/WeHxg9vfTFl8QV/2SOyaJX37CEm9XuGM0rviUg== optionalDependencies: fsevents "~2.3.1" -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2: +safe-buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: +"safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -1408,12 +1289,19 @@ saxes@^5.0.1: xmlchars "^2.2.0" semver@^7.2.1: - version "7.3.4" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" - integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== + version "7.3.5" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" + integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== dependencies: lru-cache "^6.0.0" +serialize-javascript@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" + integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== + dependencies: + randombytes "^2.1.0" + serialize-javascript@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" @@ -1465,27 +1353,15 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - bcrypt-pbkdf "^1.0.0" - dashdash "^1.12.0" - ecc-jsbn "~0.1.1" - getpass "^0.1.1" - jsbn "~0.1.0" - safer-buffer "^2.0.2" - tweetnacl "~0.14.0" - -stealthy-require@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" - integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks= +"string-width@^1.0.2 || 2": + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" -string-width@^4.2.0: +string-width@^4.1.0, string-width@^4.2.0: version "4.2.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== @@ -1494,30 +1370,12 @@ string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string.prototype.trim@~1.2.1: - version "1.2.4" - resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.4.tgz#6014689baf5efaf106ad031a5fa45157666ed1bd" - integrity sha512-hWCk/iqf7lp0/AgTF7/ddO1IWtSNPASjlzCicV5irAVdE1grjsneK26YG6xACMBEdCvO8fUST0UzDMh/2Qy+9Q== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.18.0-next.2" - -string.prototype.trimend@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" - integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - -string.prototype.trimstart@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" - integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" + ansi-regex "^3.0.0" strip-ansi@^6.0.0: version "6.0.0" @@ -1526,11 +1384,18 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -1550,46 +1415,22 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table@^6.0.4: - version "6.0.7" - resolved "https://registry.yarnpkg.com/table/-/table-6.0.7.tgz#e45897ffbcc1bcf9e8a87bf420f2c9e5a7a52a34" - integrity sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g== +table@^6.0.9: + version "6.7.1" + resolved "https://registry.yarnpkg.com/table/-/table-6.7.1.tgz#ee05592b7143831a8c94f3cee6aae4c1ccef33e2" + integrity sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg== dependencies: - ajv "^7.0.2" - lodash "^4.17.20" + ajv "^8.0.1" + lodash.clonedeep "^4.5.0" + lodash.truncate "^4.4.2" slice-ansi "^4.0.0" string-width "^4.2.0" - -tape-await@0.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/tape-await/-/tape-await-0.1.2.tgz#41f99110a2bc4728732d8bc058278b2fbf3c0bec" - integrity sha512-Gt1bXilp9uRTVj+DecLDs37tP1XwGXfFzWVqQEfW7foO9TNacy+aN5TdT0Kv6LI5t/9l3iOE4nX2hr2SQ4+OSg== - -tape@4: - version "4.13.3" - resolved "https://registry.yarnpkg.com/tape/-/tape-4.13.3.tgz#51b3d91c83668c7a45b1a594b607dee0a0b46278" - integrity sha512-0/Y20PwRIUkQcTCSi4AASs+OANZZwqPKaipGCEwp10dQMipVvSZwUUCi01Y/OklIGyHKFhIcjock+DKnBfLAFw== - dependencies: - deep-equal "~1.1.1" - defined "~1.0.0" - dotignore "~0.1.2" - for-each "~0.3.3" - function-bind "~1.1.1" - glob "~7.1.6" - has "~1.0.3" - inherits "~2.0.4" - is-regex "~1.0.5" - minimist "~1.2.5" - object-inspect "~1.7.0" - resolve "~1.17.0" - resumer "~0.0.0" - string.prototype.trim "~1.2.1" - through "~2.3.8" + strip-ansi "^6.0.0" terser@^5.0.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.6.0.tgz#138cdf21c5e3100b1b3ddfddf720962f88badcd2" - integrity sha512-vyqLMoqadC1uR0vywqOZzriDYzgEkNJFK4q9GeyOBHIbiECHiWLKcWfbQWAUaPfxkjDhapSlZB9f7fkMrvkVjA== + version "5.7.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693" + integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g== dependencies: commander "^2.20.0" source-map "~0.7.2" @@ -1600,18 +1441,12 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= -through@~2.3.4, through@~2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= - -tough-cookie@^2.3.3, tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - psl "^1.1.28" - punycode "^2.1.1" + is-number "^7.0.0" tough-cookie@^4.0.0: version "4.0.0" @@ -1623,24 +1458,12 @@ tough-cookie@^4.0.0: universalify "^0.1.2" tr46@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.0.2.tgz#03273586def1595ae08fedb38d7733cee91d2479" - integrity sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg== + version "2.1.0" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-2.1.0.tgz#fa87aa81ca5d5941da8cbf1f9b749dc969a4e240" + integrity sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw== dependencies: punycode "^2.1.1" -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= - type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" @@ -1655,20 +1478,10 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" -type-fest@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" - integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== - -unbox-primitive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.0.tgz#eeacbc4affa28e9b3d36b5eaeccc50b3251b1d3f" - integrity sha512-P/51NX+JXyxK/aigg1/ZgyccdAxm5K1+n8+tvqSntjOivPt19gvm1VC49RWYetsiub8WViUchdxl/KWHHB0kzA== - dependencies: - function-bind "^1.1.1" - has-bigints "^1.0.0" - has-symbols "^1.0.0" - which-boxed-primitive "^1.0.1" +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== universalify@^0.1.2: version "0.1.2" @@ -1682,25 +1495,11 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -uuid@^3.3.2: - version "3.4.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" - integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - v8-compile-cache@^2.0.3: version "2.3.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== -verror@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= - dependencies: - assert-plus "^1.0.0" - core-util-is "1.0.2" - extsprintf "^1.2.0" - w3c-hr-time@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" @@ -1737,47 +1536,57 @@ whatwg-mimetype@^2.3.0: resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g== -whatwg-url@^8.0.0: - version "8.4.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.4.0.tgz#50fb9615b05469591d2b2bd6dfaed2942ed72837" - integrity sha512-vwTUFf6V4zhcPkWp/4CQPr1TW9Ml6SF4lVyaIMBdJw5i6qUUJ1QWM4Z6YYVkfka0OUIzVo/0aNtGVGk256IKWw== +whatwg-url@^8.0.0, whatwg-url@^8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.5.0.tgz#7752b8464fc0903fec89aa9846fc9efe07351fd3" + integrity sha512-fy+R77xWv0AiqfLl4nuGUlQ3/6b5uNfQ4WAbGQVMYshCTCCPK9psC1nWh3XHuxGVCtlcDDQPQW1csmmIQo+fwg== dependencies: - lodash.sortby "^4.7.0" + lodash "^4.7.0" tr46 "^2.0.2" webidl-conversions "^6.1.0" -which-boxed-primitive@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" - integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== - dependencies: - is-bigint "^1.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" - is-symbol "^1.0.3" - -which@^2.0.1: +which@2.0.2, which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" +wide-align@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + word-wrap@^1.2.3, word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== +workerpool@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.0.tgz#a8e038b4c94569596852de7a8ea4228eefdeb37b" + integrity sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -ws@^7.4.4: - version "7.4.4" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59" - integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw== +ws@^7.4.5: + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== xml-name-validator@^3.0.0: version "3.0.0" @@ -1789,7 +1598,50 @@ xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.7" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a" + integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==