From 0aa367747e7fd7eefff582b91ec5e9ebbfde8a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Fri, 4 Jun 2021 21:28:10 +0200 Subject: [PATCH] Adopt type=module (#179) * Adopt type=module follow changes in d3-format: * type=module * add exports * remove zip * license: ISC * update dependencies * es6 rather than no-undef * use the "falls through" comment to make eslint's "no-fallthrough" rule happy * remove Sublime project * add eslint.json * stricter eslint * cleaner imports * update dependencies * Update README Co-authored-by: Mike Bostock --- .eslintrc.json | 7 +- .github/eslint.json | 18 + .github/workflows/node.js.yml | 30 ++ LICENSE | 40 +- README.md | 21 +- d3-shape.sublime-project | 17 - package.json | 47 +- src/curve/basis.js | 4 +- src/curve/basisOpen.js | 2 +- src/curve/bump.js | 2 +- src/curve/cardinal.js | 2 +- src/curve/cardinalOpen.js | 2 +- src/curve/catmullRom.js | 2 +- src/curve/catmullRomOpen.js | 2 +- src/curve/linear.js | 2 +- src/curve/step.js | 2 +- test/.eslintrc.json | 11 + test/arc-test.js | 525 +++++++++--------- test/area-test.js | 397 +++++++------- test/areaRadial-test.js | 144 +++-- test/asserts.js | 44 ++ test/curve/basis-test.js | 33 +- test/curve/basisClosed-test.js | 24 +- test/curve/basisOpen-test.js | 41 +- test/curve/bumpX-test.js | 33 +- test/curve/bumpY-test.js | 33 +- test/curve/bundle-test.js | 25 +- test/curve/cardinal-test.js | 75 ++- test/curve/cardinalClosed-test.js | 75 ++- test/curve/cardinalOpen-test.js | 75 ++- test/curve/catmullRom-test.js | 82 ++- test/curve/catmullRomClosed-test.js | 73 ++- test/curve/catmullRomOpen-test.js | 82 ++- test/curve/linear-test.js | 33 +- test/curve/linearClosed-test.js | 20 +- test/curve/monotoneX-test.js | 81 ++- test/curve/monotoneY-test.js | 81 ++- test/curve/natural-test.js | 37 +- test/curve/step-test.js | 33 +- test/curve/stepAfter-test.js | 33 +- test/curve/stepBefore-test.js | 33 +- test/inDelta.js | 10 - test/line-test.js | 101 ++-- test/lineRadial-test.js | 24 +- test/offset/diverging-test.js | 62 +-- test/offset/expand-test.js | 35 +- test/offset/none-test.js | 35 +- test/offset/silhouette-test.js | 35 +- test/offset/wiggle-test.js | 39 +- test/order/appearance-test.js | 14 +- test/order/ascending-test.js | 14 +- test/order/descending-test.js | 14 +- test/order/insideOut-test.js | 14 +- test/order/none-test.js | 9 +- test/order/reverse-test.js | 9 +- test/pathEqual.js | 22 - test/pie-test.js | 202 ++++--- test/polygonContext.js | 16 +- test/stack-test.js | 142 +++-- test/symbol-test.js | 204 ++++--- test/symbols-test.js | 23 +- yarn.lock | 808 +++++++++++++++------------- 62 files changed, 2015 insertions(+), 2140 deletions(-) create mode 100644 .github/eslint.json create mode 100644 .github/workflows/node.js.yml delete mode 100644 d3-shape.sublime-project create mode 100644 test/.eslintrc.json create mode 100644 test/asserts.js delete mode 100644 test/inDelta.js delete mode 100644 test/pathEqual.js diff --git a/.eslintrc.json b/.eslintrc.json index 867dbe9..7e80b00 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,12 +5,9 @@ "ecmaVersion": 8 }, "env": { - "es6": true, - "node": true, - "browser": true + "es6": true }, "rules": { - "no-cond-assign": 0, - "no-fallthrough": 0 + "no-cond-assign": 0 } } diff --git a/.github/eslint.json b/.github/eslint.json new file mode 100644 index 0000000..c280fdb --- /dev/null +++ b/.github/eslint.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "eslint-compact", + "pattern": [ + { + "regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5, + "code": 6 + } + ] + } + ] +} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..7e5ee59 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,30 @@ +# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: yarn --frozen-lockfile + - run: | + echo ::add-matcher::.github/eslint.json + yarn run eslint src test --format=compact + - run: yarn test diff --git a/LICENSE b/LICENSE index 4f0b022..b014515 100644 --- a/LICENSE +++ b/LICENSE @@ -1,27 +1,13 @@ -Copyright 2010-2015 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 98f630d..1cabc2d 100644 --- a/README.md +++ b/README.md @@ -26,18 +26,29 @@ For more, read [Introducing d3-shape](https://medium.com/@mbostock/introducing-d ## Installing -If you use NPM, `npm install d3-shape`. Otherwise, download the [latest release](https://github.com/d3/d3-shape/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-shape.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-shape`. You can also download the [latest release on GitHub](https://github.com/d3/d3-shape/releases/latest). For vanilla HTML in modern browsers, import d3-shape from Skypack: ```html - - - ``` +For legacy environments, you can load d3-shape’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported: + +```html + + + +``` ## API Reference diff --git a/d3-shape.sublime-project b/d3-shape.sublime-project deleted file mode 100644 index 772dfa5..0000000 --- a/d3-shape.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 b333424..5eb82a5 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,11 @@ "name": "d3-shape", "version": "2.1.0", "description": "Graphical primitives for visualization, such as lines and areas.", + "homepage": "https://d3js.org/d3-shape/", + "repository": { + "type": "git", + "url": "https://github.com/d3/d3-shape.git" + }, "keywords": [ "d3", "d3-module", @@ -10,39 +15,41 @@ "canvas", "svg" ], - "homepage": "https://d3js.org/d3-shape/", - "license": "BSD-3-Clause", + "license": "ISC", "author": { "name": "Mike Bostock", "url": "http://bost.ocks.org/mike" }, - "main": "dist/d3-shape.js", - "unpkg": "dist/d3-shape.min.js", - "jsdelivr": "dist/d3-shape.min.js", - "module": "src/index.js", - "repository": { - "type": "git", - "url": "https://github.com/d3/d3-shape.git" - }, + "type": "module", "files": [ "dist/**/*.js", "src/**/*.js" ], - "scripts": { - "pretest": "rollup -c", - "test": "tape 'test/**/*-test.js' && eslint src", - "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-shape.min.js", + "unpkg": "dist/d3-shape.min.js", + "exports": { + "umd": "./dist/d3-shape.min.js", + "default": "./src/index.js" }, + "sideEffects": false, "dependencies": { - "d3-path": "1 - 2" + "d3-path": "1 - 3" }, - "sideEffects": false, "devDependencies": { - "d3-polygon": "1 - 2", + "d3-polygon": "1 - 3", "eslint": "7", + "mocha": "8", "rollup": "2", - "rollup-plugin-terser": "7", - "tape": "4" + "rollup-plugin-terser": "7" + }, + "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/src/curve/basis.js b/src/curve/basis.js index b186bed..e6b1ea3 100644 --- a/src/curve/basis.js +++ b/src/curve/basis.js @@ -27,7 +27,7 @@ Basis.prototype = { }, lineEnd: function() { switch (this._point) { - case 3: point(this, this._x1, this._y1); // proceed + case 3: point(this, this._x1, this._y1); // falls through case 2: this._context.lineTo(this._x1, this._y1); break; } if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); @@ -38,7 +38,7 @@ Basis.prototype = { switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; break; - case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // proceed + case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through default: point(this, x, y); break; } this._x0 = this._x1, this._x1 = x; diff --git a/src/curve/basisOpen.js b/src/curve/basisOpen.js index 4f2e5b1..4ef5343 100644 --- a/src/curve/basisOpen.js +++ b/src/curve/basisOpen.js @@ -26,7 +26,7 @@ BasisOpen.prototype = { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; - case 3: this._point = 4; // proceed + case 3: this._point = 4; // falls through default: point(this, x, y); break; } this._x0 = this._x1, this._x1 = x; diff --git a/src/curve/bump.js b/src/curve/bump.js index b1d6327..f862eac 100644 --- a/src/curve/bump.js +++ b/src/curve/bump.js @@ -25,7 +25,7 @@ class Bump { else this._context.moveTo(x, y); break; } - case 1: this._point = 2; // proceed + case 1: this._point = 2; // falls through default: { if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); diff --git a/src/curve/cardinal.js b/src/curve/cardinal.js index 3ab1070..7e64c14 100644 --- a/src/curve/cardinal.js +++ b/src/curve/cardinal.js @@ -39,7 +39,7 @@ Cardinal.prototype = { switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; this._x1 = x, this._y1 = y; break; - case 2: this._point = 3; // proceed + case 2: this._point = 3; // falls through default: point(this, x, y); break; } this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; diff --git a/src/curve/cardinalOpen.js b/src/curve/cardinalOpen.js index e736841..f73ac8b 100644 --- a/src/curve/cardinalOpen.js +++ b/src/curve/cardinalOpen.js @@ -27,7 +27,7 @@ CardinalOpen.prototype = { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; - case 3: this._point = 4; // proceed + case 3: this._point = 4; // falls through default: point(this, x, y); break; } this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; diff --git a/src/curve/catmullRom.js b/src/curve/catmullRom.js index 643d10f..3a4b1a7 100644 --- a/src/curve/catmullRom.js +++ b/src/curve/catmullRom.js @@ -63,7 +63,7 @@ CatmullRom.prototype = { switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; break; - case 2: this._point = 3; // proceed + case 2: this._point = 3; // falls through default: point(this, x, y); break; } diff --git a/src/curve/catmullRomOpen.js b/src/curve/catmullRomOpen.js index 7e4c5ca..a372a70 100644 --- a/src/curve/catmullRomOpen.js +++ b/src/curve/catmullRomOpen.js @@ -37,7 +37,7 @@ CatmullRomOpen.prototype = { case 0: this._point = 1; break; case 1: this._point = 2; break; case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; - case 3: this._point = 4; // proceed + case 3: this._point = 4; // falls through default: point(this, x, y); break; } diff --git a/src/curve/linear.js b/src/curve/linear.js index 6245493..68e169a 100644 --- a/src/curve/linear.js +++ b/src/curve/linear.js @@ -20,7 +20,7 @@ Linear.prototype = { x = +x, y = +y; switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; - case 1: this._point = 2; // proceed + case 1: this._point = 2; // falls through default: this._context.lineTo(x, y); break; } } diff --git a/src/curve/step.js b/src/curve/step.js index e9fb78f..6f6aa05 100644 --- a/src/curve/step.js +++ b/src/curve/step.js @@ -23,7 +23,7 @@ Step.prototype = { x = +x, y = +y; switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; - case 1: this._point = 2; // proceed + case 1: this._point = 2; // falls through default: { if (this._t <= 0) { this._context.lineTo(this._x, y); diff --git a/test/.eslintrc.json b/test/.eslintrc.json new file mode 100644 index 0000000..39d0931 --- /dev/null +++ b/test/.eslintrc.json @@ -0,0 +1,11 @@ +{ + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 8 + }, + "env": { + "es6": true, + "mocha": true + } +} diff --git a/test/arc-test.js b/test/arc-test.js index aee6306..aa2df56 100644 --- a/test/arc-test.js +++ b/test/arc-test.js @@ -1,396 +1,357 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {arc} from "../src/index.js"; +import {assertPathEqual} from "./asserts.js"; -require("./pathEqual"); - -tape("arc().innerRadius(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().innerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().innerRadius(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().innerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().outerRadius(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().outerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().outerRadius(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().outerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().cornerRadius(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().outerRadius(100).cornerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().cornerRadius(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().outerRadius(100).cornerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().startAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().startAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().endAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().endAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().padAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().outerRadius(100).startAngle(Math.PI / 2).padAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().padAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().outerRadius(100).startAngle(Math.PI / 2).padAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().padRadius(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().outerRadius(100).startAngle(Math.PI / 2).padAngle(0.1).padRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().padRadius(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().outerRadius(100).startAngle(Math.PI / 2).padAngle(0.1).padRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().centroid(…) computes the midpoint of the center line of the arc", function(test) { - var a = shape.arc(), round = function(x) { return Math.round(x * 1e6) / 1e6; }; - test.deepEqual(a.centroid({innerRadius: 0, outerRadius: 100, startAngle: 0, endAngle: Math.PI}).map(round), [50, 0]); - test.deepEqual(a.centroid({innerRadius: 0, outerRadius: 100, startAngle: 0, endAngle: Math.PI / 2}).map(round), [35.355339, -35.355339]); - test.deepEqual(a.centroid({innerRadius: 50, outerRadius: 100, startAngle: 0, endAngle: -Math.PI}).map(round), [-75, -0]); - test.deepEqual(a.centroid({innerRadius: 50, outerRadius: 100, startAngle: 0, endAngle: -Math.PI / 2}).map(round), [-53.033009, -53.033009]); - test.end(); +it("arc().centroid(…) computes the midpoint of the center line of the arc", () => { + const a = arc(), round = function(x) { return Math.round(x * 1e6) / 1e6; }; + assert.deepStrictEqual(a.centroid({innerRadius: 0, outerRadius: 100, startAngle: 0, endAngle: Math.PI}).map(round), [50, 0]); + assert.deepStrictEqual(a.centroid({innerRadius: 0, outerRadius: 100, startAngle: 0, endAngle: Math.PI / 2}).map(round), [35.355339, -35.355339]); + assert.deepStrictEqual(a.centroid({innerRadius: 50, outerRadius: 100, startAngle: 0, endAngle: -Math.PI}).map(round), [-75, -0]); + assert.deepStrictEqual(a.centroid({innerRadius: 50, outerRadius: 100, startAngle: 0, endAngle: -Math.PI / 2}).map(round), [-53.033009, -53.033009]); }); -tape("arc().innerRadius(f).centroid(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().innerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().innerRadius(f).centroid(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().innerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().outerRadius(f).centroid(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().outerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().outerRadius(f).centroid(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().outerRadius(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().startAngle(f).centroid(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().startAngle(f).centroid(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().endAngle(f).centroid(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.arc().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("arc().endAngle(f).centroid(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + arc().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).centroid.apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("arc().innerRadius(0).outerRadius(0) renders a point", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(0); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,0Z"); - test.pathEqual(a.startAngle(0).endAngle(0)(), "M0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(0) renders a point", () => { + const a = arc().innerRadius(0).outerRadius(0); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,0Z"); + assertPathEqual(a.startAngle(0).endAngle(0)(), "M0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a clockwise circle if r > 0 and θ₁ - θ₀ ≥ τ", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); - test.pathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a clockwise circle if r > 0 and θ₁ - θ₀ ≥ τ", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); + assertPathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders an anticlockwise circle if r > 0 and θ₀ - θ₁ ≥ τ", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); - test.pathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders an anticlockwise circle if r > 0 and θ₀ - θ₁ ≥ τ", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); + assertPathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); }); // Note: The outer ring starts and ends at θ₀, but the inner ring starts and ends at θ₁. // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a clockwise annulus if r₀ > 0, r₁ > 0 and θ₀ - θ₁ ≥ τ", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); - test.pathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a clockwise annulus if r₀ > 0, r₁ > 0 and θ₀ - θ₁ ≥ τ", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); + assertPathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); }); // Note: The outer ring starts and ends at θ₀, but the inner ring starts and ends at θ₁. // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders an anticlockwise annulus if r₀ > 0, r₁ > 0 and θ₁ - θ₀ ≥ τ", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); - test.pathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders an anticlockwise annulus if r₀ > 0, r₁ > 0 and θ₁ - θ₀ ≥ τ", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); + assertPathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a small clockwise sector if r > 0 and π > θ₁ - θ₀ ≥ 0", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L0,0Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L0,0Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,0,1,-100,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a small clockwise sector if r > 0 and π > θ₁ - θ₀ ≥ 0", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L0,0Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L0,0Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,0,1,-100,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a small anticlockwise sector if r > 0 and π > θ₀ - θ₁ ≥ 0", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L0,0Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L0,0Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,0,0,100,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a small anticlockwise sector if r > 0 and π > θ₀ - θ₁ ≥ 0", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L0,0Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L0,0Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,0,0,100,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a large clockwise sector if r > 0 and τ > θ₁ - θ₀ ≥ π", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L0,0Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L0,0Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,1,1,100,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a large clockwise sector if r > 0 and τ > θ₁ - θ₀ ≥ π", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L0,0Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L0,0Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,1,1,100,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a large anticlockwise sector if r > 0 and τ > θ₀ - θ₁ ≥ π", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L0,0Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L0,0Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,1,0,-100,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁) renders a large anticlockwise sector if r > 0 and τ > θ₀ - θ₁ ≥ π", () => { + const a = arc().innerRadius(0).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L0,0Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L0,0Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,1,0,-100,0L0,0Z"); }); // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a small clockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₁ - θ₀ ≥ 0", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L50,0A50,50,0,0,0,0,-50Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L50,0A50,50,0,0,0,0,-50Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,0,1,-100,0L-50,0A50,50,0,0,0,0,50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a small clockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₁ - θ₀ ≥ 0", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L50,0A50,50,0,0,0,0,-50Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-100A100,100,0,0,1,100,0L50,0A50,50,0,0,0,0,-50Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,0,1,-100,0L-50,0A50,50,0,0,0,0,50Z"); }); // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a small anticlockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₀ - θ₁ ≥ 0", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L-50,0A50,50,0,0,1,0,-50Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L-50,0A50,50,0,0,1,0,-50Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,0,0,100,0L50,0A50,50,0,0,1,0,50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a small anticlockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₀ - θ₁ ≥ 0", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L-50,0A50,50,0,0,1,0,-50Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-100A100,100,0,0,0,-100,0L-50,0A50,50,0,0,1,0,-50Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,0,0,100,0L50,0A50,50,0,0,1,0,50Z"); }); // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a large clockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₁ - θ₀ ≥ π", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L-50,0A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L-50,0A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,1,1,100,0L50,0A50,50,0,1,0,0,50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a large clockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₁ - θ₀ ≥ π", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L-50,0A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-100A100,100,0,1,1,-100,0L-50,0A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,100A100,100,0,1,1,100,0L50,0A50,50,0,1,0,0,50Z"); }); // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a large anticlockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₀ - θ₁ ≥ π", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L50,0A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L50,0A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,1,0,-100,0L-50,0A50,50,0,1,1,0,50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁) renders a large anticlockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₀ - θ₁ ≥ π", () => { + const a = arc().innerRadius(50).outerRadius(100); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L50,0A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-100A100,100,0,1,0,100,0L50,0A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,100A100,100,0,1,0,-100,0L-50,0A50,50,0,1,1,0,50Z"); }); -tape("arc().innerRadius(0).outerRadius(0).cornerRadius(r) renders a point", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(0).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,0Z"); - test.pathEqual(a.startAngle(0).endAngle(0)(), "M0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(0).cornerRadius(r) renders a point", () => { + const a = arc().innerRadius(0).outerRadius(0).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,0Z"); + assertPathEqual(a.startAngle(0).endAngle(0)(), "M0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a clockwise circle if r > 0 and θ₁ - θ₀ ≥ τ", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); - test.pathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a clockwise circle if r > 0 and θ₁ - θ₀ ≥ τ", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); + assertPathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders an anticlockwise circle if r > 0 and θ₀ - θ₁ ≥ τ", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); - test.pathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders an anticlockwise circle if r > 0 and θ₀ - θ₁ ≥ τ", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); + assertPathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100Z"); }); // Note: The outer ring starts and ends at θ₀, but the inner ring starts and ends at θ₁. // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a clockwise annulus if r₀ > 0, r₁ > 0 and θ₀ - θ₁ ≥ τ", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); - test.pathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a clockwise annulus if r₀ > 0, r₁ > 0 and θ₀ - θ₁ ≥ τ", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(2 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,50A50,50,0,1,0,0,-50A50,50,0,1,0,0,50Z"); + assertPathEqual(a.startAngle(-3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,1,0,-100A100,100,0,1,1,0,100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); }); // Note: The outer ring starts and ends at θ₀, but the inner ring starts and ends at θ₁. // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders an anticlockwise annulus if r₀ > 0, r₁ > 0 and θ₁ - θ₀ ≥ τ", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); - test.pathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders an anticlockwise annulus if r₀ > 0, r₁ > 0 and θ₁ - θ₀ ≥ τ", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-2 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(0)(), "M0,-100A100,100,0,1,0,0,100A100,100,0,1,0,0,-100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,50A50,50,0,1,1,0,-50A50,50,0,1,1,0,50Z"); + assertPathEqual(a.startAngle(3 * Math.PI).endAngle(0)(), "M0,100A100,100,0,1,0,0,-100A100,100,0,1,0,0,100M0,-50A50,50,0,1,1,0,50A50,50,0,1,1,0,-50Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small clockwise sector if r > 0 and π > θ₁ - θ₀ ≥ 0", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,0,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small clockwise sector if r > 0 and π > θ₁ - θ₀ ≥ 0", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,0,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small anticlockwise sector if r > 0 and π > θ₀ - θ₁ ≥ 0", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,0,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small anticlockwise sector if r > 0 and π > θ₀ - θ₁ ≥ 0", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,0,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large clockwise sector if r > 0 and τ > θ₁ - θ₀ ≥ π", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,1,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large clockwise sector if r > 0 and τ > θ₁ - θ₀ ≥ π", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,1,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large anticlockwise sector if r > 0 and τ > θ₀ - θ₁ ≥ π", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,1,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large anticlockwise sector if r > 0 and τ > θ₀ - θ₁ ≥ π", () => { + const a = arc().innerRadius(0).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L0,0Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,1,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L0,0Z"); }); // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small clockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₁ - θ₀ ≥ 0", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,0,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,0,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,0,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,0,0,-4.545455,49.792960A5,5,0,0,1,0,54.772256Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small clockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₁ - θ₀ ≥ 0", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,0,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,0,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,0,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,0,0,-4.545455,49.792960A5,5,0,0,1,0,54.772256Z"); }); // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small anticlockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₀ - θ₁ ≥ 0", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,0,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,0,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,0,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,0,1,4.545455,49.792960A5,5,0,0,0,0,54.772256Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a small anticlockwise annular sector if r₀ > 0, r₁ > 0 and π > θ₀ - θ₁ ≥ 0", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,0,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-5 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,0,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,0,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,0,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,0,1,4.545455,49.792960A5,5,0,0,0,0,54.772256Z"); }); // Note: The outer ring is clockwise, but the inner ring is anticlockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large clockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₁ - θ₀ ≥ π", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,1,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); - test.pathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,1,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); - test.pathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,1,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,1,0,-4.545455,49.792960A5,5,0,0,1,0,54.772256Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large clockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₁ - θ₀ ≥ π", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,1,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); + assertPathEqual(a.startAngle(2 * Math.PI).endAngle(7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,1,1,-99.861400,5.263158A5,5,0,0,1,-94.868330,0L-54.772256,0A5,5,0,0,1,-49.792960,4.545455A50,50,0,1,0,4.545455,-49.792960A5,5,0,0,1,0,-54.772256Z"); + assertPathEqual(a.startAngle(-Math.PI).endAngle(Math.PI / 2)(), "M0,94.868330A5,5,0,0,1,-5.263158,99.861400A100,100,0,1,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L54.772256,0A5,5,0,0,1,49.792960,-4.545455A50,50,0,1,0,-4.545455,49.792960A5,5,0,0,1,0,54.772256Z"); }); // Note: The outer ring is anticlockwise, but the inner ring is clockwise. -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large anticlockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₀ - θ₁ ≥ π", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).cornerRadius(5); - test.pathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,1,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); - test.pathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,1,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); - test.pathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,1,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,1,1,4.545455,49.792960A5,5,0,0,0,0,54.772256Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).cornerRadius(rᵧ) renders a large anticlockwise annular sector if r₀ > 0, r₁ > 0 and τ > θ₀ - θ₁ ≥ π", () => { + const a = arc().innerRadius(50).outerRadius(100).cornerRadius(5); + assertPathEqual(a.startAngle(0).endAngle(-3 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,1,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); + assertPathEqual(a.startAngle(-2 * Math.PI).endAngle(-7 * Math.PI / 2)(), "M0,-94.868330A5,5,0,0,0,-5.263158,-99.861400A100,100,0,1,0,99.861400,5.263158A5,5,0,0,0,94.868330,0L54.772256,0A5,5,0,0,0,49.792960,4.545455A50,50,0,1,1,-4.545455,-49.792960A5,5,0,0,0,0,-54.772256Z"); + assertPathEqual(a.startAngle(Math.PI).endAngle(-Math.PI / 2)(), "M0,94.868330A5,5,0,0,0,5.263158,99.861400A100,100,0,1,0,-99.861400,-5.263158A5,5,0,0,0,-94.868330,0L-54.772256,0A5,5,0,0,0,-49.792960,-4.545455A50,50,0,1,1,4.545455,49.792960A5,5,0,0,0,0,54.772256Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).cornerRadius(rᵧ) restricts rᵧ to |r₁ - r₀| / 2", function(test) { - var a = shape.arc().cornerRadius(Infinity).startAngle(0).endAngle(Math.PI / 2); - test.pathEqual(a.innerRadius(90).outerRadius(100)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L94.868330,0A5,5,0,0,1,89.875260,-4.736842A90,90,0,0,0,4.736842,-89.875260A5,5,0,0,1,0,-94.868330Z"); - test.pathEqual(a.innerRadius(100).outerRadius(90)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L94.868330,0A5,5,0,0,1,89.875260,-4.736842A90,90,0,0,0,4.736842,-89.875260A5,5,0,0,1,0,-94.868330Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).cornerRadius(rᵧ) restricts rᵧ to |r₁ - r₀| / 2", () => { + const a = arc().cornerRadius(Infinity).startAngle(0).endAngle(Math.PI / 2); + assertPathEqual(a.innerRadius(90).outerRadius(100)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L94.868330,0A5,5,0,0,1,89.875260,-4.736842A90,90,0,0,0,4.736842,-89.875260A5,5,0,0,1,0,-94.868330Z"); + assertPathEqual(a.innerRadius(100).outerRadius(90)(), "M0,-94.868330A5,5,0,0,1,5.263158,-99.861400A100,100,0,0,1,99.861400,-5.263158A5,5,0,0,1,94.868330,0L94.868330,0A5,5,0,0,1,89.875260,-4.736842A90,90,0,0,0,4.736842,-89.875260A5,5,0,0,1,0,-94.868330Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).cornerRadius(rᵧ) merges adjacent corners when rᵧ is relatively large", function(test) { - var a = shape.arc().cornerRadius(Infinity).startAngle(0).endAngle(Math.PI / 2); - test.pathEqual(a.innerRadius(10).outerRadius(100)(), "M0,-41.421356A41.421356,41.421356,0,1,1,41.421356,0L24.142136,0A24.142136,24.142136,0,0,1,0,-24.142136Z"); - test.pathEqual(a.innerRadius(100).outerRadius(10)(), "M0,-41.421356A41.421356,41.421356,0,1,1,41.421356,0L24.142136,0A24.142136,24.142136,0,0,1,0,-24.142136Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).cornerRadius(rᵧ) merges adjacent corners when rᵧ is relatively large", () => { + const a = arc().cornerRadius(Infinity).startAngle(0).endAngle(Math.PI / 2); + assertPathEqual(a.innerRadius(10).outerRadius(100)(), "M0,-41.421356A41.421356,41.421356,0,1,1,41.421356,0L24.142136,0A24.142136,24.142136,0,0,1,0,-24.142136Z"); + assertPathEqual(a.innerRadius(100).outerRadius(10)(), "M0,-41.421356A41.421356,41.421356,0,1,1,41.421356,0L24.142136,0A24.142136,24.142136,0,0,1,0,-24.142136Z"); }); -tape("arc().innerRadius(0).outerRadius(0).startAngle(0).endAngle(τ).padAngle(δ) does not pad a point", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(0).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); - test.pathEqual(a(), "M0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(0).startAngle(0).endAngle(τ).padAngle(δ) does not pad a point", () => { + const a = arc().innerRadius(0).outerRadius(0).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); + assertPathEqual(a(), "M0,0Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(0).endAngle(τ).padAngle(δ) does not pad a circle", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); - test.pathEqual(a(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(0).endAngle(τ).padAngle(δ) does not pad a circle", () => { + const a = arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); + assertPathEqual(a(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(0).endAngle(τ).padAngle(δ) does not pad an annulus", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); - test.pathEqual(a(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(0).endAngle(τ).padAngle(δ) does not pad an annulus", () => { + const a = arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(2 * Math.PI).padAngle(0.1); + assertPathEqual(a(), "M0,-100A100,100,0,1,1,0,100A100,100,0,1,1,0,-100M0,-50A50,50,0,1,0,0,50A50,50,0,1,0,0,-50Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).padAngle(δ) pads the outside of a circular sector", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1); - test.pathEqual(a(), "M4.997917,-99.875026A100,100,0,0,1,99.875026,-4.997917L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).padAngle(δ) pads the outside of a circular sector", () => { + const a = arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1); + assertPathEqual(a(), "M4.997917,-99.875026A100,100,0,0,1,99.875026,-4.997917L0,0Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ) pads an annular sector", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1); - test.pathEqual(a(), "M5.587841,-99.843758A100,100,0,0,1,99.843758,-5.587841L49.686779,-5.587841A50,50,0,0,0,5.587841,-49.686779Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ) pads an annular sector", () => { + const a = arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1); + assertPathEqual(a(), "M5.587841,-99.843758A100,100,0,0,1,99.843758,-5.587841L49.686779,-5.587841A50,50,0,0,0,5.587841,-49.686779Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ) may collapse the inside of an annular sector", function(test) { - var a = shape.arc().innerRadius(10).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.2); - test.pathEqual(a(), "M10.033134,-99.495408A100,100,0,0,1,99.495408,-10.033134L7.071068,-7.071068Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ) may collapse the inside of an annular sector", () => { + const a = arc().innerRadius(10).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.2); + assertPathEqual(a(), "M10.033134,-99.495408A100,100,0,0,1,99.495408,-10.033134L7.071068,-7.071068Z"); }); -tape("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads a circular sector", function(test) { - var a = shape.arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1).cornerRadius(10); - test.pathEqual(a(), "M4.470273,-89.330939A10,10,0,0,1,16.064195,-98.701275A100,100,0,0,1,98.701275,-16.064195A10,10,0,0,1,89.330939,-4.470273L0,0Z"); - test.end(); +it("arc().innerRadius(0).outerRadius(r).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads a circular sector", () => { + const a = arc().innerRadius(0).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1).cornerRadius(10); + assertPathEqual(a(), "M4.470273,-89.330939A10,10,0,0,1,16.064195,-98.701275A100,100,0,0,1,98.701275,-16.064195A10,10,0,0,1,89.330939,-4.470273L0,0Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads an annular sector", function(test) { - var a = shape.arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1).cornerRadius(10); - test.pathEqual(a(), "M5.587841,-88.639829A10,10,0,0,1,17.319823,-98.488698A100,100,0,0,1,98.488698,-17.319823A10,10,0,0,1,88.639829,-5.587841L57.939790,-5.587841A10,10,0,0,1,48.283158,-12.989867A50,50,0,0,0,12.989867,-48.283158A10,10,0,0,1,5.587841,-57.939790Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads an annular sector", () => { + const a = arc().innerRadius(50).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.1).cornerRadius(10); + assertPathEqual(a(), "M5.587841,-88.639829A10,10,0,0,1,17.319823,-98.488698A100,100,0,0,1,98.488698,-17.319823A10,10,0,0,1,88.639829,-5.587841L57.939790,-5.587841A10,10,0,0,1,48.283158,-12.989867A50,50,0,0,0,12.989867,-48.283158A10,10,0,0,1,5.587841,-57.939790Z"); }); -tape("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads a collapsed annular sector", function(test) { - var a = shape.arc().innerRadius(10).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.2).cornerRadius(10); - test.pathEqual(a(), "M9.669396,-88.145811A10,10,0,0,1,21.849183,-97.583878A100,100,0,0,1,97.583878,-21.849183A10,10,0,0,1,88.145811,-9.669396L7.071068,-7.071068Z"); - test.end(); +it("arc().innerRadius(r₀).outerRadius(r₁).startAngle(θ₀).endAngle(θ₁).padAngle(δ).cornerRadius(rᵧ) rounds and pads a collapsed annular sector", () => { + const a = arc().innerRadius(10).outerRadius(100).startAngle(0).endAngle(Math.PI / 2).padAngle(0.2).cornerRadius(10); + assertPathEqual(a(), "M9.669396,-88.145811A10,10,0,0,1,21.849183,-97.583878A100,100,0,0,1,97.583878,-21.849183A10,10,0,0,1,88.145811,-9.669396L7.071068,-7.071068Z"); }); diff --git a/test/area-test.js b/test/area-test.js index 6cdac04..3c0c6ec 100644 --- a/test/area-test.js +++ b/test/area-test.js @@ -1,210 +1,189 @@ -var tape = require("tape"), - shape = require("../"); - -require("./pathEqual"); - -tape("area() returns a default area shape", function(test) { - var a = shape.area(); - test.equal(a.x0()([42, 34]), 42); - test.equal(a.x1(), null); - test.equal(a.y0()([42, 34]), 0); - test.equal(a.y1()([42, 34]), 34); - test.equal(a.defined()([42, 34]), true); - test.equal(a.curve(), shape.curveLinear); - test.equal(a.context(), null); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); - test.end(); -}); - -tape("area(x, y0, y1) sets x0, y0 and y1", function(test) { - var x = function() {}, y = function() {}; - test.equal(shape.area(x).x0(), x); - test.equal(shape.area(x, y).y0(), y); - test.equal(shape.area(x, 0, y).y1(), y); - test.equal(shape.area(3, 2, 1).x0()("aa"), 3); - test.equal(shape.area(3, 2, 1).y0()("aa"), 2); - test.equal(shape.area(3, 2, 1).y1()("aa"), 1); - test.end(); -}); - -tape("area.x(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().x(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.x0(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().x0(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.x1(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().x1(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.y(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().y(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.y0(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().y0(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.y1(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().y1(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.defined(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.area().defined(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); -}); - -tape("area.x(x)(data) observes the specified function", function(test) { - var x = function(d) { return d.x; }, - a = shape.area().x(x); - test.equal(a.x(), x); - test.equal(a.x0(), x); - test.equal(a.x1(), null); - test.pathEqual(a([{x: 0, 1: 1}, {x: 2, 1: 3}, {x: 4, 1: 5}]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); - test.end(); -}); - -tape("area.x(x)(data) observes the specified constant", function(test) { - var x = 0, - a = shape.area().x(x); - test.equal(a.x()(), 0); - test.equal(a.x0()(), 0); - test.equal(a.x1(), null); - test.pathEqual(a([{1: 1}, {1: 3}, {1: 5}]), "M0,1L0,3L0,5L0,0L0,0L0,0Z"); - test.end(); -}); - -tape("area.y(y)(data) observes the specified function", function(test) { - var y = function(d) { return d.y; }, - a = shape.area().y(y); - test.equal(a.y(), y); - test.equal(a.y0(), y); - test.equal(a.y1(), null); - test.pathEqual(a([{0: 0, y: 1}, {0: 2, y: 3}, {0: 4, y: 5}]), "M0,1L2,3L4,5L4,5L2,3L0,1Z"); - test.end(); -}); - -tape("area.y(y)(data) observes the specified constant", function(test) { - var a = shape.area().y(0); - test.equal(a.y()(), 0); - test.equal(a.y0()(), 0); - test.equal(a.y1(), null); - test.pathEqual(a([{0: 0}, {0: 2}, {0: 4}]), "M0,0L2,0L4,0L4,0L2,0L0,0Z"); - test.end(); -}); - -tape("area.curve(curve) sets the curve method", function(test) { - var a = shape.area().curve(shape.curveCardinal); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); - test.end(); -}); - -tape("area.curve(curveCardinal.tension(tension)) sets the cardinal spline tension", function(test) { - var a = shape.area().curve(shape.curveCardinal.tension(0.1)); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,2,1,2,1L2,0C2,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,1.700000,1,2,1C2.300000,1,3,3,3,3L3,0C3,0,2.300000,0,2,0C1.700000,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); - test.end(); -}); - -tape("area.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", function(test) { - var a = shape.area().curve(shape.curveCardinal.tension("0.1")); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,2,1,2,1L2,0C2,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,1.700000,1,2,1C2.300000,1,3,3,3,3L3,0C3,0,2.300000,0,2,0C1.700000,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); - test.end(); -}); - -tape("area.lineX0() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - x0 = function() {}, - x1 = function() {}, - y = function() {}, - a = shape.area().defined(defined).curve(curve).context(context).y(y).x0(x0).x1(x1), - l = a.lineX0(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.x(), x0); - test.equal(l.y(), y); - test.end(); -}); - -tape("area.lineX1() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - x0 = function() {}, - x1 = function() {}, - y = function() {}, - a = shape.area().defined(defined).curve(curve).context(context).y(y).x0(x0).x1(x1), - l = a.lineX1(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.x(), x1); - test.equal(l.y(), y); - test.end(); -}); - -tape("area.lineY0() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - x = function() {}, - y0 = function() {}, - y1 = function() {}, - a = shape.area().defined(defined).curve(curve).context(context).x(x).y0(y0).y1(y1), - l = a.lineY0(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.x(), x); - test.equal(l.y(), y0); - test.end(); -}); - -tape("area.lineY1() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - x = function() {}, - y0 = function() {}, - y1 = function() {}, - a = shape.area().defined(defined).curve(curve).context(context).x(x).y0(y0).y1(y1), - l = a.lineY1(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.x(), x); - test.equal(l.y(), y1); - test.end(); +import assert from "assert"; +import {area, curveCardinal, curveLinear} from "../src/index.js"; +import {assertPathEqual} from "./asserts.js"; + +it("area() returns a default area shape", () => { + const a = area(); + assert.strictEqual(a.x0()([42, 34]), 42); + assert.strictEqual(a.x1(), null); + assert.strictEqual(a.y0()([42, 34]), 0); + assert.strictEqual(a.y1()([42, 34]), 34); + assert.strictEqual(a.defined()([42, 34]), true); + assert.strictEqual(a.curve(), curveLinear); + assert.strictEqual(a.context(), null); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); +}); + +it("area(x, y0, y1) sets x0, y0 and y1", () => { + const x = function() {}, y = function() {}; + assert.strictEqual(area(x).x0(), x); + assert.strictEqual(area(x, y).y0(), y); + assert.strictEqual(area(x, 0, y).y1(), y); + assert.strictEqual(area(3, 2, 1).x0()("aa"), 3); + assert.strictEqual(area(3, 2, 1).y0()("aa"), 2); + assert.strictEqual(area(3, 2, 1).y1()("aa"), 1); +}); + +it("area.x(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().x(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.x0(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().x0(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.x1(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().x1(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.y(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().y(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.y0(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().y0(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.y1(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().y1(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.defined(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + area().defined(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); +}); + +it("area.x(x)(data) observes the specified function", () => { + const x = function(d) { return d.x; }; + const a = area().x(x); + assert.strictEqual(a.x(), x); + assert.strictEqual(a.x0(), x); + assert.strictEqual(a.x1(), null); + assertPathEqual(a([{x: 0, 1: 1}, {x: 2, 1: 3}, {x: 4, 1: 5}]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); +}); + +it("area.x(x)(data) observes the specified constant", () => { + const x = 0; + const a = area().x(x); + assert.strictEqual(a.x()(), 0); + assert.strictEqual(a.x0()(), 0); + assert.strictEqual(a.x1(), null); + assertPathEqual(a([{1: 1}, {1: 3}, {1: 5}]), "M0,1L0,3L0,5L0,0L0,0L0,0Z"); +}); + +it("area.y(y)(data) observes the specified function", () => { + const y = function(d) { return d.y; }; + const a = area().y(y); + assert.strictEqual(a.y(), y); + assert.strictEqual(a.y0(), y); + assert.strictEqual(a.y1(), null); + assertPathEqual(a([{0: 0, y: 1}, {0: 2, y: 3}, {0: 4, y: 5}]), "M0,1L2,3L4,5L4,5L2,3L0,1Z"); +}); + +it("area.y(y)(data) observes the specified constant", () => { + const a = area().y(0); + assert.strictEqual(a.y()(), 0); + assert.strictEqual(a.y0()(), 0); + assert.strictEqual(a.y1(), null); + assertPathEqual(a([{0: 0}, {0: 2}, {0: 4}]), "M0,0L2,0L4,0L4,0L2,0L0,0Z"); +}); + +it("area.curve(curve) sets the curve method", () => { + const a = area().curve(curveCardinal); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); +}); + +it("area.curve(curveCardinal.tension(tension)) sets the cardinal spline tension", () => { + const a = area().curve(curveCardinal.tension(0.1)); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,2,1,2,1L2,0C2,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,1.700000,1,2,1C2.300000,1,3,3,3,3L3,0C3,0,2.300000,0,2,0C1.700000,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); +}); + +it("area.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", () => { + const a = area().curve(curveCardinal.tension("0.1")); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,2,1,2,1L2,0C2,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.700000,3,1,3C1.300000,3,1.700000,1,2,1C2.300000,1,3,3,3,3L3,0C3,0,2.300000,0,2,0C1.700000,0,1.300000,0,1,0C0.700000,0,0,0,0,0Z"); +}); + +it("area.lineX0() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const x0 = function() {}; + const x1 = function() {}; + const y = function() {}; + const a = area().defined(defined).curve(curve).context(context).y(y).x0(x0).x1(x1); + const l = a.lineX0(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.x(), x0); + assert.strictEqual(l.y(), y); +}); + +it("area.lineX1() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const x0 = function() {}; + const x1 = function() {}; + const y = function() {}; + const a = area().defined(defined).curve(curve).context(context).y(y).x0(x0).x1(x1); + const l = a.lineX1(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.x(), x1); + assert.strictEqual(l.y(), y); +}); + +it("area.lineY0() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const x = function() {}; + const y0 = function() {}; + const y1 = function() {}; + const a = area().defined(defined).curve(curve).context(context).x(x).y0(y0).y1(y1); + const l = a.lineY0(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.x(), x); + assert.strictEqual(l.y(), y0); +}); + +it("area.lineY1() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const x = function() {}; + const y0 = function() {}; + const y1 = function() {}; + const a = area().defined(defined).curve(curve).context(context).x(x).y0(y0).y1(y1); + const l = a.lineY1(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.x(), x); + assert.strictEqual(l.y(), y1); }); diff --git a/test/areaRadial-test.js b/test/areaRadial-test.js index d9855fe..aa74e69 100644 --- a/test/areaRadial-test.js +++ b/test/areaRadial-test.js @@ -1,85 +1,79 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {areaRadial, curveCardinal, curveLinear} from "../src/index.js"; +import {assertPathEqual} from "./asserts.js"; -require("./pathEqual"); - -tape("areaRadial() returns a default radial area shape", function(test) { - var a = shape.areaRadial(); - test.equal(a.startAngle()([42, 34]), 42); - test.equal(a.endAngle(), null); - test.equal(a.innerRadius()([42, 34]), 0); - test.equal(a.outerRadius()([42, 34]), 34); - test.equal(a.defined()([42, 34]), true); - test.equal(a.curve(), shape.curveLinear); - test.equal(a.context(), null); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,-1L2.727892,1.248441L-3.784012,3.268218L0,0L0,0L0,0Z"); - test.end(); +it("areaRadial() returns a default radial area shape", () => { + const a = areaRadial(); + assert.strictEqual(a.startAngle()([42, 34]), 42); + assert.strictEqual(a.endAngle(), null); + assert.strictEqual(a.innerRadius()([42, 34]), 0); + assert.strictEqual(a.outerRadius()([42, 34]), 34); + assert.strictEqual(a.defined()([42, 34]), true); + assert.strictEqual(a.curve(), curveLinear); + assert.strictEqual(a.context(), null); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,-1L2.727892,1.248441L-3.784012,3.268218L0,0L0,0L0,0Z"); }); -tape("areaRadial.lineStartAngle() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - startAngle = function() {}, - endAngle = function() {}, - radius = function() {}, - a = shape.areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle), - l = a.lineStartAngle(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.angle(), startAngle); - test.equal(l.radius(), radius); - test.end(); +it("areaRadial.lineStartAngle() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const startAngle = function() {}; + const endAngle = function() {}; + const radius = function() {}; + const a = areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle); + const l = a.lineStartAngle(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.angle(), startAngle); + assert.strictEqual(l.radius(), radius); }); -tape("areaRadial.lineEndAngle() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - startAngle = function() {}, - endAngle = function() {}, - radius = function() {}, - a = shape.areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle), - l = a.lineEndAngle(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.angle(), endAngle); - test.equal(l.radius(), radius); - test.end(); +it("areaRadial.lineEndAngle() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const startAngle = function() {}; + const endAngle = function() {}; + const radius = function() {}; + const a = areaRadial().defined(defined).curve(curve).context(context).radius(radius).startAngle(startAngle).endAngle(endAngle); + const l = a.lineEndAngle(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.angle(), endAngle); + assert.strictEqual(l.radius(), radius); }); -tape("areaRadial.lineInnerRadius() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - angle = function() {}, - innerRadius = function() {}, - outerRadius = function() {}, - a = shape.areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius), - l = a.lineInnerRadius(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.angle(), angle); - test.equal(l.radius(), innerRadius); - test.end(); +it("areaRadial.lineInnerRadius() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const angle = function() {}; + const innerRadius = function() {}; + const outerRadius = function() {}; + const a = areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius); + const l = a.lineInnerRadius(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.angle(), angle); + assert.strictEqual(l.radius(), innerRadius); }); -tape("areaRadial.lineOuterRadius() returns a line derived from the area", function(test) { - var defined = function() { return true; }, - curve = shape.curveCardinal, - context = {}, - angle = function() {}, - innerRadius = function() {}, - outerRadius = function() {}, - a = shape.areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius), - l = a.lineOuterRadius(); - test.equal(l.defined(), defined); - test.equal(l.curve(), curve); - test.equal(l.context(), context); - test.equal(l.angle(), angle); - test.equal(l.radius(), outerRadius); - test.end(); +it("areaRadial.lineOuterRadius() returns a line derived from the area", () => { + const defined = function() { return true; }; + const curve = curveCardinal; + const context = {}; + const angle = function() {}; + const innerRadius = function() {}; + const outerRadius = function() {}; + const a = areaRadial().defined(defined).curve(curve).context(context).angle(angle).innerRadius(innerRadius).outerRadius(outerRadius); + const l = a.lineOuterRadius(); + assert.strictEqual(l.defined(), defined); + assert.strictEqual(l.curve(), curve); + assert.strictEqual(l.context(), context); + assert.strictEqual(l.angle(), angle); + assert.strictEqual(l.radius(), outerRadius); }); diff --git a/test/asserts.js b/test/asserts.js new file mode 100644 index 0000000..24e1e8e --- /dev/null +++ b/test/asserts.js @@ -0,0 +1,44 @@ +import assert from "assert"; + +export function assertPathEqual(actual, expected) { + assert.strictEqual(normalizePath(actual + ""), normalizePath(expected + "")); +} + +const reNumber = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g; + +function normalizePath(path) { + return path.replace(reNumber, formatNumber); +} + +function formatNumber(s) { + return Math.abs((s = +s) - Math.round(s)) < 1e-6 ? Math.round(s) : s.toFixed(6); +} + +export function assertInDelta(actual, expected, delta) { + delta = delta || 1e-6; + assert(inDelta(actual, expected, delta), + `${actual} should be within ${delta} of ${expected}`); +} + +function inDelta(actual, expected, delta) { + return (Array.isArray(expected) ? inDeltaArray + : typeof expected === "object" ? inDeltaObject + : inDeltaNumber)(actual, expected, delta); +} + +function inDeltaArray(actual, expected, delta) { + let n = expected.length, i = -1; + if (actual.length !== n) return false; + while (++i < n) if (!inDelta(actual[i], expected[i], delta)) return false; + return true; +} + +function inDeltaObject(actual, expected, delta) { + for (let i in expected) if (!inDelta(actual[i], expected[i], delta)) return false; + for (let i in actual) if (!(i in expected)) return false; + return true; +} + +function inDeltaNumber(actual, expected, delta) { + return actual >= expected - delta && actual <= expected + delta; +} diff --git a/test/curve/basis-test.js b/test/curve/basis-test.js index 563a4f5..a10980a 100644 --- a/test/curve/basis-test.js +++ b/test/curve/basis-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveBasis} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveBasis)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveBasis); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1L0.166667,1.333333C0.333333,1.666667,0.666667,2.333333,1,2.333333C1.333333,2.333333,1.666667,1.666667,1.833333,1.333333L2,1"); - test.end(); +it("line.curve(curveBasis)(data) generates the expected path", () => { + const l = line().curve(curveBasis); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1L0.166667,1.333333C0.333333,1.666667,0.666667,2.333333,1,2.333333C1.333333,2.333333,1.666667,1.666667,1.833333,1.333333L2,1"); }); -tape("area.curve(curveBasis)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveBasis); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1L0.166667,1.333333C0.333333,1.666667,0.666667,2.333333,1,2.333333C1.333333,2.333333,1.666667,1.666667,1.833333,1.333333L2,1L2,0L1.833333,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0.166667,0L0,0Z"); - test.end(); +it("area.curve(curveBasis)(data) generates the expected path", () => { + const a = area().curve(curveBasis); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1L0.166667,1.333333C0.333333,1.666667,0.666667,2.333333,1,2.333333C1.333333,2.333333,1.666667,1.666667,1.833333,1.333333L2,1L2,0L1.833333,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0.166667,0L0,0Z"); }); diff --git a/test/curve/basisClosed-test.js b/test/curve/basisClosed-test.js index c8693e5..a66760a 100644 --- a/test/curve/basisClosed-test.js +++ b/test/curve/basisClosed-test.js @@ -1,15 +1,13 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {line, curveBasisClosed} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveBasisClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveBasisClosed); - test.equal(l([]), null); - test.pathEqual(l([[0, 0]]), "M0,0Z"); - test.pathEqual(l([[0, 0], [0, 10]]), "M0,6.666667L0,3.333333Z"); - test.pathEqual(l([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333C3.333333,10,6.666667,10,6.666667,8.333333C6.666667,6.666667,3.333333,3.333333,1.666667,3.333333C0,3.333333,0,6.666667,1.666667,8.333333"); - test.pathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667C6.666667,0,3.333333,0,1.666667,1.666667C0,3.333333,0,6.666667,1.666667,8.333333"); - test.pathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667C6.666667,0,3.333333,0,1.666667,0C0,0,0,0,0,1.666667C0,3.333333,0,6.666667,1.666667,8.333333"); - test.end(); +it("line.curve(curveBasisClosed)(data) generates the expected path", () => { + const l = line().curve(curveBasisClosed); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 0]]), "M0,0Z"); + assertPathEqual(l([[0, 0], [0, 10]]), "M0,6.666667L0,3.333333Z"); + assertPathEqual(l([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333C3.333333,10,6.666667,10,6.666667,8.333333C6.666667,6.666667,3.333333,3.333333,1.666667,3.333333C0,3.333333,0,6.666667,1.666667,8.333333"); + assertPathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667C6.666667,0,3.333333,0,1.666667,1.666667C0,3.333333,0,6.666667,1.666667,8.333333"); + assertPathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667C6.666667,0,3.333333,0,1.666667,0C0,0,0,0,0,1.666667C0,3.333333,0,6.666667,1.666667,8.333333"); }); diff --git a/test/curve/basisOpen-test.js b/test/curve/basisOpen-test.js index 8c0c7e6..9f45b31 100644 --- a/test/curve/basisOpen-test.js +++ b/test/curve/basisOpen-test.js @@ -1,26 +1,23 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveBasisOpen} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveBasisOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveBasisOpen); - test.equal(l([]), null); - test.equal(l([[0, 0]]), null); - test.equal(l([[0, 0], [0, 10]]), null); - test.pathEqual(l([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333Z"); - test.pathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333"); - test.pathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667"); - test.end(); +it("line.curve(curveBasisOpen)(data) generates the expected path", () => { + const l = line().curve(curveBasisOpen); + assert.strictEqual(l([]), null); + assert.strictEqual(l([[0, 0]]), null); + assert.strictEqual(l([[0, 0], [0, 10]]), null); + assertPathEqual(l([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333Z"); + assertPathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333"); + assertPathEqual(l([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667"); }); -tape("area.curve(curveBasisOpen)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveBasisOpen); - test.equal(a([]), null); - test.equal(a([[0, 1]]), null); - test.equal(a([[0, 1], [1, 3]]), null); - test.pathEqual(a([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333L1.666667,0Z"); - test.pathEqual(a([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333L8.333333,0C6.666667,0,3.333333,0,1.666667,0Z"); - test.pathEqual(a([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667L8.333333,0C10,0,10,0,8.333333,0C6.666667,0,3.333333,0,1.666667,0Z"); - test.end(); +it("area.curve(curveBasisOpen)(data) generates the expected path", () => { + const a = area().curve(curveBasisOpen); + assert.strictEqual(a([]), null); + assert.strictEqual(a([[0, 1]]), null); + assert.strictEqual(a([[0, 1], [1, 3]]), null); + assertPathEqual(a([[0, 0], [0, 10], [10, 10]]), "M1.666667,8.333333L1.666667,0Z"); + assertPathEqual(a([[0, 0], [0, 10], [10, 10], [10, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333L8.333333,0C6.666667,0,3.333333,0,1.666667,0Z"); + assertPathEqual(a([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]), "M1.666667,8.333333C3.333333,10,6.666667,10,8.333333,8.333333C10,6.666667,10,3.333333,8.333333,1.666667L8.333333,0C10,0,10,0,8.333333,0C6.666667,0,3.333333,0,1.666667,0Z"); }); diff --git a/test/curve/bumpX-test.js b/test/curve/bumpX-test.js index d8c82bf..dccea4e 100644 --- a/test/curve/bumpX-test.js +++ b/test/curve/bumpX-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveBumpX} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveBumpX)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveBumpX); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1C0.500000,1,0.500000,3,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.500000,1,0.500000,3,1,3C1.500000,3,1.500000,1,2,1"); - test.end(); +it("line.curve(curveBumpX)(data) generates the expected path", () => { + const l = line().curve(curveBumpX); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1C0.500000,1,0.500000,3,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.500000,1,0.500000,3,1,3C1.500000,3,1.500000,1,2,1"); }); -tape("area.curve(curveBumpX)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveBumpX); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1C0.500000,1,0.500000,3,1,3L1,0C0.500000,0,0.500000,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.500000,1,0.500000,3,1,3C1.500000,3,1.500000,1,2,1L2,0C1.500000,0,1.500000,0,1,0C0.500000,0,0.500000,0,0,0Z"); - test.end(); +it("area.curve(curveBumpX)(data) generates the expected path", () => { + const a = area().curve(curveBumpX); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1C0.500000,1,0.500000,3,1,3L1,0C0.500000,0,0.500000,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.500000,1,0.500000,3,1,3C1.500000,3,1.500000,1,2,1L2,0C1.500000,0,1.500000,0,1,0C0.500000,0,0.500000,0,0,0Z"); }); diff --git a/test/curve/bumpY-test.js b/test/curve/bumpY-test.js index 6014b74..431b7c3 100644 --- a/test/curve/bumpY-test.js +++ b/test/curve/bumpY-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveBumpY} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveBumpY)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveBumpY); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1C0,2,1,2,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,2,1,2,1,3C1,2,2,2,2,1"); - test.end(); +it("line.curve(curveBumpY)(data) generates the expected path", () => { + const l = line().curve(curveBumpY); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1C0,2,1,2,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,2,1,2,1,3C1,2,2,2,2,1"); }); -tape("area.curve(curveBumpY)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveBumpY); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1C0,2,1,2,1,3L1,0C1,0,0,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,2,1,2,1,3C1,2,2,2,2,1L2,0C2,0,1,0,1,0C1,0,0,0,0,0Z"); - test.end(); +it("area.curve(curveBumpY)(data) generates the expected path", () => { + const a = area().curve(curveBumpY); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1C0,2,1,2,1,3L1,0C1,0,0,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,2,1,2,1,3C1,2,2,2,2,1L2,0C2,0,1,0,1,0C1,0,0,0,0,0Z"); }); diff --git a/test/curve/bundle-test.js b/test/curve/bundle-test.js index 48a6bb4..af72420 100644 --- a/test/curve/bundle-test.js +++ b/test/curve/bundle-test.js @@ -1,21 +1,16 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {line, curveBundle} from "../../src/index.js"; -require("../pathEqual"); - -tape("line.curve(curveBundle) uses a default beta of 0.85", function(test) { - var l = shape.line().curve(shape.curveBundle.beta(0.85)); - test.equal(shape.line().curve(shape.curveBundle)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveBundle) uses a default beta of 0.85", () => { + const l = line().curve(curveBundle.beta(0.85)); + assert.strictEqual(line().curve(curveBundle)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveBundle.beta(beta)) uses the specified beta", function(test) { - test.equal(shape.line().curve(shape.curveBundle.beta(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1L0.16666666666666666,1.222222222222222C0.3333333333333333,1.4444444444444444,0.6666666666666666,1.8888888888888886,1,1.9999999999999998C1.3333333333333333,2.1111111111111107,1.6666666666666667,1.8888888888888886,2,2C2.3333333333333335,2.111111111111111,2.6666666666666665,2.5555555555555554,2.8333333333333335,2.7777777777777772L3,3"); - test.end(); +it("line.curve(curveBundle.beta(beta)) uses the specified beta", () => { + assert.strictEqual(line().curve(curveBundle.beta(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1L0.16666666666666666,1.222222222222222C0.3333333333333333,1.4444444444444444,0.6666666666666666,1.8888888888888886,1,1.9999999999999998C1.3333333333333333,2.1111111111111107,1.6666666666666667,1.8888888888888886,2,2C2.3333333333333335,2.111111111111111,2.6666666666666665,2.5555555555555554,2.8333333333333335,2.7777777777777772L3,3"); }); -tape("line.curve(curveBundle.beta(beta)) coerces the specified beta to a number", function(test) { - var l = shape.line().curve(shape.curveBundle.beta("0.5")); - test.equal(shape.line().curve(shape.curveBundle.beta(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveBundle.beta(beta)) coerces the specified beta to a number", () => { + const l = line().curve(curveBundle.beta("0.5")); + assert.strictEqual(line().curve(curveBundle.beta(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/cardinal-test.js b/test/curve/cardinal-test.js index dc26680..7a802d3 100644 --- a/test/curve/cardinal-test.js +++ b/test/curve/cardinal-test.js @@ -1,58 +1,49 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveCardinal} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveCardinal)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCardinal); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); - test.end(); +it("line.curve(curveCardinal)(data) generates the expected path", () => { + const l = line().curve(curveCardinal); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); }); -tape("line.curve(curveCardinal) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.curveCardinal.tension(0)); - test.equal(shape.line().curve(shape.curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinal) uses a default tension of zero", () => { + const l = line().curve(curveCardinal.tension(0)); + assert.strictEqual(line().curve(curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCardinal.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.line().curve(shape.curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.833333,3,1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3,3,3,3"); - test.end(); +it("line.curve(curveCardinal.tension(tension)) uses the specified tension", () => { + assertPathEqual(line().curve(curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.833333,3,1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3,3,3,3"); }); -tape("line.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", function(test) { - var l = shape.line().curve(shape.curveCardinal.tension("0.5")); - test.equal(shape.line().curve(shape.curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", () => { + const l = line().curve(curveCardinal.tension("0.5")); + assert.strictEqual(line().curve(curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinal)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveCardinal); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1L2,0C2,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); - test.end(); +it("area.curve(curveCardinal)(data) generates the expected path", () => { + const a = area().curve(curveCardinal); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1L2,0C2,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); }); -tape("area.curve(curveCardinal) uses a default tension of zero", function(test) { - var a = shape.area().curve(shape.curveCardinal.tension(0)); - test.equal(shape.area().curve(shape.curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinal) uses a default tension of zero", () => { + const a = area().curve(curveCardinal.tension(0)); + assert.strictEqual(area().curve(curveCardinal)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinal.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.area().curve(shape.curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.833333,3,1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3,3,3,3L3,0C3,0,2.166667,0,2,0C1.833333,0,1.166667,0,1,0C0.833333,0,0,0,0,0Z"); - test.end(); +it("area.curve(curveCardinal.tension(tension)) uses the specified tension", () => { + assertPathEqual(area().curve(curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.833333,3,1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3,3,3,3L3,0C3,0,2.166667,0,2,0C1.833333,0,1.166667,0,1,0C0.833333,0,0,0,0,0Z"); }); -tape("area.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", function(test) { - var a = shape.area().curve(shape.curveCardinal.tension("0.5")); - test.equal(shape.area().curve(shape.curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinal.tension(tension)) coerces the specified tension to a number", () => { + const a = area().curve(curveCardinal.tension("0.5")); + assert.strictEqual(area().curve(curveCardinal.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/cardinalClosed-test.js b/test/curve/cardinalClosed-test.js index 36e52da..8c8246f 100644 --- a/test/curve/cardinalClosed-test.js +++ b/test/curve/cardinalClosed-test.js @@ -1,58 +1,49 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveCardinalClosed} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveCardinalClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCardinalClosed); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3"); - test.end(); +it("line.curve(curveCardinalClosed)(data) generates the expected path", () => { + const l = line().curve(curveCardinalClosed); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3"); }); -tape("line.curve(curveCardinalClosed) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.curveCardinalClosed.tension(0)); - test.equal(shape.line().curve(shape.curveCardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinalClosed) uses a default tension of zero", () => { + const l = line().curve(curveCardinalClosed.tension(0)); + assert.strictEqual(line().curve(curveCardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCardinalClosed.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.line().curve(shape.curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3.166667,3,3,3C2.833333,3,0.166667,1,0,1C-0.166667,1,0.833333,3,1,3"); - test.end(); +it("line.curve(curveCardinalClosed.tension(tension)) uses the specified tension", () => { + assertPathEqual(line().curve(curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3.166667,3,3,3C2.833333,3,0.166667,1,0,1C-0.166667,1,0.833333,3,1,3"); }); -tape("line.curve(curveCardinalClosed.tension(tension)) coerces the specified tension to a number", function(test) { - var l = shape.line().curve(shape.curveCardinalClosed.tension("0.5")); - test.equal(shape.line().curve(shape.curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinalClosed.tension(tension)) coerces the specified tension to a number", () => { + const l = line().curve(curveCardinalClosed.tension("0.5")); + assert.strictEqual(line().curve(curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinalClosed)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveCardinalClosed); - test.equal(a([]), null); - test.equal(a([[0, 1]]), "M0,1ZM0,0Z"); - test.equal(a([[0, 1], [1, 3]]), "M1,3L0,1ZM0,0L1,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3M1,0C0.666667,0,-0.166667,0,0,0C0.166667,0,1.833333,0,2,0C2.166667,0,1.333333,0,1,0"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3M2,0C1.666667,0,1.333333,0,1,0C0.666667,0,-0.333333,0,0,0C0.333333,0,2.666667,0,3,0C3.333333,0,2.333333,0,2,0"); - test.end(); +it("area.curve(curveCardinalClosed)(data) generates the expected path", () => { + const a = area().curve(curveCardinalClosed); + assert.strictEqual(a([]), null); + assert.strictEqual(a([[0, 1]]), "M0,1ZM0,0Z"); + assert.strictEqual(a([[0, 1], [1, 3]]), "M1,3L0,1ZM0,0L1,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3M1,0C0.666667,0,-0.166667,0,0,0C0.166667,0,1.833333,0,2,0C2.166667,0,1.333333,0,1,0"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3M2,0C1.666667,0,1.333333,0,1,0C0.666667,0,-0.333333,0,0,0C0.333333,0,2.666667,0,3,0C3.333333,0,2.333333,0,2,0"); }); -tape("area.curve(curveCardinalClosed) uses a default tension of zero", function(test) { - var a = shape.area().curve(shape.curveCardinalClosed.tension(0)); - test.equal(shape.area().curve(shape.curveCardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinalClosed) uses a default tension of zero", () => { + const a = area().curve(curveCardinalClosed.tension(0)); + assert.strictEqual(area().curve(curveCardinalClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinalClosed.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.area().curve(shape.curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3.166667,3,3,3C2.833333,3,0.166667,1,0,1C-0.166667,1,0.833333,3,1,3M2,0C1.833333,0,1.166667,0,1,0C0.833333,0,-0.166667,0,0,0C0.166667,0,2.833333,0,3,0C3.166667,0,2.166667,0,2,0"); - test.end(); +it("area.curve(curveCardinalClosed.tension(tension)) uses the specified tension", () => { + assertPathEqual(area().curve(curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1C2.166667,1,3.166667,3,3,3C2.833333,3,0.166667,1,0,1C-0.166667,1,0.833333,3,1,3M2,0C1.833333,0,1.166667,0,1,0C0.833333,0,-0.166667,0,0,0C0.166667,0,2.833333,0,3,0C3.166667,0,2.166667,0,2,0"); }); -tape("area.curve(curveCardinalClosed.tension(tension)) coerces the specified tension to a number", function(test) { - var a = shape.area().curve(shape.curveCardinalClosed.tension("0.5")); - test.equal(shape.area().curve(shape.curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinalClosed.tension(tension)) coerces the specified tension to a number", () => { + const a = area().curve(curveCardinalClosed.tension("0.5")); + assert.strictEqual(area().curve(curveCardinalClosed.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/cardinalOpen-test.js b/test/curve/cardinalOpen-test.js index 652cbe4..ab205a9 100644 --- a/test/curve/cardinalOpen-test.js +++ b/test/curve/cardinalOpen-test.js @@ -1,58 +1,49 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveCardinalOpen} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveCardinalOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCardinalOpen); - test.equal(l([]), null); - test.equal(l([[0, 1]]), null); - test.equal(l([[0, 1], [1, 3]]), null); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); - test.end(); +it("line.curve(curveCardinalOpen)(data) generates the expected path", () => { + const l = line().curve(curveCardinalOpen); + assert.strictEqual(l([]), null); + assert.strictEqual(l([[0, 1]]), null); + assert.strictEqual(l([[0, 1], [1, 3]]), null); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); }); -tape("line.curve(curveCardinalOpen) uses a default tension of zero", function(test) { - var l = shape.line().curve(shape.curveCardinalOpen.tension(0)); - test.equal(shape.line().curve(shape.curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinalOpen) uses a default tension of zero", () => { + const l = line().curve(curveCardinalOpen.tension(0)); + assert.strictEqual(line().curve(curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCardinalOpen.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.line().curve(shape.curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1"); - test.end(); +it("line.curve(curveCardinalOpen.tension(tension)) uses the specified tension", () => { + assertPathEqual(line().curve(curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1"); }); -tape("line.curve(curveCardinalOpen.tension(tension)) coerces the specified tension to a number", function(test) { - var l = shape.line().curve(shape.curveCardinalOpen.tension("0.5")); - test.equal(shape.line().curve(shape.curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCardinalOpen.tension(tension)) coerces the specified tension to a number", () => { + const l = line().curve(curveCardinalOpen.tension("0.5")); + assert.strictEqual(line().curve(curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinalOpen)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveCardinalOpen); - test.equal(a([]), null); - test.equal(a([[0, 1]]), null); - test.equal(a([[0, 1], [1, 3]]), null); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3L1,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1L2,0C1.666667,0,1.333333,0,1,0Z"); - test.end(); +it("area.curve(curveCardinalOpen)(data) generates the expected path", () => { + const a = area().curve(curveCardinalOpen); + assert.strictEqual(a([]), null); + assert.strictEqual(a([[0, 1]]), null); + assert.strictEqual(a([[0, 1], [1, 3]]), null); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3L1,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1L2,0C1.666667,0,1.333333,0,1,0Z"); }); -tape("area.curve(curveCardinalOpen) uses a default tension of zero", function(test) { - var a = shape.area().curve(shape.curveCardinalOpen.tension(0)); - test.equal(shape.area().curve(shape.curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinalOpen) uses a default tension of zero", () => { + const a = area().curve(curveCardinalOpen.tension(0)); + assert.strictEqual(area().curve(curveCardinalOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCardinalOpen.tension(tension)) uses the specified tension", function(test) { - test.pathEqual(shape.area().curve(shape.curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1L2,0C1.833333,0,1.166667,0,1,0Z"); - test.end(); +it("area.curve(curveCardinalOpen.tension(tension)) uses the specified tension", () => { + assertPathEqual(area().curve(curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.166667,3,1.833333,1,2,1L2,0C1.833333,0,1.166667,0,1,0Z"); }); -tape("area.curve(curveCardinalOpen.tension(tension)) coerces the specified tension to a number", function(test) { - var a = shape.area().curve(shape.curveCardinalOpen.tension("0.5")); - test.equal(shape.area().curve(shape.curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCardinalOpen.tension(tension)) coerces the specified tension to a number", () => { + const a = area().curve(curveCardinalOpen.tension("0.5")); + assert.strictEqual(area().curve(curveCardinalOpen.tension(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/catmullRom-test.js b/test/curve/catmullRom-test.js index b617b84..a74f082 100644 --- a/test/curve/catmullRom-test.js +++ b/test/curve/catmullRom-test.js @@ -1,58 +1,50 @@ -var tape = require("tape"), - shape = require("../../"); - -require("../pathEqual"); - -tape("line.curve(curveCatmullRom)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRom); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); - test.end(); +import assert from "assert"; +import {area, line, curveCatmullRom} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; + +it("line.curve(curveCatmullRom)(data) generates the expected path", () => { + const l = line().curve(curveCatmullRom); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); }); -tape("line.curve(curveCatmullRom.alpha(1))(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRom.alpha(1)); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); - test.end(); +it("line.curve(curveCatmullRom.alpha(1))(data) generates the expected path", () => { + const l = line().curve(curveCatmullRom.alpha(1)); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3"); }); -tape("line.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.curveCatmullRom.alpha(0.5)); - test.equal(shape.line().curve(shape.curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", () => { + const l = line().curve(curveCatmullRom.alpha(0.5)); + assert.strictEqual(line().curve(curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCatmullRom.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var l = shape.line().curve(shape.curveCatmullRom.alpha("0.5")); - test.equal(shape.line().curve(shape.curveCatmullRom.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRom.alpha(alpha)) coerces the specified alpha to a number", () => { + const l = line().curve(curveCatmullRom.alpha("0.5")); + assert.strictEqual(line().curve(curveCatmullRom.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCatmullRom.alpha(0))(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveCatmullRom.alpha(0)); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1L2,0C2,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); - test.end(); +it("area.curve(curveCatmullRom.alpha(0))(data) generates the expected path", () => { + const a = area().curve(curveCatmullRom.alpha(0)); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,2,1,2,1L2,0C2,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0,1,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3,3,3,3L3,0C3,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0,0,0,0Z"); }); -tape("area.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", function(test) { - var a = shape.area().curve(shape.curveCatmullRom.alpha(0.5)); - test.equal(shape.area().curve(shape.curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCatmullRom) uses a default alpha of 0.5 (centripetal)", () => { + const a = area().curve(curveCatmullRom.alpha(0.5)); + assert.strictEqual(area().curve(curveCatmullRom)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCatmullRom.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var a = shape.area().curve(shape.curveCatmullRom.alpha("0.5")); - test.equal(shape.area().curve(shape.curveCatmullRom.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCatmullRom.alpha(alpha)) coerces the specified alpha to a number", () => { + const a = area().curve(curveCatmullRom.alpha("0.5")); + assert.strictEqual(area().curve(curveCatmullRom.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/catmullRomClosed-test.js b/test/curve/catmullRomClosed-test.js index 900dafb..4d9fc8f 100644 --- a/test/curve/catmullRomClosed-test.js +++ b/test/curve/catmullRomClosed-test.js @@ -1,52 +1,45 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveCatmullRomClosed} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveCatmullRomClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRomClosed); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.200267,1.324038,2,1C1.810600,0.693544,0.189400,0.693544,0,1C-0.200267,1.324038,0.666667,3,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.160469,2.858341,3,3C2.796233,3.179882,0.203767,0.820118,0,1C-0.160469,1.141659,0.666667,3,1,3"); - test.end(); +it("line.curve(curveCatmullRomClosed)(data) generates the expected path", () => { + const l = line().curve(curveCatmullRomClosed); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.200267,1.324038,2,1C1.810600,0.693544,0.189400,0.693544,0,1C-0.200267,1.324038,0.666667,3,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.160469,2.858341,3,3C2.796233,3.179882,0.203767,0.820118,0,1C-0.160469,1.141659,0.666667,3,1,3"); }); -tape("line.curve(curveCatmullRomClosed.alpha(0))(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRomClosed.alpha(0)); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3"); - test.end(); +it("line.curve(curveCatmullRomClosed.alpha(0))(data) generates the expected path", () => { + const l = line().curve(curveCatmullRomClosed.alpha(0)); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.166667,1.333333,2,1C1.833333,0.666667,0.166667,0.666667,0,1C-0.166667,1.333333,0.666667,3,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.333333,3,3,3C2.666667,3,0.333333,1,0,1C-0.333333,1,0.666667,3,1,3"); }); -tape("line.curve(curveCatmullRomClosed.alpha(1))(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRomClosed.alpha(1)); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.236068,1.314757,2,1C1.788854,0.718473,0.211146,0.718473,0,1C-0.236068,1.314757,0.666667,3,1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.031652,2.746782,3,3C2.948962,3.408301,0.051038,0.591699,0,1C-0.031652,1.253218,0.666667,3,1,3"); - test.end(); +it("line.curve(curveCatmullRomClosed.alpha(1))(data) generates the expected path", () => { + const l = line().curve(curveCatmullRomClosed.alpha(1)); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M1,3L0,1Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3C1.333333,3,2.236068,1.314757,2,1C1.788854,0.718473,0.211146,0.718473,0,1C-0.236068,1.314757,0.666667,3,1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1C2.333333,1,3.031652,2.746782,3,3C2.948962,3.408301,0.051038,0.591699,0,1C-0.031652,1.253218,0.666667,3,1,3"); }); -tape("line.curve(curveCatmullRomClosed) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.curveCatmullRomClosed.alpha(0.5)); - test.equal(shape.line().curve(shape.curveCatmullRomClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRomClosed) uses a default alpha of 0.5 (centripetal)", () => { + const l = line().curve(curveCatmullRomClosed.alpha(0.5)); + assert.strictEqual(line().curve(curveCatmullRomClosed)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCatmullRomClosed.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var l = shape.line().curve(shape.curveCatmullRomClosed.alpha("0.5")); - test.equal(shape.line().curve(shape.curveCatmullRomClosed.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRomClosed.alpha(alpha)) coerces the specified alpha to a number", () => { + const l = line().curve(curveCatmullRomClosed.alpha("0.5")); + assert.strictEqual(line().curve(curveCatmullRomClosed.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCatmullRomClosed.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var a = shape.area().curve(shape.curveCatmullRomClosed.alpha("0.5")); - test.equal(shape.area().curve(shape.curveCatmullRomClosed.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCatmullRomClosed.alpha(alpha)) coerces the specified alpha to a number", () => { + const a = area().curve(curveCatmullRomClosed.alpha("0.5")); + assert.strictEqual(area().curve(curveCatmullRomClosed.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/catmullRomOpen-test.js b/test/curve/catmullRomOpen-test.js index a8acad4..2cdca0d 100644 --- a/test/curve/catmullRomOpen-test.js +++ b/test/curve/catmullRomOpen-test.js @@ -1,58 +1,50 @@ -var tape = require("tape"), - shape = require("../../"); - -require("../pathEqual"); - -tape("line.curve(curveCatmullRomOpen)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRomOpen); - test.equal(l([]), null); - test.equal(l([[0, 1]]), null); - test.equal(l([[0, 1], [1, 3]]), null); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); - test.end(); +import assert from "assert"; +import {area, line, curveCatmullRomOpen} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; + +it("line.curve(curveCatmullRomOpen)(data) generates the expected path", () => { + const l = line().curve(curveCatmullRomOpen); + assert.strictEqual(l([]), null); + assert.strictEqual(l([[0, 1]]), null); + assert.strictEqual(l([[0, 1], [1, 3]]), null); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); }); -tape("line.curve(curveCatmullRomOpen.alpha(1))(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveCatmullRomOpen.alpha(1)); - test.equal(l([]), null); - test.equal(l([[0, 1]]), null); - test.equal(l([[0, 1], [1, 3]]), null); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); - test.end(); +it("line.curve(curveCatmullRomOpen.alpha(1))(data) generates the expected path", () => { + const l = line().curve(curveCatmullRomOpen.alpha(1)); + assert.strictEqual(l([]), null); + assert.strictEqual(l([[0, 1]]), null); + assert.strictEqual(l([[0, 1], [1, 3]]), null); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M1,3Z"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1"); }); -tape("line.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { - var l = shape.line().curve(shape.curveCatmullRomOpen.alpha(0.5)); - test.equal(shape.line().curve(shape.curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", () => { + const l = line().curve(curveCatmullRomOpen.alpha(0.5)); + assert.strictEqual(line().curve(curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("line.curve(curveCatmullRom.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var l = shape.line().curve(shape.curveCatmullRom.alpha("0.5")); - test.equal(shape.line().curve(shape.curveCatmullRom.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("line.curve(curveCatmullRomOpen.alpha(alpha)) coerces the specified alpha to a number", () => { + const l = line().curve(curveCatmullRomOpen.alpha("0.5")); + assert.strictEqual(line().curve(curveCatmullRomOpen.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), l([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCatmullRomOpen.alpha(0.5))(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveCatmullRomOpen, 0.5); - test.equal(a([]), null); - test.equal(a([[0, 1]]), null); - test.equal(a([[0, 1], [1, 3]]), null); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3L1,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1L2,0C1.666667,0,1.333333,0,1,0Z"); - test.end(); +it("area.curve(curveCatmullRomOpen.alpha(0.5))(data) generates the expected path", () => { + const a = area().curve(curveCatmullRomOpen, 0.5); + assert.strictEqual(a([]), null); + assert.strictEqual(a([[0, 1]]), null); + assert.strictEqual(a([[0, 1], [1, 3]]), null); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M1,3L1,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M1,3C1.333333,3,1.666667,1,2,1L2,0C1.666667,0,1.333333,0,1,0Z"); }); -tape("area.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", function(test) { - var a = shape.area().curve(shape.curveCatmullRomOpen, 0.5); - test.equal(shape.area().curve(shape.curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCatmullRomOpen) uses a default alpha of 0.5 (centripetal)", () => { + const a = area().curve(curveCatmullRomOpen, 0.5); + assert.strictEqual(area().curve(curveCatmullRomOpen)([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); -tape("area.curve(curveCatmullRomOpen.alpha(alpha)) coerces the specified alpha to a number", function(test) { - var a = shape.area().curve(shape.curveCatmullRomOpen.alpha("0.5")); - test.equal(shape.area().curve(shape.curveCatmullRomOpen.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); - test.end(); +it("area.curve(curveCatmullRomOpen.alpha(alpha)) coerces the specified alpha to a number", () => { + const a = area().curve(curveCatmullRomOpen.alpha("0.5")); + assert.strictEqual(area().curve(curveCatmullRomOpen.alpha(0.5))([[0, 1], [1, 3], [2, 1], [3, 3]]), a([[0, 1], [1, 3], [2, 1], [3, 3]])); }); diff --git a/test/curve/linear-test.js b/test/curve/linear-test.js index 3480dd8..e81feb4 100644 --- a/test/curve/linear-test.js +++ b/test/curve/linear-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveLinear} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveLinear)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveLinear); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3"); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5"); - test.end(); +it("line.curve(curveLinear)(data) generates the expected path", () => { + const l = line().curve(curveLinear); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3"); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5"); }); -tape("area.curve(curveLinear)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveLinear); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L2,3L2,0L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); - test.end(); +it("area.curve(curveLinear)(data) generates the expected path", () => { + const a = area().curve(curveLinear); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3]]), "M0,1L2,3L2,0L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5L4,0L2,0L0,0Z"); }); diff --git a/test/curve/linearClosed-test.js b/test/curve/linearClosed-test.js index 9312f6b..e9b5fcd 100644 --- a/test/curve/linearClosed-test.js +++ b/test/curve/linearClosed-test.js @@ -1,13 +1,11 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {line, curveLinearClosed} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveLinearClosed)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveLinearClosed); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5Z"); - test.end(); +it("line.curve(curveLinearClosed)(data) generates the expected path", () => { + const l = line().curve(curveLinearClosed); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5Z"); }); diff --git a/test/curve/monotoneX-test.js b/test/curve/monotoneX-test.js index c5efb26..0ed647f 100644 --- a/test/curve/monotoneX-test.js +++ b/test/curve/monotoneX-test.js @@ -1,56 +1,49 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveMonotoneX} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveMonotoneX)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveMonotoneX); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,2.666667,2,3,3"); - test.end(); +it("line.curve(curveMonotoneX)(data) generates the expected path", () => { + const l = line().curve(curveMonotoneX); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,2.666667,2,3,3"); }); -tape("line.curve(curveMonotoneX)(data) preserves monotonicity in y", function(test) { - var l = shape.line().curve(shape.curveMonotoneX); - test.pathEqual(l([[0, 200], [100, 100], [200, 100], [300, 300], [400, 300]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C233.333333,100,266.666667,300,300,300C333.333333,300,366.666667,300,400,300"); - test.end(); +it("line.curve(curveMonotoneX)(data) preserves monotonicity in y", () => { + const l = line().curve(curveMonotoneX); + assertPathEqual(l([[0, 200], [100, 100], [200, 100], [300, 300], [400, 300]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C233.333333,100,266.666667,300,300,300C333.333333,300,366.666667,300,400,300"); }); -tape("line.curve(curveMonotoneX)(data) handles duplicate x-values", function(test) { - var l = shape.line().curve(shape.curveMonotoneX); - test.pathEqual(l([[0, 200], [0, 100], [100, 100], [200, 0]]), "M0,200C0,200,0,100,0,100C33.333333,100,66.666667,100,100,100C133.333333,100,166.666667,50,200,0"); - test.pathEqual(l([[0, 200], [100, 100], [100, 0], [200, 0]]), "M0,200C33.333333,183.333333,66.666667,166.666667,100,100C100,100,100,0,100,0C133.333333,0,166.666667,0,200,0"); - test.pathEqual(l([[0, 200], [100, 100], [200, 100], [200, 0]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C200,100,200,0,200,0"); - test.end(); +it("line.curve(curveMonotoneX)(data) handles duplicate x-values", () => { + const l = line().curve(curveMonotoneX); + assertPathEqual(l([[0, 200], [0, 100], [100, 100], [200, 0]]), "M0,200C0,200,0,100,0,100C33.333333,100,66.666667,100,100,100C133.333333,100,166.666667,50,200,0"); + assertPathEqual(l([[0, 200], [100, 100], [100, 0], [200, 0]]), "M0,200C33.333333,183.333333,66.666667,166.666667,100,100C100,100,100,0,100,0C133.333333,0,166.666667,0,200,0"); + assertPathEqual(l([[0, 200], [100, 100], [200, 100], [200, 0]]), "M0,200C33.333333,150,66.666667,100,100,100C133.333333,100,166.666667,100,200,100C200,100,200,0,200,0"); }); -tape("line.curve(curveMonotoneX)(data) handles segments of infinite slope", function(test) { - var l = shape.line().curve(shape.curveMonotoneX); - test.pathEqual(l([[0, 200], [100, 150], [100, 50], [200, 0]]), "M0,200C33.333333,191.666667,66.666667,183.333333,100,150C100,150,100,50,100,50C133.333333,16.666667,166.666667,8.333333,200,0"); - test.pathEqual(l([[200, 0], [100, 50], [100, 150], [0, 200]]), "M200,0C166.666667,8.333333,133.333333,16.666667,100,50C100,50,100,150,100,150C66.666667,183.333333,33.333333,191.666667,0,200"); - test.end(); +it("line.curve(curveMonotoneX)(data) handles segments of infinite slope", () => { + const l = line().curve(curveMonotoneX); + assertPathEqual(l([[0, 200], [100, 150], [100, 50], [200, 0]]), "M0,200C33.333333,191.666667,66.666667,183.333333,100,150C100,150,100,50,100,50C133.333333,16.666667,166.666667,8.333333,200,0"); + assertPathEqual(l([[200, 0], [100, 50], [100, 150], [0, 200]]), "M200,0C166.666667,8.333333,133.333333,16.666667,100,50C100,50,100,150,100,150C66.666667,183.333333,33.333333,191.666667,0,200"); }); -tape("line.curve(curveMonotoneX)(data) ignores coincident points", function(test) { - var l = shape.line().curve(shape.curveMonotoneX), - p = l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]); - test.equal(l([[0, 200], [0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); - test.equal(l([[0, 200], [50, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [100, 100], [150, 0], [200, 0]]), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [150, 0], [150, 0], [200, 0]]), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0], [200, 0]]), p); - test.end(); +it("line.curve(curveMonotoneX)(data) ignores coincident points", () => { + const l = line().curve(curveMonotoneX); + const p = l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]); + assert.strictEqual(l([[0, 200], [0, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); + assert.strictEqual(l([[0, 200], [50, 200], [50, 200], [100, 100], [150, 0], [200, 0]]), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [100, 100], [150, 0], [200, 0]]), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [150, 0], [150, 0], [200, 0]]), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0], [200, 0]]), p); }); -tape("area.curve(curveMonotoneX)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveMonotoneX); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1L2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,2.666667,2,3,3L3,0C2.666667,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); - test.end(); +it("area.curve(curveMonotoneX)(data) generates the expected path", () => { + const a = area().curve(curveMonotoneX); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1L2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,1,2,1C2.333333,1,2.666667,2,3,3L3,0C2.666667,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); }); diff --git a/test/curve/monotoneY-test.js b/test/curve/monotoneY-test.js index 690252a..2aa55dd 100644 --- a/test/curve/monotoneY-test.js +++ b/test/curve/monotoneY-test.js @@ -1,58 +1,51 @@ -var tape = require("tape"), - shape = require("../../"); - -require("../pathEqual"); - -tape("line.curve(curveMonotoneY)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveMonotoneY); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]].map(reflect)), "M1,0Z"); - test.pathEqual(l([[0, 1], [1, 3]].map(reflect)), "M1,0L3,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,2,1.666667,1,2"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,1,1.666667,1,2C1,2.333333,2,2.666667,3,3"); - test.end(); +import assert from "assert"; +import {area, line, curveMonotoneY} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; + +it("line.curve(curveMonotoneY)(data) generates the expected path", () => { + const l = line().curve(curveMonotoneY); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]].map(reflect)), "M1,0Z"); + assertPathEqual(l([[0, 1], [1, 3]].map(reflect)), "M1,0L3,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,2,1.666667,1,2"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,1,1.666667,1,2C1,2.333333,2,2.666667,3,3"); }); -tape("line.curve(curveMonotoneY)(data) preserves monotonicity in y", function(test) { - var l = shape.line().curve(shape.curveMonotoneY); - test.pathEqual(l([[0, 200], [100, 100], [200, 100], [300, 300], [400, 300]].map(reflect)), "M200,0C150,33.333333,100,66.666667,100,100C100,133.333333,100,166.666667,100,200C100,233.333333,300,266.666667,300,300C300,333.333333,300,366.666667,300,400"); - test.end(); +it("line.curve(curveMonotoneY)(data) preserves monotonicity in y", () => { + const l = line().curve(curveMonotoneY); + assertPathEqual(l([[0, 200], [100, 100], [200, 100], [300, 300], [400, 300]].map(reflect)), "M200,0C150,33.333333,100,66.666667,100,100C100,133.333333,100,166.666667,100,200C100,233.333333,300,266.666667,300,300C300,333.333333,300,366.666667,300,400"); }); -tape("line.curve(curveMonotoneY)(data) handles duplicate x-values", function(test) { - var l = shape.line().curve(shape.curveMonotoneY); - test.pathEqual(l([[0, 200], [0, 100], [100, 100], [200, 0]].map(reflect)), "M200,0C200,0,100,0,100,0C100,33.333333,100,66.666667,100,100C100,133.333333,50,166.666667,0,200"); - test.pathEqual(l([[0, 200], [100, 100], [100, 0], [200, 0]].map(reflect)), "M200,0C183.333333,33.333333,166.666667,66.666667,100,100C100,100,0,100,0,100C0,133.333333,0,166.666667,0,200"); - test.pathEqual(l([[0, 200], [100, 100], [200, 100], [200, 0]].map(reflect)), "M200,0C150,33.333333,100,66.666667,100,100C100,133.333333,100,166.666667,100,200C100,200,0,200,0,200"); - test.end(); +it("line.curve(curveMonotoneY)(data) handles duplicate x-values", () => { + const l = line().curve(curveMonotoneY); + assertPathEqual(l([[0, 200], [0, 100], [100, 100], [200, 0]].map(reflect)), "M200,0C200,0,100,0,100,0C100,33.333333,100,66.666667,100,100C100,133.333333,50,166.666667,0,200"); + assertPathEqual(l([[0, 200], [100, 100], [100, 0], [200, 0]].map(reflect)), "M200,0C183.333333,33.333333,166.666667,66.666667,100,100C100,100,0,100,0,100C0,133.333333,0,166.666667,0,200"); + assertPathEqual(l([[0, 200], [100, 100], [200, 100], [200, 0]].map(reflect)), "M200,0C150,33.333333,100,66.666667,100,100C100,133.333333,100,166.666667,100,200C100,200,0,200,0,200"); }); -tape("line.curve(curveMonotoneY)(data) handles segments of infinite slope", function(test) { - var l = shape.line().curve(shape.curveMonotoneY); - test.pathEqual(l([[0, 200], [100, 150], [100, 50], [200, 0]].map(reflect)), "M200,0C191.666667,33.333333,183.333333,66.666667,150,100C150,100,50,100,50,100C16.666667,133.333333,8.333333,166.666667,0,200"); - test.pathEqual(l([[200, 0], [100, 50], [100, 150], [0, 200]].map(reflect)), "M0,200C8.333333,166.666667,16.666667,133.333333,50,100C50,100,150,100,150,100C183.333333,66.666667,191.666667,33.333333,200,0"); - test.end(); +it("line.curve(curveMonotoneY)(data) handles segments of infinite slope", () => { + const l = line().curve(curveMonotoneY); + assertPathEqual(l([[0, 200], [100, 150], [100, 50], [200, 0]].map(reflect)), "M200,0C191.666667,33.333333,183.333333,66.666667,150,100C150,100,50,100,50,100C16.666667,133.333333,8.333333,166.666667,0,200"); + assertPathEqual(l([[200, 0], [100, 50], [100, 150], [0, 200]].map(reflect)), "M0,200C8.333333,166.666667,16.666667,133.333333,50,100C50,100,150,100,150,100C183.333333,66.666667,191.666667,33.333333,200,0"); }); -tape("line.curve(curveMonotoneY)(data) ignores coincident points", function(test) { - var l = shape.line().curve(shape.curveMonotoneY), +it("line.curve(curveMonotoneY)(data) ignores coincident points", () => { + const l = line().curve(curveMonotoneY), p = l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0]].map(reflect)); - test.equal(l([[0, 200], [0, 200], [50, 200], [100, 100], [150, 0], [200, 0]].map(reflect)), p); - test.equal(l([[0, 200], [50, 200], [50, 200], [100, 100], [150, 0], [200, 0]].map(reflect)), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [100, 100], [150, 0], [200, 0]].map(reflect)), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [150, 0], [150, 0], [200, 0]].map(reflect)), p); - test.equal(l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0], [200, 0]].map(reflect)), p); - test.end(); + assert.strictEqual(l([[0, 200], [0, 200], [50, 200], [100, 100], [150, 0], [200, 0]].map(reflect)), p); + assert.strictEqual(l([[0, 200], [50, 200], [50, 200], [100, 100], [150, 0], [200, 0]].map(reflect)), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [100, 100], [150, 0], [200, 0]].map(reflect)), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [150, 0], [150, 0], [200, 0]].map(reflect)), p); + assert.strictEqual(l([[0, 200], [50, 200], [100, 100], [150, 0], [200, 0], [200, 0]].map(reflect)), p); }); -tape("area.curve(curveMonotoneY)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveMonotoneY); - test.equal(a([].map(reflect)), null); - test.pathEqual(a([[0, 1]].map(reflect)), "M1,0L1,0Z"); - test.pathEqual(a([[0, 1], [1, 3]].map(reflect)), "M1,0L3,1L3,0L1,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,2,1.666667,1,2L1,0C1,0,3,0,3,0C3,0,1,0,1,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,1,1.666667,1,2C1,2.333333,2,2.666667,3,3L3,0C3,0,1,0,1,0C1,0,3,0,3,0C3,0,1,0,1,0Z"); - test.end(); +it("area.curve(curveMonotoneY)(data) generates the expected path", () => { + const a = area().curve(curveMonotoneY); + assert.strictEqual(a([].map(reflect)), null); + assertPathEqual(a([[0, 1]].map(reflect)), "M1,0L1,0Z"); + assertPathEqual(a([[0, 1], [1, 3]].map(reflect)), "M1,0L3,1L3,0L1,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,2,1.666667,1,2L1,0C1,0,3,0,3,0C3,0,1,0,1,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]].map(reflect)), "M1,0C2,0.333333,3,0.666667,3,1C3,1.333333,1,1.666667,1,2C1,2.333333,2,2.666667,3,3L3,0C3,0,1,0,1,0C1,0,3,0,3,0C3,0,1,0,1,0Z"); }); function reflect(p) { diff --git a/test/curve/natural-test.js b/test/curve/natural-test.js index 5664b2b..46eca8d 100644 --- a/test/curve/natural-test.js +++ b/test/curve/natural-test.js @@ -1,24 +1,21 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveNatural} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveNatural)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveNatural); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1"); - test.pathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2.111111,0.666667,3.222222,1,3C1.333333,2.777778,1.666667,1.222222,2,1C2.333333,0.777778,2.666667,1.888889,3,3"); - test.end(); +it("line.curve(curveNatural)(data) generates the expected path", () => { + const l = line().curve(curveNatural); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [1, 3]]), "M0,1L1,3"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1"); + assertPathEqual(l([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2.111111,0.666667,3.222222,1,3C1.333333,2.777778,1.666667,1.222222,2,1C2.333333,0.777778,2.666667,1.888889,3,3"); }); -tape("area.curve(curveNatural)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveNatural); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1L2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); - test.pathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2.111111,0.666667,3.222222,1,3C1.333333,2.777778,1.666667,1.222222,2,1C2.333333,0.777778,2.666667,1.888889,3,3L3,0C2.666667,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); - test.end(); +it("area.curve(curveNatural)(data) generates the expected path", () => { + const a = area().curve(curveNatural); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3]]), "M0,1L1,3L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1]]), "M0,1C0.333333,2,0.666667,3,1,3C1.333333,3,1.666667,2,2,1L2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); + assertPathEqual(a([[0, 1], [1, 3], [2, 1], [3, 3]]), "M0,1C0.333333,2.111111,0.666667,3.222222,1,3C1.333333,2.777778,1.666667,1.222222,2,1C2.333333,0.777778,2.666667,1.888889,3,3L3,0C2.666667,0,2.333333,0,2,0C1.666667,0,1.333333,0,1,0C0.666667,0,0.333333,0,0,0Z"); }); diff --git a/test/curve/step-test.js b/test/curve/step-test.js index e37e681..1bb5f99 100644 --- a/test/curve/step-test.js +++ b/test/curve/step-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveStep} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveStep)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveStep); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3"); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L1,1L1,3L3,3L3,5L4,5"); - test.end(); +it("line.curve(curveStep)(data) generates the expected path", () => { + const l = line().curve(curveStep); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3"); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L1,1L1,3L3,3L3,5L4,5"); }); -tape("area.curve(curveStep)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveStep); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3L2,0L1,0L1,0L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L1,1L1,3L3,3L3,5L4,5L4,0L3,0L3,0L1,0L1,0L0,0Z"); - test.end(); +it("area.curve(curveStep)(data) generates the expected path", () => { + const a = area().curve(curveStep); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3]]), "M0,1L1,1L1,3L2,3L2,0L1,0L1,0L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L1,1L1,3L3,3L3,5L4,5L4,0L3,0L3,0L1,0L1,0L0,0Z"); }); diff --git a/test/curve/stepAfter-test.js b/test/curve/stepAfter-test.js index 8466258..51e6f89 100644 --- a/test/curve/stepAfter-test.js +++ b/test/curve/stepAfter-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveStepAfter} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveStepAfter)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveStepAfter); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,1L2,3"); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,1L2,3L4,3L4,5"); - test.end(); +it("line.curve(curveStepAfter)(data) generates the expected path", () => { + const l = line().curve(curveStepAfter); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L2,1L2,3"); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,1L2,3L4,3L4,5"); }); -tape("area.curve(curveStepAfter)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveStepAfter); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L2,1L2,3L2,0L2,0L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,1L2,3L4,3L4,5L4,0L4,0L2,0L2,0L0,0Z"); - test.end(); +it("area.curve(curveStepAfter)(data) generates the expected path", () => { + const a = area().curve(curveStepAfter); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3]]), "M0,1L2,1L2,3L2,0L2,0L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L2,1L2,3L4,3L4,5L4,0L4,0L2,0L2,0L0,0Z"); }); diff --git a/test/curve/stepBefore-test.js b/test/curve/stepBefore-test.js index 7a8470c..4518d8e 100644 --- a/test/curve/stepBefore-test.js +++ b/test/curve/stepBefore-test.js @@ -1,22 +1,19 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {area, line, curveStepBefore} from "../../src/index.js"; +import {assertPathEqual} from "../asserts.js"; -require("../pathEqual"); - -tape("line.curve(curveStepBefore)(data) generates the expected path", function(test) { - var l = shape.line().curve(shape.curveStepBefore); - test.equal(l([]), null); - test.pathEqual(l([[0, 1]]), "M0,1Z"); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L0,3L2,3"); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L0,3L2,3L2,5L4,5"); - test.end(); +it("line.curve(curveStepBefore)(data) generates the expected path", () => { + const l = line().curve(curveStepBefore); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1]]), "M0,1Z"); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L0,3L2,3"); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L0,3L2,3L2,5L4,5"); }); -tape("area.curve(curveStepBefore)(data) generates the expected path", function(test) { - var a = shape.area().curve(shape.curveStepBefore); - test.equal(a([]), null); - test.pathEqual(a([[0, 1]]), "M0,1L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3]]), "M0,1L0,3L2,3L2,0L0,0L0,0Z"); - test.pathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L0,3L2,3L2,5L4,5L4,0L2,0L2,0L0,0L0,0Z"); - test.end(); +it("area.curve(curveStepBefore)(data) generates the expected path", () => { + const a = area().curve(curveStepBefore); + assert.strictEqual(a([]), null); + assertPathEqual(a([[0, 1]]), "M0,1L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3]]), "M0,1L0,3L2,3L2,0L0,0L0,0Z"); + assertPathEqual(a([[0, 1], [2, 3], [4, 5]]), "M0,1L0,3L2,3L2,5L4,5L4,0L2,0L2,0L0,0L0,0Z"); }); diff --git a/test/inDelta.js b/test/inDelta.js deleted file mode 100644 index f3def21..0000000 --- a/test/inDelta.js +++ /dev/null @@ -1,10 +0,0 @@ -var tape = require("tape"); - -tape.Test.prototype.inDelta = function(actual, expected) { - this._assert(expected - 1e-6 < actual && actual < expected + 1e-6, { - message: "should be in delta", - operator: "inDelta", - actual: actual, - expected: expected - }); -}; diff --git a/test/line-test.js b/test/line-test.js index a26bc24..8aea99a 100644 --- a/test/line-test.js +++ b/test/line-test.js @@ -1,76 +1,65 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {line, curveLinear, curveLinearClosed} from "../src/index.js"; +import {assertPathEqual} from "./asserts.js"; -require("./pathEqual"); - -tape("line() returns a default line shape", function(test) { - var l = shape.line(); - test.equal(l.x()([42, 34]), 42); - test.equal(l.y()([42, 34]), 34); - test.equal(l.defined()([42, 34]), true); - test.equal(l.curve(), shape.curveLinear); - test.equal(l.context(), null); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5"); - test.end(); +it("line() returns a default line shape", () => { + const l = line(); + assert.strictEqual(l.x()([42, 34]), 42); + assert.strictEqual(l.y()([42, 34]), 34); + assert.strictEqual(l.defined()([42, 34]), true); + assert.strictEqual(l.curve(), curveLinear); + assert.strictEqual(l.context(), null); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,1L2,3L4,5"); }); -tape("line(x, y) sets x and y", function(test) { - var x = function() {}, y = function() {}; - test.equal(shape.line(x).x(), x); - test.equal(shape.line(x, y).y(), y); - test.equal(shape.line(3, 2).x()("aa"), 3); - test.equal(shape.line(3, 2).y()("aa"), 2); - test.end(); +it("line(x, y) sets x and y", () => { + const x = function() {}, y = function() {}; + assert.strictEqual(line(x).x(), x); + assert.strictEqual(line(x, y).y(), y); + assert.strictEqual(line(3, 2).x()("aa"), 3); + assert.strictEqual(line(3, 2).y()("aa"), 2); }); -tape("line.x(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.line().x(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); +it("line.x(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + line().x(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); }); -tape("line.y(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.line().y(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); +it("line.y(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + line().y(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); }); -tape("line.defined(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.line().defined(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); +it("line.defined(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"], actual = []; + line().defined(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); }); -tape("line.x(x)(data) observes the specified function", function(test) { - var l = shape.line().x(function(d) { return d.x; }); - test.pathEqual(l([{x: 0, 1: 1}, {x: 2, 1: 3}, {x: 4, 1: 5}]), "M0,1L2,3L4,5"); - test.end(); +it("line.x(x)(data) observes the specified function", () => { + const l = line().x(function(d) { return d.x; }); + assertPathEqual(l([{x: 0, 1: 1}, {x: 2, 1: 3}, {x: 4, 1: 5}]), "M0,1L2,3L4,5"); }); -tape("line.x(x)(data) observes the specified constant", function(test) { - var l = shape.line().x(0); - test.pathEqual(l([{1: 1}, {1: 3}, {1: 5}]), "M0,1L0,3L0,5"); - test.end(); +it("line.x(x)(data) observes the specified constant", () => { + const l = line().x(0); + assertPathEqual(l([{1: 1}, {1: 3}, {1: 5}]), "M0,1L0,3L0,5"); }); -tape("line.y(y)(data) observes the specified function", function(test) { - var l = shape.line().y(function(d) { return d.y; }); - test.pathEqual(l([{0: 0, y: 1}, {0: 2, y: 3}, {0: 4, y: 5}]), "M0,1L2,3L4,5"); - test.end(); +it("line.y(y)(data) observes the specified function", () => { + const l = line().y(function(d) { return d.y; }); + assertPathEqual(l([{0: 0, y: 1}, {0: 2, y: 3}, {0: 4, y: 5}]), "M0,1L2,3L4,5"); }); -tape("line.y(y)(data) observes the specified constant", function(test) { - var l = shape.line().y(0); - test.pathEqual(l([{0: 0}, {0: 2}, {0: 4}]), "M0,0L2,0L4,0"); - test.end(); +it("line.y(y)(data) observes the specified constant", () => { + const l = line().y(0); + assertPathEqual(l([{0: 0}, {0: 2}, {0: 4}]), "M0,0L2,0L4,0"); }); -tape("line.curve(curve) sets the curve method", function(test) { - var l = shape.line().curve(shape.curveLinearClosed); - test.equal(l([]), null); - test.pathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); - test.end(); +it("line.curve(curve) sets the curve method", () => { + const l = line().curve(curveLinearClosed); + assert.strictEqual(l([]), null); + assertPathEqual(l([[0, 1], [2, 3]]), "M0,1L2,3Z"); }); diff --git a/test/lineRadial-test.js b/test/lineRadial-test.js index 20138ca..790ba2e 100644 --- a/test/lineRadial-test.js +++ b/test/lineRadial-test.js @@ -1,15 +1,13 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {curveLinear, lineRadial} from "../src/index.js"; +import {assertPathEqual} from "./asserts.js"; -require("./pathEqual"); - -tape("lineRadial() returns a default radial line shape", function(test) { - var l = shape.lineRadial(); - test.equal(l.angle()([42, 34]), 42); - test.equal(l.radius()([42, 34]), 34); - test.equal(l.defined()([42, 34]), true); - test.equal(l.curve(), shape.curveLinear); - test.equal(l.context(), null); - test.pathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,-1L2.727892,1.248441L-3.784012,3.268218"); - test.end(); +it("lineRadial() returns a default radial line shape", () => { + const l = lineRadial(); + assert.strictEqual(l.angle()([42, 34]), 42); + assert.strictEqual(l.radius()([42, 34]), 34); + assert.strictEqual(l.defined()([42, 34]), true); + assert.strictEqual(l.curve(), curveLinear); + assert.strictEqual(l.context(), null); + assertPathEqual(l([[0, 1], [2, 3], [4, 5]]), "M0,-1L2.727892,1.248441L-3.784012,3.268218"); }); diff --git a/test/offset/diverging-test.js b/test/offset/diverging-test.js index a9a1015..2fd0384 100644 --- a/test/offset/diverging-test.js +++ b/test/offset/diverging-test.js @@ -1,90 +1,84 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOffsetDiverging, stackOrderNone, stackOrderReverse} from "../../src/index.js"; -tape("stackOffsetDiverging(series, order) applies a zero baseline, ignoring existing offsets", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) applies a zero baseline, ignoring existing offsets", () => { + const series = [ [[1, 2], [2, 4], [3, 4]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[0, 1], [0, 2], [0, 1]], [[1, 4], [2, 6], [1, 3]], [[4, 9], [6, 8], [3, 7]] ]); - test.end(); }); -tape("stackOffsetDiverging(series, order) handles a single series", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) handles a single series", () => { + const series = [ [[1, 2], [2, 4], [3, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[0, 1], [0, 2], [0, 1]] ]); - test.end(); }); -tape("stackOffsetDiverging(series, order) treats NaN as zero", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) treats NaN as zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderNone(series)); - test.ok(isNaN(series[1][1][1])); - series[1][1][1] = "NaN"; // can’t test.equal NaN - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderNone(series)); + assert(isNaN(series[1][1][1])); + series[1][1][1] = "NaN"; // can’t assert.strictEqual NaN + assert.deepStrictEqual(series, [ [[0, 1], [0, 2], [0, 1]], [[1, 4], [0, "NaN"], [1, 3]], [[4, 9], [2, 4], [3, 7]] ]); - test.end(); }); -tape("stackOffsetDiverging(series, order) observes the specified order", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) observes the specified order", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderReverse(series)); - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderReverse(series)); + assert.deepStrictEqual(series, [ [[8, 9], [6, 8], [6, 7]], [[5, 8], [2, 6], [4, 6]], [[0, 5], [0, 2], [0, 4]] ]); - test.end(); }); -tape("stackOffsetDiverging(series, order) puts negative values below zero, in order", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) puts negative values below zero, in order", () => { + const series = [ [[0, 1], [0, -2], [0, -1]], [[0, -3], [0, -4], [0, -2]], [[0, -5], [0, -2], [0, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[ 0, 1], [-2, 0], [-1, 0]], [[-3, 0], [-6, -2], [-3, -1]], [[-8, -3], [-8, -6], [ 0, 4]] ]); - test.end(); }); -tape("stackOffsetDiverging(series, order) puts zero values at zero, in order", function(test) { - var series = [ +it("stackOffsetDiverging(series, order) puts zero values at zero, in order", () => { + const series = [ [[0, 1], [0, 2], [0, -1]], [[0, 3], [0, 0], [0, 0]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetDiverging(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetDiverging(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[0, 1], [0, 2], [-1, 0]], [[1, 4], [0, 0], [0, 0]], [[4, 9], [2, 4], [0, 4]] ]); - test.end(); }); diff --git a/test/offset/expand-test.js b/test/offset/expand-test.js index 497c0c1..0330aa2 100644 --- a/test/offset/expand-test.js +++ b/test/offset/expand-test.js @@ -1,49 +1,46 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOffsetExpand, stackOrderNone, stackOrderReverse} from "../../src/index.js"; -tape("stackOffsetExpand(series, order) expands to fill [0, 1]", function(test) { - var series = [ +it("stackOffsetExpand(series, order) expands to fill [0, 1]", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetExpand(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetExpand(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[0 / 9, 1 / 9], [0 / 8, 2 / 8], [0 / 7, 1 / 7]], [[1 / 9, 4 / 9], [2 / 8, 6 / 8], [1 / 7, 3 / 7]], [[4 / 9, 9 / 9], [6 / 8, 8 / 8], [3 / 7, 7 / 7]] ]); - test.end(); }); -tape("stackOffsetExpand(series, order) treats NaN as zero", function(test) { - var series = [ +it("stackOffsetExpand(series, order) treats NaN as zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetExpand(series, shape.stackOrderNone(series)); - test.ok(isNaN(series[1][1][1])); - series[1][1][1] = "NaN"; // can’t test.equal NaN - test.deepEqual(series, [ + stackOffsetExpand(series, stackOrderNone(series)); + assert(isNaN(series[1][1][1])); + series[1][1][1] = "NaN"; // can’t assert.strictEqual NaN + assert.deepStrictEqual(series, [ [[0 / 9, 1 / 9], [0 / 4, 2 / 4], [0 / 7, 1 / 7]], [[1 / 9, 4 / 9], [2 / 4, "NaN"], [1 / 7, 3 / 7]], [[4 / 9, 9 / 9], [2 / 4, 4 / 4], [3 / 7, 7 / 7]] ]); - test.end(); }); -tape("stackOffsetExpand(series, order) observes the specified order", function(test) { - var series = [ +it("stackOffsetExpand(series, order) observes the specified order", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetExpand(series, shape.stackOrderReverse(series)); - test.deepEqual(series, [ + stackOffsetExpand(series, stackOrderReverse(series)); + assert.deepStrictEqual(series, [ [[8 / 9, 9 / 9], [6 / 8, 8 / 8], [6 / 7, 7 / 7]], [[5 / 9, 8 / 9], [2 / 8, 6 / 8], [4 / 7, 6 / 7]], [[0 / 9, 5 / 9], [0 / 8, 2 / 8], [0 / 7, 4 / 7]] ]); - test.end(); }); diff --git a/test/offset/none-test.js b/test/offset/none-test.js index 3faefb0..8381d0d 100644 --- a/test/offset/none-test.js +++ b/test/offset/none-test.js @@ -1,49 +1,46 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOffsetNone, stackOrderNone, stackOrderReverse} from "../../src/index.js"; -tape("stackOffsetNone(series, order) stacks upon the first layer’s existing positions", function(test) { - var series = [ +it("stackOffsetNone(series, order) stacks upon the first layer’s existing positions", () => { + const series = [ [[1, 2], [2, 4], [3, 4]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetNone(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetNone(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[1, 2], [2, 4], [3, 4]], [[2, 5], [4, 8], [4, 6]], [[5, 10], [8, 10], [6, 10]] ]); - test.end(); }); -tape("stackOffsetNone(series, order) treats NaN as zero", function(test) { - var series = [ +it("stackOffsetNone(series, order) treats NaN as zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetNone(series, shape.stackOrderNone(series)); - test.ok(isNaN(series[1][1][1])); - series[1][1][1] = "NaN"; // can’t test.equal NaN - test.deepEqual(series, [ + stackOffsetNone(series, stackOrderNone(series)); + assert(isNaN(series[1][1][1])); + series[1][1][1] = "NaN"; // can’t assert.strictEqual NaN + assert.deepStrictEqual(series, [ [[0, 1], [0, 2], [0, 1]], [[1, 4], [2, "NaN"], [1, 3]], [[4, 9], [2, 4], [3, 7]] ]); - test.end(); }); -tape("stackOffsetNone(series, order) observes the specified order", function(test) { - var series = [ +it("stackOffsetNone(series, order) observes the specified order", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetNone(series, shape.stackOrderReverse(series)); - test.deepEqual(series, [ + stackOffsetNone(series, stackOrderReverse(series)); + assert.deepStrictEqual(series, [ [[8, 9], [6, 8], [6, 7]], [[5, 8], [2, 6], [4, 6]], [[0, 5], [0, 2], [0, 4]] ]); - test.end(); }); diff --git a/test/offset/silhouette-test.js b/test/offset/silhouette-test.js index 5ab18bf..5031bc9 100644 --- a/test/offset/silhouette-test.js +++ b/test/offset/silhouette-test.js @@ -1,49 +1,46 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOffsetSilhouette, stackOrderNone, stackOrderReverse} from "../../src/index.js"; -tape("stackOffsetSilhouette(series, order) centers the stack around zero", function(test) { - var series = [ +it("stackOffsetSilhouette(series, order) centers the stack around zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetSilhouette(series, shape.stackOrderNone(series)); - test.deepEqual(series, [ + stackOffsetSilhouette(series, stackOrderNone(series)); + assert.deepStrictEqual(series, [ [[0 - 9 / 2, 1 - 9 / 2], [0 - 8 / 2, 2 - 8 / 2], [0 - 7 / 2, 1 - 7 / 2]], [[1 - 9 / 2, 4 - 9 / 2], [2 - 8 / 2, 6 - 8 / 2], [1 - 7 / 2, 3 - 7 / 2]], [[4 - 9 / 2, 9 - 9 / 2], [6 - 8 / 2, 8 - 8 / 2], [3 - 7 / 2, 7 - 7 / 2]] ]); - test.end(); }); -tape("stackOffsetSilhouette(series, order) treats NaN as zero", function(test) { - var series = [ +it("stackOffsetSilhouette(series, order) treats NaN as zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, NaN], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetSilhouette(series, shape.stackOrderNone(series)); - test.ok(isNaN(series[1][1][1])); - series[1][1][1] = "NaN"; // can’t test.equal NaN - test.deepEqual(series, [ + stackOffsetSilhouette(series, stackOrderNone(series)); + assert(isNaN(series[1][1][1])); + series[1][1][1] = "NaN"; // can’t assert.strictEqual NaN + assert.deepStrictEqual(series, [ [[0 - 9 / 2, 1 - 9 / 2], [0 - 4 / 2, 2 - 4 / 2], [0 - 7 / 2, 1 - 7 / 2]], [[1 - 9 / 2, 4 - 9 / 2], [2 - 4 / 2, "NaN"], [1 - 7 / 2, 3 - 7 / 2]], [[4 - 9 / 2, 9 - 9 / 2], [2 - 4 / 2, 4 - 4 / 2], [3 - 7 / 2, 7 - 7 / 2]] ]); - test.end(); }); -tape("stackOffsetSilhouette(series, order) observes the specified order", function(test) { - var series = [ +it("stackOffsetSilhouette(series, order) observes the specified order", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetSilhouette(series, shape.stackOrderReverse(series)); - test.deepEqual(series, [ + stackOffsetSilhouette(series, stackOrderReverse(series)); + assert.deepStrictEqual(series, [ [[8 - 9 / 2, 9 - 9 / 2], [6 - 8 / 2, 8 - 8 / 2], [6 - 7 / 2, 7 - 7 / 2]], [[5 - 9 / 2, 8 - 9 / 2], [2 - 8 / 2, 6 - 8 / 2], [4 - 7 / 2, 6 - 7 / 2]], [[0 - 9 / 2, 5 - 9 / 2], [0 - 8 / 2, 2 - 8 / 2], [0 - 7 / 2, 4 - 7 / 2]] ]); - test.end(); }); diff --git a/test/offset/wiggle-test.js b/test/offset/wiggle-test.js index 95d4a45..b01bdd3 100644 --- a/test/offset/wiggle-test.js +++ b/test/offset/wiggle-test.js @@ -1,55 +1,52 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOffsetWiggle, stackOrderNone, stackOrderReverse} from "../../src/index.js"; -tape("stackOffsetWiggle(series, order) minimizes weighted wiggle", function(test) { - var series = [ +it("stackOffsetWiggle(series, order) minimizes weighted wiggle", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetWiggle(series, shape.stackOrderNone(series)); - test.deepEqual(series.map(roundSeries), [ + stackOffsetWiggle(series, stackOrderNone(series)); + assert.deepStrictEqual(series.map(roundSeries), [ [[0, 1], [-1, 1], [0.7857143, 1.7857143]], [[1, 4], [ 1, 5], [1.7857143, 3.7857143]], [[4, 9], [ 5, 7], [3.7857143, 7.7857143]] ].map(roundSeries)); - test.end(); }); -tape("stackOffsetWiggle(series, order) treats NaN as zero", function(test) { - var series = [ +it("stackOffsetWiggle(series, order) treats NaN as zero", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, NaN], [0, NaN], [0, NaN]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetWiggle(series, shape.stackOrderNone(series)); - test.ok(isNaN(series[1][0][1])); - test.ok(isNaN(series[1][0][2])); - test.ok(isNaN(series[1][0][3])); - series[1][0][1] = series[1][1][1] = series[1][2][1] = "NaN"; // can’t test.equal NaN - test.deepEqual(series.map(roundSeries), [ + stackOffsetWiggle(series, stackOrderNone(series)); + assert(isNaN(series[1][0][1])); + assert(isNaN(series[1][0][2])); + assert(isNaN(series[1][0][3])); + series[1][0][1] = series[1][1][1] = series[1][2][1] = "NaN"; // can’t assert.strictEqual NaN + assert.deepStrictEqual(series.map(roundSeries), [ [[0, 1], [-1, 1], [0.7857143, 1.7857143]], [[1, "NaN"], [ 1, "NaN"], [1.7857143, "NaN"]], [[1, 4], [ 1, 5], [1.7857143, 3.7857143]], [[4, 9], [ 5, 7], [3.7857143, 7.7857143]] ].map(roundSeries)); - test.end(); }); -tape("stackOffsetWiggle(series, order) observes the specified order", function(test) { - var series = [ +it("stackOffsetWiggle(series, order) observes the specified order", () => { + const series = [ [[0, 1], [0, 2], [0, 1]], [[0, 3], [0, 4], [0, 2]], [[0, 5], [0, 2], [0, 4]] ]; - shape.stackOffsetWiggle(series, shape.stackOrderReverse(series)); - test.deepEqual(series.map(roundSeries), [ + stackOffsetWiggle(series, stackOrderReverse(series)); + assert.deepStrictEqual(series.map(roundSeries), [ [[8, 9], [8, 10], [7.21428571, 8.21428571]], [[5, 8], [4, 8], [5.21428571, 7.21428571]], [[0, 5], [2, 4], [1.21428571, 5.21428571]] ].map(roundSeries)); - test.end(); }); function roundSeries(series) { diff --git a/test/order/appearance-test.js b/test/order/appearance-test.js index 4672d5a..88e3d74 100644 --- a/test/order/appearance-test.js +++ b/test/order/appearance-test.js @@ -1,20 +1,18 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderAppearance} from "../../src/index.js"; -tape("stackOrderAppearance(series) returns an order by appearance", function(test) { - test.deepEqual(shape.stackOrderAppearance([ +it("stackOrderAppearance(series) returns an order by appearance", () => { + assert.deepStrictEqual(stackOrderAppearance([ [[0, 0], [0, 0], [0, 1]], [[0, 3], [0, 2], [0, 0]], [[0, 0], [0, 4], [0, 0]] ]), [1, 2, 0]); - test.end(); }); -tape("stackOrderAppearance(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.stackOrderAppearance([ +it("stackOrderAppearance(series) treats NaN values as zero", () => { + assert.deepStrictEqual(stackOrderAppearance([ [[0, NaN], [0, NaN], [0, 1]], [[0, 3], [0, 2], [0, NaN]], [[0, NaN], [0, 4], [0, NaN]] ]), [1, 2, 0]); - test.end(); }); diff --git a/test/order/ascending-test.js b/test/order/ascending-test.js index a85d9eb..74a4a30 100644 --- a/test/order/ascending-test.js +++ b/test/order/ascending-test.js @@ -1,20 +1,18 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderAscending} from "../../src/index.js"; -tape("stackOrderAscending(series) returns an order by sum", function(test) { - test.deepEqual(shape.stackOrderAscending([ +it("stackOrderAscending(series) returns an order by sum", () => { + assert.deepStrictEqual(stackOrderAscending([ [[0, 1], [0, 2], [0, 3]], [[0, 2], [0, 3], [0, 4]], [[0, 0], [0, 1], [0, 2]] ]), [2, 0, 1]); - test.end(); }); -tape("stackOrderAscending(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.stackOrderAscending([ +it("stackOrderAscending(series) treats NaN values as zero", () => { + assert.deepStrictEqual(stackOrderAscending([ [[0, 1], [0, 2], [0, NaN], [0, 3]], [[0, 2], [0, 3], [0, NaN], [0, 4]], [[0, 0], [0, 1], [0, NaN], [0, 2]] ]), [2, 0, 1]); - test.end(); }); diff --git a/test/order/descending-test.js b/test/order/descending-test.js index a5f5499..5793b62 100644 --- a/test/order/descending-test.js +++ b/test/order/descending-test.js @@ -1,20 +1,18 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderDescending} from "../../src/index.js"; -tape("stackOrderDescending(series) returns an order by sum", function(test) { - test.deepEqual(shape.stackOrderDescending([ +it("stackOrderDescending(series) returns an order by sum", () => { + assert.deepStrictEqual(stackOrderDescending([ [[0, 1], [0, 2], [0, 3]], [[0, 2], [0, 3], [0, 4]], [[0, 0], [0, 1], [0, 2]] ]), [1, 0, 2]); - test.end(); }); -tape("stackOrderDescending(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.stackOrderDescending([ +it("stackOrderDescending(series) treats NaN values as zero", () => { + assert.deepStrictEqual(stackOrderDescending([ [[0, 1], [0, 2], [0, 3], [0, NaN]], [[0, 2], [0, 3], [0, 4], [0, NaN]], [[0, 0], [0, 1], [0, 2], [0, NaN]] ]), [1, 0, 2]); - test.end(); }); diff --git a/test/order/insideOut-test.js b/test/order/insideOut-test.js index 9af8c65..c4ef02b 100644 --- a/test/order/insideOut-test.js +++ b/test/order/insideOut-test.js @@ -1,8 +1,8 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderInsideOut} from "../../src/index.js"; -tape("stackOrderInsideOut(series) returns an order by appearance", function(test) { - test.deepEqual(shape.stackOrderInsideOut([ +it("stackOrderInsideOut(series) returns an order by appearance", () => { + assert.deepStrictEqual(stackOrderInsideOut([ [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1]], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 2], [0, 0]], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 3], [0, 0], [0, 0]], @@ -11,11 +11,10 @@ tape("stackOrderInsideOut(series) returns an order by appearance", function(test [[0, 0], [0, 6], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]], [[0, 7], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]] ]), [2, 3, 6, 5, 4, 1, 0]); - test.end(); }); -tape("stackOrderInsideOut(series) treats NaN values as zero", function(test) { - test.deepEqual(shape.stackOrderInsideOut([ +it("stackOrderInsideOut(series) treats NaN values as zero", () => { + assert.deepStrictEqual(stackOrderInsideOut([ [[0, 0], [0, NaN], [0, 0], [0, 0], [0, 0], [0, 0], [0, 1]], [[0, 0], [0, 0], [0, NaN], [0, 0], [0, 0], [0, 2], [0, 0]], [[0, 0], [0, 0], [0, 0], [0, 0], [0, 3], [0, 0], [0, 0]], @@ -24,5 +23,4 @@ tape("stackOrderInsideOut(series) treats NaN values as zero", function(test) { [[0, NaN], [0, 6], [0, 0], [0, NaN], [0, 0], [0, 0], [0, 0]], [[0, 7], [0, NaN], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]] ]), [2, 3, 6, 5, 4, 1, 0]); - test.end(); }); diff --git a/test/order/none-test.js b/test/order/none-test.js index 2f8f9b8..4f829df 100644 --- a/test/order/none-test.js +++ b/test/order/none-test.js @@ -1,7 +1,6 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderNone} from "../../src/index.js"; -tape("stackOrderNone(series) returns [0, 1, … series.length - 1]", function(test) { - test.deepEqual(shape.stackOrderNone(new Array(4)), [0, 1, 2, 3]); - test.end(); +it("stackOrderNone(series) returns [0, 1, … series.length - 1]", () => { + assert.deepStrictEqual(stackOrderNone(new Array(4)), [0, 1, 2, 3]); }); diff --git a/test/order/reverse-test.js b/test/order/reverse-test.js index 396df3a..3a73c6a 100644 --- a/test/order/reverse-test.js +++ b/test/order/reverse-test.js @@ -1,7 +1,6 @@ -var tape = require("tape"), - shape = require("../../"); +import assert from "assert"; +import {stackOrderReverse} from "../../src/index.js"; -tape("stackOrderReverse(series) returns [series.length - 1, series.length - 2, … 0]", function(test) { - test.deepEqual(shape.stackOrderReverse(new Array(4)), [3, 2, 1, 0]); - test.end(); +it("stackOrderReverse(series) returns [series.length - 1, series.length - 2, … 0]", () => { + assert.deepStrictEqual(stackOrderReverse(new Array(4)), [3, 2, 1, 0]); }); diff --git a/test/pathEqual.js b/test/pathEqual.js deleted file mode 100644 index 1f064cf..0000000 --- a/test/pathEqual.js +++ /dev/null @@ -1,22 +0,0 @@ -var tape = require("tape"); - -var reNumber = /[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g; - -tape.Test.prototype.pathEqual = function(actual, expected) { - actual = normalizePath(actual + ""); - // expected = normalizePath(expected + ""); - this._assert(actual === expected, { - message: "should be equal", - operator: "pathEqual", - actual: actual, - expected: expected - }); -}; - -function normalizePath(path) { - return path.replace(reNumber, formatNumber); -} - -function formatNumber(s) { - return Math.abs((s = +s) - Math.round(s)) < 1e-6 ? Math.round(s) : s.toFixed(6); -} diff --git a/test/pie-test.js b/test/pie-test.js index a5db8bc..506ac41 100644 --- a/test/pie-test.js +++ b/test/pie-test.js @@ -1,219 +1,205 @@ -var tape = require("tape"), - shape = require("../"); - -tape("pie() returns a default pie shape", function(test) { - var p = shape.pie(); - test.equal(p.value()(42), 42); - test.ok(p.sortValues()(1, 2) > 0); - test.ok(p.sortValues()(2, 1) < 0); - test.equal(p.sortValues()(1, 1), 0); - test.equal(p.sort(), null); - test.equal(p.startAngle()(), 0); - test.equal(p.endAngle()(), 2 * Math.PI); - test.equal(p.padAngle()(), 0); - test.end(); -}); - -tape("pie(data) returns arcs in input order", function(test) { - var p = shape.pie(); - test.deepEqual(p([1, 3, 2]), [ +import assert from "assert"; +import {pie} from "../src/index.js"; + +it("pie() returns a default pie shape", () => { + const p = pie(); + assert.strictEqual(p.value()(42), 42); + assert(p.sortValues()(1, 2) > 0); + assert(p.sortValues()(2, 1) < 0); + assert.strictEqual(p.sortValues()(1, 1), 0); + assert.strictEqual(p.sort(), null); + assert.strictEqual(p.startAngle()(), 0); + assert.strictEqual(p.endAngle()(), 2 * Math.PI); + assert.strictEqual(p.padAngle()(), 0); +}); + +it("pie(data) returns arcs in input order", () => { + const p = pie(); + assert.deepStrictEqual(p([1, 3, 2]), [ {data: 1, value: 1, index: 2, startAngle: 5.235987755982988, endAngle: 6.283185307179585, padAngle: 0}, {data: 3, value: 3, index: 0, startAngle: 0.000000000000000, endAngle: 3.141592653589793, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 3.141592653589793, endAngle: 5.235987755982988, padAngle: 0} ]); - test.end(); }); -tape("pie(data) accepts an iterable", function(test) { - var p = shape.pie(); - test.deepEqual(p(new Set([1, 3, 2])), [ +it("pie(data) accepts an iterable", () => { + const p = pie(); + assert.deepStrictEqual(p(new Set([1, 3, 2])), [ {data: 1, value: 1, index: 2, startAngle: 5.235987755982988, endAngle: 6.283185307179585, padAngle: 0}, {data: 3, value: 3, index: 0, startAngle: 0.000000000000000, endAngle: 3.141592653589793, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 3.141592653589793, endAngle: 5.235987755982988, padAngle: 0} ]); - test.end(); }); -tape("pie(data) coerces the specified value to a number", function(test) { - var p = shape.pie(), three = {valueOf: function() { return 3; }}; - test.deepEqual(p(["1", three, "2"]), [ +it("pie(data) coerces the specified value to a number", () => { + const p = pie(); + const three = {valueOf: function() { return 3; }}; + assert.deepStrictEqual(p(["1", three, "2"]), [ {data: "1", value: 1, index: 2, startAngle: 5.235987755982988, endAngle: 6.283185307179585, padAngle: 0}, {data: three, value: 3, index: 0, startAngle: 0.000000000000000, endAngle: 3.141592653589793, padAngle: 0}, {data: "2", value: 2, index: 1, startAngle: 3.141592653589793, endAngle: 5.235987755982988, padAngle: 0} ]); - test.end(); }); -tape("pie(data) treats negative values as zero", function(test) { - var p = shape.pie(); - test.deepEqual(p([1, 0, -1]), [ +it("pie(data) treats negative values as zero", () => { + const p = pie(); + assert.deepStrictEqual(p([1, 0, -1]), [ {data: 1, value: 1, index: 0, startAngle: 0.000000000000000, endAngle: 6.283185307179586, padAngle: 0}, {data: 0, value: 0, index: 1, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0}, {data: -1, value: -1, index: 2, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0} ]); - test.end(); }); -tape("pie(data) treats NaN values as zero", function(test) { - var p = shape.pie(), - actual = p([1, NaN, undefined]), - expected = [ - {data: 1, value: 1, index: 0, startAngle: 0.000000000000000, endAngle: 6.283185307179586, padAngle: 0}, - {data: NaN, value: NaN, index: 1, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0}, - {data: undefined, value: NaN, index: 2, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0} - ]; - test.ok(isNaN(actual[1].data)); - test.ok(isNaN(actual[1].value)); - test.ok(isNaN(actual[2].value)); +it("pie(data) treats NaN values as zero", () => { + const p = pie(); + const actual = p([1, NaN, undefined]); + const expected = [ + {data: 1, value: 1, index: 0, startAngle: 0.000000000000000, endAngle: 6.283185307179586, padAngle: 0}, + {data: NaN, value: NaN, index: 1, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0}, + {data: undefined, value: NaN, index: 2, startAngle: 6.283185307179586, endAngle: 6.283185307179586, padAngle: 0} + ]; + assert(isNaN(actual[1].data)); + assert(isNaN(actual[1].value)); + assert(isNaN(actual[2].value)); actual[1].data = actual[1].value = actual[2].value = expected[1].data = expected[1].value = expected[2].value = {}; // deepEqual NaN - test.deepEqual(actual, expected); - test.end(); + assert.deepStrictEqual(actual, expected); }); -tape("pie(data) puts everything at the startAngle when the sum is zero", function(test) { - var p = shape.pie(); - test.deepEqual(p([0, 0]), [ +it("pie(data) puts everything at the startAngle when the sum is zero", () => { + const p = pie(); + assert.deepStrictEqual(p([0, 0]), [ {data: 0, value: 0, index: 0, startAngle: 0, endAngle: 0, padAngle: 0}, {data: 0, value: 0, index: 1, startAngle: 0, endAngle: 0, padAngle: 0} ]); - test.deepEqual(p.startAngle(1)([0, 0]), [ + assert.deepStrictEqual(p.startAngle(1)([0, 0]), [ {data: 0, value: 0, index: 0, startAngle: 1, endAngle: 1, padAngle: 0}, {data: 0, value: 0, index: 1, startAngle: 1, endAngle: 1, padAngle: 0} ]); - test.end(); }); -tape("pie(data) restricts |endAngle - startAngle| to τ", function(test) { - var p = shape.pie(); - test.deepEqual(p.startAngle(0).endAngle(7)([1, 2]), [ +it("pie(data) restricts |endAngle - startAngle| to τ", () => { + const p = pie(); + assert.deepStrictEqual(p.startAngle(0).endAngle(7)([1, 2]), [ {data: 1, value: 1, index: 1, startAngle: 4.1887902047863905, endAngle: 6.2831853071795860, padAngle: 0}, {data: 2, value: 2, index: 0, startAngle: 0.0000000000000000, endAngle: 4.1887902047863905, padAngle: 0} ]); - test.deepEqual(p.startAngle(7).endAngle(0)([1, 2]), [ + assert.deepStrictEqual(p.startAngle(7).endAngle(0)([1, 2]), [ {data: 1, value: 1, index: 1, startAngle: 2.8112097952136095, endAngle: 0.7168146928204142, padAngle: 0}, {data: 2, value: 2, index: 0, startAngle: 7.0000000000000000, endAngle: 2.8112097952136095, padAngle: 0} ]); - test.deepEqual(p.startAngle(1).endAngle(8)([1, 2]), [ + assert.deepStrictEqual(p.startAngle(1).endAngle(8)([1, 2]), [ {data: 1, value: 1, index: 1, startAngle: 5.1887902047863905, endAngle: 7.2831853071795860, padAngle: 0}, {data: 2, value: 2, index: 0, startAngle: 1.0000000000000000, endAngle: 5.1887902047863905, padAngle: 0} ]); - test.deepEqual(p.startAngle(8).endAngle(1)([1, 2]), [ + assert.deepStrictEqual(p.startAngle(8).endAngle(1)([1, 2]), [ {data: 1, value: 1, index: 1, startAngle: 3.8112097952136095, endAngle: 1.7168146928204142, padAngle: 0}, {data: 2, value: 2, index: 0, startAngle: 8.0000000000000000, endAngle: 3.8112097952136095, padAngle: 0} ]); - test.end(); }); -tape("pie.value(value)(data) observes the specified value function", function(test) { - test.deepEqual(shape.pie().value(function(d, i) { return i; })(new Array(3)), [ +it("pie.value(value)(data) observes the specified value function", () => { + assert.deepStrictEqual(pie().value(function(d, i) { return i; })(new Array(3)), [ {data: undefined, value: 0, index: 2, startAngle: 6.2831853071795860, endAngle: 6.2831853071795860, padAngle: 0}, {data: undefined, value: 1, index: 1, startAngle: 4.1887902047863905, endAngle: 6.2831853071795860, padAngle: 0}, {data: undefined, value: 2, index: 0, startAngle: 0.0000000000000000, endAngle: 4.1887902047863905, padAngle: 0} ]); - test.end(); }); -tape("pie.value(f)(data) passes d, i and data to the specified function f", function(test) { - var data = ["a", "b"], actual = []; - shape.pie().value(function() { actual.push([].slice.call(arguments)); })(data); - test.deepEqual(actual, [["a", 0, data], ["b", 1, data]]); - test.end(); +it("pie.value(f)(data) passes d, i and data to the specified function f", () => { + const data = ["a", "b"]; + let actual = []; + pie().value(function() { actual.push([].slice.call(arguments)); })(data); + assert.deepStrictEqual(actual, [["a", 0, data], ["b", 1, data]]); }); -tape("pie().startAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.pie().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("pie().startAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + pie().startAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("pie().startAngle(θ)(data) observes the specified start angle", function(test) { - test.deepEqual(shape.pie().startAngle(Math.PI)([1, 2, 3]), [ +it("pie().startAngle(θ)(data) observes the specified start angle", () => { + assert.deepStrictEqual(pie().startAngle(Math.PI)([1, 2, 3]), [ {data: 1, value: 1, index: 2, startAngle: 5.759586531581287, endAngle: 6.283185307179586, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 4.712388980384690, endAngle: 5.759586531581287, padAngle: 0}, {data: 3, value: 3, index: 0, startAngle: 3.141592653589793, endAngle: 4.712388980384690, padAngle: 0} ]); - test.end(); }); -tape("pie().endAngle(θ)(data) observes the specified end angle", function(test) { - test.deepEqual(shape.pie().endAngle(Math.PI)([1, 2, 3]), [ +it("pie().endAngle(θ)(data) observes the specified end angle", () => { + assert.deepStrictEqual(pie().endAngle(Math.PI)([1, 2, 3]), [ {data: 1, value: 1, index: 2, startAngle: 2.6179938779914940, endAngle: 3.1415926535897927, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 1.5707963267948966, endAngle: 2.6179938779914940, padAngle: 0}, {data: 3, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: 1.5707963267948966, padAngle: 0} ]); - test.end(); }); -tape("pie().padAngle(δ)(data) observes the specified pad angle", function(test) { - test.deepEqual(shape.pie().padAngle(0.1)([1, 2, 3]), [ +it("pie().padAngle(δ)(data) observes the specified pad angle", () => { + assert.deepStrictEqual(pie().padAngle(0.1)([1, 2, 3]), [ {data: 1, value: 1, index: 2, startAngle: 5.1859877559829880, endAngle: 6.2831853071795850, padAngle: 0.1}, {data: 2, value: 2, index: 1, startAngle: 3.0915926535897933, endAngle: 5.1859877559829880, padAngle: 0.1}, {data: 3, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: 3.0915926535897933, padAngle: 0.1} ]); - test.end(); }); -tape("pie().endAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.pie().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("pie().endAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + pie().endAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("pie().padAngle(f)(…) propagates the context and arguments to the specified function f", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.pie().padAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("pie().padAngle(f)(…) propagates the context and arguments to the specified function f", () => { + const expected = {that: {}, args: [42]}; + let actual; + pie().padAngle(function() { actual = {that: this, args: [].slice.call(arguments)}; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("pie().startAngle(θ₀).endAngle(θ₁).padAngle(δ)(data) restricts the pad angle to |θ₁ - θ₀| / data.length", function(test) { - test.deepEqual(shape.pie().startAngle(0).endAngle(Math.PI).padAngle(Infinity)([1, 2, 3]), [ +it("pie().startAngle(θ₀).endAngle(θ₁).padAngle(δ)(data) restricts the pad angle to |θ₁ - θ₀| / data.length", () => { + assert.deepStrictEqual(pie().startAngle(0).endAngle(Math.PI).padAngle(Infinity)([1, 2, 3]), [ {data: 1, value: 1, index: 2, startAngle: 2.0943951023931953, endAngle: 3.1415926535897930, padAngle: 1.0471975511965976}, {data: 2, value: 2, index: 1, startAngle: 1.0471975511965976, endAngle: 2.0943951023931953, padAngle: 1.0471975511965976}, {data: 3, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: 1.0471975511965976, padAngle: 1.0471975511965976} ]); - test.deepEqual(shape.pie().startAngle(0).endAngle(-Math.PI).padAngle(Infinity)([1, 2, 3]), [ + assert.deepStrictEqual(pie().startAngle(0).endAngle(-Math.PI).padAngle(Infinity)([1, 2, 3]), [ {data: 1, value: 1, index: 2, startAngle: -2.0943951023931953, endAngle: -3.1415926535897930, padAngle: 1.0471975511965976}, {data: 2, value: 2, index: 1, startAngle: -1.0471975511965976, endAngle: -2.0943951023931953, padAngle: 1.0471975511965976}, {data: 3, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: -1.0471975511965976, padAngle: 1.0471975511965976} ]); - test.end(); }); -tape("pie.sortValues(f) sorts arcs by value per the specified comparator function f", function(test) { - var p = shape.pie(); - test.deepEqual(p.sortValues(function(a, b) { return a - b; })([1, 3, 2]), [ +it("pie.sortValues(f) sorts arcs by value per the specified comparator function f", () => { + const p = pie(); + assert.deepStrictEqual(p.sortValues(function(a, b) { return a - b; })([1, 3, 2]), [ {data: 1, value: 1, index: 0, startAngle: 0.0000000000000000, endAngle: 1.0471975511965976, padAngle: 0}, {data: 3, value: 3, index: 2, startAngle: 3.1415926535897930, endAngle: 6.2831853071795860, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 1.0471975511965976, endAngle: 3.1415926535897930, padAngle: 0} ]); - test.deepEqual(p.sortValues(function(a, b) { return b - a; })([1, 3, 2]), [ + assert.deepStrictEqual(p.sortValues(function(a, b) { return b - a; })([1, 3, 2]), [ {data: 1, value: 1, index: 2, startAngle: 5.2359877559829880, endAngle: 6.2831853071795850, padAngle: 0}, {data: 3, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: 3.1415926535897930, padAngle: 0}, {data: 2, value: 2, index: 1, startAngle: 3.1415926535897930, endAngle: 5.2359877559829880, padAngle: 0} ]); - test.equal(p.sort(), null); - test.end(); + assert.strictEqual(p.sort(), null); }); -tape("pie.sort(f) sorts arcs by data per the specified comparator function f", function(test) { - var a = {valueOf: function() { return 1; }, name: "a"}, - b = {valueOf: function() { return 2; }, name: "b"}, - c = {valueOf: function() { return 3; }, name: "c"}, - p = shape.pie(); - test.deepEqual(p.sort(function(a, b) { return a.name.localeCompare(b.name); })([a, c, b]), [ +it("pie.sort(f) sorts arcs by data per the specified comparator function f", () => { + const a = {valueOf: function() { return 1; }, name: "a"}; + const b = {valueOf: function() { return 2; }, name: "b"}; + const c = {valueOf: function() { return 3; }, name: "c"}; + const p = pie(); + assert.deepStrictEqual(p.sort(function(a, b) { return a.name.localeCompare(b.name); })([a, c, b]), [ {data: a, value: 1, index: 0, startAngle: 0.0000000000000000, endAngle: 1.0471975511965976, padAngle: 0}, {data: c, value: 3, index: 2, startAngle: 3.1415926535897930, endAngle: 6.2831853071795860, padAngle: 0}, {data: b, value: 2, index: 1, startAngle: 1.0471975511965976, endAngle: 3.1415926535897930, padAngle: 0} ]); - test.deepEqual(p.sort(function(a, b) { return b.name.localeCompare(a.name); })([a, c, b]), [ + assert.deepStrictEqual(p.sort(function(a, b) { return b.name.localeCompare(a.name); })([a, c, b]), [ {data: a, value: 1, index: 2, startAngle: 5.2359877559829880, endAngle: 6.2831853071795850, padAngle: 0}, {data: c, value: 3, index: 0, startAngle: 0.0000000000000000, endAngle: 3.1415926535897930, padAngle: 0}, {data: b, value: 2, index: 1, startAngle: 3.1415926535897930, endAngle: 5.2359877559829880, padAngle: 0} ]); - test.equal(p.sortValues(), null); - test.end(); + assert.strictEqual(p.sortValues(), null); }); diff --git a/test/polygonContext.js b/test/polygonContext.js index d3b6a83..53e1f8a 100644 --- a/test/polygonContext.js +++ b/test/polygonContext.js @@ -1,12 +1,12 @@ -var polygon = require("d3-polygon"); +import {polygonArea} from "d3-polygon"; -module.exports = function() { +export function polygonContext() { return { points: null, - area: function() { return Math.abs(polygon.polygonArea(this.points)); }, - moveTo: function(x, y) { this.points = [[x, y]]; }, - lineTo: function(x, y) { this.points.push([x, y]); }, - rect: function(x, y, w, h) { this.points = [[x, y], [x + w, y], [x + w, y + h], [x, y + h]]; }, - closePath: function() {} + area() { return Math.abs(polygonArea(this.points)); }, + moveTo(x, y) { this.points = [[x, y]]; }, + lineTo(x, y) { this.points.push([x, y]); }, + rect(x, y, w, h) { this.points = [[x, y], [x + w, y], [x + w, y + h], [x, y + h]]; }, + closePath() {} }; -}; +} diff --git a/test/stack-test.js b/test/stack-test.js index e3ce9b0..573a92b 100644 --- a/test/stack-test.js +++ b/test/stack-test.js @@ -1,126 +1,112 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {stack, stackOffsetExpand, stackOffsetNone, stackOrderNone, stackOrderReverse} from "../src/index.js"; -tape("stack() has the expected defaults", function(test) { - var s = shape.stack(); - test.deepEqual(s.keys()(), []); - test.equal(s.value()({foo: 42}, "foo"), 42); - test.equal(s.order(), shape.stackOrderNone); - test.equal(s.offset(), shape.stackOffsetNone); - test.end(); +it("stack() has the expected defaults", () => { + const s = stack(); + assert.deepStrictEqual(s.keys()(), []); + assert.strictEqual(s.value()({foo: 42}, "foo"), 42); + assert.strictEqual(s.order(), stackOrderNone); + assert.strictEqual(s.offset(), stackOffsetNone); }); -tape("stack(data) computes the stacked series for the given data", function(test) { - var s = shape.stack().keys([0, 1, 2, 3]), - data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.deepEqual(s(data), [ +it("stack(data) computes the stacked series for the given data", () => { + const s = stack().keys([0, 1, 2, 3]); + const data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; + assert.deepStrictEqual(s(data), [ series([[0, 1], [0, 2], [0, 1]], data, 0, 0), series([[1, 4], [2, 6], [1, 3]], data, 1, 1), series([[4, 9], [6, 8], [3, 7]], data, 2, 2), series([[9, 10], [8, 11], [7, 9]], data, 3, 3) ]); - test.end(); }); -tape("stack.keys(array) sets the array of constant keys", function(test) { - var s = shape.stack().keys(["0.0", "2.0", "4.0"]); - test.deepEqual(s.keys()(), ["0.0", "2.0", "4.0"]); - test.end(); +it("stack.keys(array) sets the array of constant keys", () => { + const s = stack().keys(["0.0", "2.0", "4.0"]); + assert.deepStrictEqual(s.keys()(), ["0.0", "2.0", "4.0"]); }); -tape("stack.keys(function) sets the key accessor function", function(test) { - var s = shape.stack().keys(function() { return "abc".split(""); }); - test.deepEqual(s.keys()(), ["a", "b", "c"]); - test.end(); +it("stack.keys(function) sets the key accessor function", () => { + const s = stack().keys(function() { return "abc".split(""); }); + assert.deepStrictEqual(s.keys()(), ["a", "b", "c"]); }); -tape("stack(data, arguments…) passes the key accessor any additional arguments", function(test) { - var A, - B, - k = function(data, a, b) { A = a, B = b; return Object.keys(data[0]); }, - s = shape.stack().keys(k), - data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.deepEqual(s(data, "foo", "bar"), [ +it("stack(data, arguments…) passes the key accessor any additional arguments", () => { + let A; + let B; + let k = function(data, a, b) { A = a, B = b; return Object.keys(data[0]); }; + let s = stack().keys(k); + let data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; + assert.deepStrictEqual(s(data, "foo", "bar"), [ series([[0, 1], [0, 2], [0, 1]], data, "0", 0), series([[1, 4], [2, 6], [1, 3]], data, "1", 1), series([[4, 9], [6, 8], [3, 7]], data, "2", 2), series([[9, 10], [8, 11], [7, 9]], data, "3", 3) ]); - test.equal(A, "foo"); - test.equal(B, "bar"); - test.end(); + assert.strictEqual(A, "foo"); + assert.strictEqual(B, "bar"); }); -tape("stack.value(number) sets the constant value", function(test) { - var s = shape.stack().value("42.0"); - test.equal(s.value()(), 42); - test.end(); +it("stack.value(number) sets the constant value", () => { + const s = stack().value("42.0"); + assert.strictEqual(s.value()(), 42); }); -tape("stack.value(function) sets the value accessor function", function(test) { - var v = function() { return 42; }, - s = shape.stack().value(v); - test.equal(s.value(), v); - test.end(); +it("stack.value(function) sets the value accessor function", () => { + const v = function() { return 42; }; + const s = stack().value(v); + assert.strictEqual(s.value(), v); }); -tape("stack(data) passes the value accessor datum, key, index and data", function(test) { - var actual, - v = function(d, k, i, data) { actual = {datum: d, key: k, index: i, data: data}; return 2; }, - s = shape.stack().keys(["foo"]).value(v), - data = [{foo: 1}]; - test.deepEqual(s(data), [series([[0, 2]], data, "foo", 0)]); - test.deepEqual(actual, {datum: data[0], key: "foo", index: 0, data: data}); - test.end(); +it("stack(data) passes the value accessor datum, key, index and data", () => { + let actual; + let v = function(d, k, i, data) { actual = {datum: d, key: k, index: i, data: data}; return 2; }; + let s = stack().keys(["foo"]).value(v); + let data = [{foo: 1}]; + assert.deepStrictEqual(s(data), [series([[0, 2]], data, "foo", 0)]); + assert.deepStrictEqual(actual, {datum: data[0], key: "foo", index: 0, data: data}); }); -tape("stack(data) coerces the return value of the value accessor to a number", function(test) { - var actual, - v = function() { return "2.0"; }, - s = shape.stack().keys(["foo"]).value(v), - data = [{foo: 1}]; - test.deepEqual(s(data), [series([[0, 2]], data, "foo", 0)]); - test.end(); +it("stack(data) coerces the return value of the value accessor to a number", () => { + const v = function() { return "2.0"; }; + const s = stack().keys(["foo"]).value(v); + const data = [{foo: 1}]; + assert.deepStrictEqual(s(data), [series([[0, 2]], data, "foo", 0)]); }); -tape("stack.order(null) is equivalent to stack.order(stackOrderNone)", function(test) { - var s = shape.stack().order(null); - test.equal(s.order(), shape.stackOrderNone); - test.equal(typeof s.order(), "function"); - test.end(); +it("stack.order(null) is equivalent to stack.order(stackOrderNone)", () => { + const s = stack().order(null); + assert.strictEqual(s.order(), stackOrderNone); + assert.strictEqual(typeof s.order(), "function"); }); -tape("stack.order(function) sets the order function", function(test) { - var s = shape.stack().keys([0, 1, 2, 3]).order(shape.stackOrderReverse), - data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.equal(s.order(), shape.stackOrderReverse); - test.deepEqual(s(data), [ +it("stack.order(function) sets the order function", () => { + const s = stack().keys([0, 1, 2, 3]).order(stackOrderReverse); + const data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; + assert.strictEqual(s.order(), stackOrderReverse); + assert.deepStrictEqual(s(data), [ series([[9, 10], [9, 11], [8, 9]], data, 0, 3), series([[6, 9], [5, 9], [6, 8]], data, 1, 2), series([[1, 6], [3, 5], [2, 6]], data, 2, 1), series([[0, 1], [0, 3], [0, 2]], data, 3, 0) ]); - test.end(); }); -tape("stack.offset(null) is equivalent to stack.offset(stackOffsetNone)", function(test) { - var s = shape.stack().offset(null); - test.equal(s.offset(), shape.stackOffsetNone); - test.equal(typeof s.offset(), "function"); - test.end(); +it("stack.offset(null) is equivalent to stack.offset(stackOffsetNone)", () => { + const s = stack().offset(null); + assert.strictEqual(s.offset(), stackOffsetNone); + assert.strictEqual(typeof s.offset(), "function"); }); -tape("stack.offset(function) sets the offset function", function(test) { - var s = shape.stack().keys([0, 1, 2, 3]).offset(shape.stackOffsetExpand), - data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; - test.equal(s.offset(), shape.stackOffsetExpand); - test.deepEqual(s(data).map(roundSeries), [ +it("stack.offset(function) sets the offset function", () => { + const s = stack().keys([0, 1, 2, 3]).offset(stackOffsetExpand); + const data = [[1, 3, 5, 1], [2, 4, 2, 3], [1, 2, 4, 2]]; + assert.strictEqual(s.offset(), stackOffsetExpand); + assert.deepStrictEqual(s(data).map(roundSeries), [ [[0 / 10, 1 / 10], [0 / 11, 2 / 11], [0 / 9, 1 / 9]], [[1 / 10, 4 / 10], [2 / 11, 6 / 11], [1 / 9, 3 / 9]], [[4 / 10, 9 / 10], [6 / 11, 8 / 11], [3 / 9, 7 / 9]], [[9 / 10, 10 / 10], [8 / 11, 11 / 11], [7 / 9, 9 / 9]] ].map(roundSeries)); - test.end(); }); function series(series, data, key, index) { diff --git a/test/symbol-test.js b/test/symbol-test.js index 2a93fd7..ba5deea 100644 --- a/test/symbol-test.js +++ b/test/symbol-test.js @@ -1,150 +1,130 @@ -var tape = require("tape"), - shape = require("../"), - polygonContext = require("./polygonContext"); +import assert from "assert"; +import {symbol, symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye} from "../src/index.js"; +import {assertInDelta, assertPathEqual} from "./asserts.js"; +import {polygonContext} from "./polygonContext.js"; -require("./inDelta"); -require("./pathEqual"); - -tape("symbol() returns a default symbol shape", function(test) { - var s = shape.symbol(); - test.equal(s.type()(), shape.symbolCircle); - test.equal(s.size()(), 64); - test.equal(s.context(), null); - test.pathEqual(s(), "M4.513517,0A4.513517,4.513517,0,1,1,-4.513517,0A4.513517,4.513517,0,1,1,4.513517,0"); - test.end(); +it("symbol() returns a default symbol shape", () => { + const s = symbol(); + assert.strictEqual(s.type()(), symbolCircle); + assert.strictEqual(s.size()(), 64); + assert.strictEqual(s.context(), null); + assertPathEqual(s(), "M4.513517,0A4.513517,4.513517,0,1,1,-4.513517,0A4.513517,4.513517,0,1,1,4.513517,0"); }); -tape("symbol().size(f)(…) propagates the context and arguments to the specified function", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.symbol().size(function() { actual = {that: this, args: [].slice.call(arguments)}; return 64; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("symbol().size(f)(…) propagates the context and arguments to the specified function", () => { + const expected = {that: {}, args: [42]}; + let actual; + symbol().size(function() { actual = {that: this, args: [].slice.call(arguments)}; return 64; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("symbol().type(f)(…) propagates the context and arguments to the specified function", function(test) { - var expected = {that: {}, args: [42]}, actual; - shape.symbol().type(function() { actual = {that: this, args: [].slice.call(arguments)}; return shape.symbolCircle; }).apply(expected.that, expected.args); - test.deepEqual(actual, expected); - test.end(); +it("symbol().type(f)(…) propagates the context and arguments to the specified function", () => { + const expected = {that: {}, args: [42]}; + let actual; + symbol().type(function() { actual = {that: this, args: [].slice.call(arguments)}; return symbolCircle; }).apply(expected.that, expected.args); + assert.deepStrictEqual(actual, expected); }); -tape("symbol.size(size) observes the specified size function", function(test) { - var size = function(d, i) { return d.z * 2 + i; }, - s = shape.symbol().size(size); - test.equal(s.size(), size); - test.pathEqual(s({z: 0}, 0), "M0,0"); - test.pathEqual(s({z: Math.PI / 2}, 0), "M1,0A1,1,0,1,1,-1,0A1,1,0,1,1,1,0"); - test.pathEqual(s({z: 2 * Math.PI}, 0), "M2,0A2,2,0,1,1,-2,0A2,2,0,1,1,2,0"); - test.pathEqual(s({z: Math.PI}, 1), "M1.522600,0A1.522600,1.522600,0,1,1,-1.522600,0A1.522600,1.522600,0,1,1,1.522600,0"); - test.pathEqual(s({z: 4 * Math.PI}, 2), "M2.938813,0A2.938813,2.938813,0,1,1,-2.938813,0A2.938813,2.938813,0,1,1,2.938813,0"); - test.end(); +it("symbol.size(size) observes the specified size function", () => { + const size = function(d, i) { return d.z * 2 + i; }, + s = symbol().size(size); + assert.strictEqual(s.size(), size); + assertPathEqual(s({z: 0}, 0), "M0,0"); + assertPathEqual(s({z: Math.PI / 2}, 0), "M1,0A1,1,0,1,1,-1,0A1,1,0,1,1,1,0"); + assertPathEqual(s({z: 2 * Math.PI}, 0), "M2,0A2,2,0,1,1,-2,0A2,2,0,1,1,2,0"); + assertPathEqual(s({z: Math.PI}, 1), "M1.522600,0A1.522600,1.522600,0,1,1,-1.522600,0A1.522600,1.522600,0,1,1,1.522600,0"); + assertPathEqual(s({z: 4 * Math.PI}, 2), "M2.938813,0A2.938813,2.938813,0,1,1,-2.938813,0A2.938813,2.938813,0,1,1,2.938813,0"); }); -tape("symbol.size(size) observes the specified size constant", function(test) { - var s = shape.symbol(); - test.equal(s.size(42).size()(), 42); - test.pathEqual(s.size(0)(), "M0,0"); - test.pathEqual(s.size(Math.PI)(), "M1,0A1,1,0,1,1,-1,0A1,1,0,1,1,1,0"); - test.pathEqual(s.size(4 * Math.PI)(), "M2,0A2,2,0,1,1,-2,0A2,2,0,1,1,2,0"); - test.end(); +it("symbol.size(size) observes the specified size constant", () => { + const s = symbol(); + assert.strictEqual(s.size(42).size()(), 42); + assertPathEqual(s.size(0)(), "M0,0"); + assertPathEqual(s.size(Math.PI)(), "M1,0A1,1,0,1,1,-1,0A1,1,0,1,1,1,0"); + assertPathEqual(s.size(4 * Math.PI)(), "M2,0A2,2,0,1,1,-2,0A2,2,0,1,1,2,0"); }); -tape("symbol.type(symbolCircle) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolCircle).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0"); - test.pathEqual(s(20), "M2.523133,0A2.523133,2.523133,0,1,1,-2.523133,0A2.523133,2.523133,0,1,1,2.523133,0"); - test.end(); +it("symbol.type(symbolCircle) generates the expected path", () => { + const s = symbol().type(symbolCircle).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0"); + assertPathEqual(s(20), "M2.523133,0A2.523133,2.523133,0,1,1,-2.523133,0A2.523133,2.523133,0,1,1,2.523133,0"); }); -tape("symbol.type(symbolCross) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolCross).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolCross) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolCross).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolCross) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolCross).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); - test.pathEqual(s(20), "M-3,-1L-1,-1L-1,-3L1,-3L1,-1L3,-1L3,1L1,1L1,3L-1,3L-1,1L-3,1Z"); - test.end(); +it("symbol.type(symbolCross) generates the expected path", () => { + const s = symbol().type(symbolCross).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); + assertPathEqual(s(20), "M-3,-1L-1,-1L-1,-3L1,-3L1,-1L3,-1L3,1L1,1L1,3L-1,3L-1,1L-3,1Z"); }); -tape("symbol.type(symbolDiamond) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolDiamond).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolDiamond) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolDiamond).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolDiamond) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolDiamond).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0L0,0L0,0L0,0Z"); - test.pathEqual(s(10), "M0,-2.942831L1.699044,0L0,2.942831L-1.699044,0Z"); - test.end(); +it("symbol.type(symbolDiamond) generates the expected path", () => { + const s = symbol().type(symbolDiamond).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0L0,0L0,0L0,0Z"); + assertPathEqual(s(10), "M0,-2.942831L1.699044,0L0,2.942831L-1.699044,0Z"); }); -tape("symbol.type(symbolStar) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolStar).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolStar) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolStar).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolStar) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolStar).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); - test.pathEqual(s(10), "M0,-2.984649L0.670095,-0.922307L2.838570,-0.922307L1.084237,0.352290L1.754333,2.414632L0,1.140035L-1.754333,2.414632L-1.084237,0.352290L-2.838570,-0.922307L-0.670095,-0.922307Z"); - test.end(); +it("symbol.type(symbolStar) generates the expected path", () => { + const s = symbol().type(symbolStar).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); + assertPathEqual(s(10), "M0,-2.984649L0.670095,-0.922307L2.838570,-0.922307L1.084237,0.352290L1.754333,2.414632L0,1.140035L-1.754333,2.414632L-1.084237,0.352290L-2.838570,-0.922307L-0.670095,-0.922307Z"); }); -tape("symbol.type(symbolSquare) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolSquare).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolSquare) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolSquare).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolSquare) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolSquare).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0h0v0h0Z"); - test.pathEqual(s(4), "M-1,-1h2v2h-2Z"); - test.pathEqual(s(16), "M-2,-2h4v4h-4Z"); - test.end(); +it("symbol.type(symbolSquare) generates the expected path", () => { + const s = symbol().type(symbolSquare).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0h0v0h0Z"); + assertPathEqual(s(4), "M-1,-1h2v2h-2Z"); + assertPathEqual(s(16), "M-2,-2h4v4h-4Z"); }); -tape("symbol.type(symbolTriangle) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolTriangle).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolTriangle) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolTriangle).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolTriangle) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolTriangle).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0L0,0L0,0Z"); - test.pathEqual(s(10), "M0,-2.774528L2.402811,1.387264L-2.402811,1.387264Z"); - test.end(); +it("symbol.type(symbolTriangle) generates the expected path", () => { + const s = symbol().type(symbolTriangle).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0L0,0L0,0Z"); + assertPathEqual(s(10), "M0,-2.774528L2.402811,1.387264L-2.402811,1.387264Z"); }); -tape("symbol.type(symbolWye) generates a polygon with the specified size", function(test) { - var p = polygonContext(), s = shape.symbol().type(shape.symbolWye).context(p); - s.size(1)(); test.inDelta(p.area(), 1); - s.size(240)(); test.inDelta(p.area(), 240); - test.end(); +it("symbol.type(symbolWye) generates a polygon with the specified size", () => { + const p = polygonContext(), s = symbol().type(symbolWye).context(p); + s.size(1)(); assertInDelta(p.area(), 1); + s.size(240)(); assertInDelta(p.area(), 240); }); -tape("symbol.type(symbolWye) generates the expected path", function(test) { - var s = shape.symbol().type(shape.symbolWye).size(function(d) { return d; }); - test.pathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); - test.pathEqual(s(10), "M0.853360,0.492688L0.853360,2.199408L-0.853360,2.199408L-0.853360,0.492688L-2.331423,-0.360672L-1.478063,-1.838735L0,-0.985375L1.478063,-1.838735L2.331423,-0.360672Z"); - test.end(); +it("symbol.type(symbolWye) generates the expected path", () => { + const s = symbol().type(symbolWye).size(function(d) { return d; }); + assertPathEqual(s(0), "M0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0L0,0Z"); + assertPathEqual(s(10), "M0.853360,0.492688L0.853360,2.199408L-0.853360,2.199408L-0.853360,0.492688L-2.331423,-0.360672L-1.478063,-1.838735L0,-0.985375L1.478063,-1.838735L2.331423,-0.360672Z"); }); -tape("symbol(type, size) is equivalent to symbol().type(type).size(size)", function(test) { - var s0 = shape.symbol().type(shape.symbolCross).size(16), - s1 = shape.symbol(shape.symbolCross, 16); - test.equal(s0(), s1()); - test.end(); +it("symbol(type, size) is equivalent to symbol().type(type).size(size)", () => { + const s0 = symbol().type(symbolCross).size(16); + const s1 = symbol(symbolCross, 16); + assert.strictEqual(s0(), s1()); }); - diff --git a/test/symbols-test.js b/test/symbols-test.js index 16a7790..3c66cf7 100644 --- a/test/symbols-test.js +++ b/test/symbols-test.js @@ -1,15 +1,14 @@ -var tape = require("tape"), - shape = require("../"); +import assert from "assert"; +import {symbols, symbolCircle, symbolCross, symbolDiamond, symbolSquare, symbolStar, symbolTriangle, symbolWye} from "../src/index.js"; -tape("symbols is the array of symbol types", function(test) { - test.deepEqual(shape.symbols, [ - shape.symbolCircle, - shape.symbolCross, - shape.symbolDiamond, - shape.symbolSquare, - shape.symbolStar, - shape.symbolTriangle, - shape.symbolWye +it("symbols is the array of symbol types", () => { + assert.deepStrictEqual(symbols, [ + symbolCircle, + symbolCross, + symbolDiamond, + symbolSquare, + symbolStar, + symbolTriangle, + symbolWye ]); - test.end(); }); diff --git a/yarn.lock b/yarn.lock index 0ffb952..1265550 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,24 +16,24 @@ 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.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.1.tgz#442763b88cecbe3ee0ec7ca6d6dd6168550cbf14" + integrity sha512-5v7TDE9plVhvxQeWLXDTvFvJBdH6pEsdnl2g/dAptmuFEPedQ4Erq5rsDsX+mvAM610IhNaO2W5V1dOOnDKxkQ== dependencies: ajv "^6.12.4" debug "^4.1.1" @@ -46,9 +46,14 @@ strip-json-comments "^3.1.1" "@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== + +"@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== acorn-jsx@^5.3.1: version "5.3.1" @@ -70,21 +75,26 @@ ajv@^6.10.0, 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" @@ -104,6 +114,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" @@ -111,15 +129,25 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +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" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== 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= + version "1.0.2" + 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" @@ -129,24 +157,33 @@ 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-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" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== -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== +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" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -157,13 +194,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" @@ -207,51 +268,37 @@ cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" -"d3-path@1 - 2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-2.0.0.tgz#55d86ac131a0548adae241eebfb56b4582dd09d8" - integrity sha512-ZwZQxKhBnv9yHaiWd6ZU4x5BtCQ7pXszEV9CU6kRgwIQVQGLMv1oiL4M+MK/n79sYzsj+gcgpPQSctJUsLN7fA== +"d3-path@1 - 3": + version "3.0.0" + resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-3.0.0.tgz#f1c26531bd3959e27512d9036840714864eb4888" + integrity sha512-N23RTlR6WckG/pWFbCX2f7VGFIkxGDRQ032LsIbY3QGj9Q9XLW1xq6B4fNLegvIICkFsuhBwoBMQYJSKlHK2lQ== -"d3-polygon@1 - 2": - version "2.0.0" - resolved "https://registry.yarnpkg.com/d3-polygon/-/d3-polygon-2.0.0.tgz#13608ef042fbec625ba1598327564f03c0396d8e" - integrity sha512-MsexrCK38cTGermELs0cO1d79DcTsQRN7IWMJKczD/2kBjzNXxLUWP33qRF6VDpiLV/4EI4r6Gs0DAWQkE8pSQ== +"d3-polygon@1 - 3": + version "3.0.0" + resolved "https://registry.yarnpkg.com/d3-polygon/-/d3-polygon-3.0.0.tgz#f23953af70699cfb3f5251afc4cb0cd9f69a801f" + integrity sha512-9ab4zICyHynjn/mrB/K579RfP8uwX8sleisNVAt6riH9rhdMXAykhGNHKLSp6AWiJs4VsM45hH49AHgLdPJjOQ== -debug@^4.0.1, debug@^4.1.1: +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" -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" +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== deep-is@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= -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= +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" @@ -260,13 +307,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -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" - emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -279,36 +319,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" @@ -336,33 +355,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.27.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.27.0.tgz#665a1506d8f95655c9274d84bd78f7166b07e9c7" + integrity sha512-JZuR6La2ZF0UD384lcbnd0Cgg6QJjiCwhMD6eU4h/VGPcVGwawNNzKU41tgokGXnfjOOyI6QIffthhJTPzzuRA== dependencies: "@babel/code-frame" "7.12.11" - "@eslint/eslintrc" "^0.4.0" + "@eslint/eslintrc" "^0.4.1" 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" + globals "^13.6.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" @@ -370,7 +391,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" @@ -379,7 +400,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" @@ -426,7 +447,7 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -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== @@ -448,6 +469,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" @@ -456,18 +492,16 @@ 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" - fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -478,33 +512,24 @@ 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: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - functional-red-black-tree@^1.0.1: version "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" +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.0.0, 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== @@ -516,6 +541,18 @@ glob@^7.1.3, glob@~7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" +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: + 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" + globals@^12.1.0: version "12.4.0" resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" @@ -523,10 +560,17 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" -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== +globals@^13.6.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: + type-fest "^0.20.2" + +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" @@ -538,17 +582,10 @@ 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: - 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== ignore@^4.0.6: version "4.0.6" @@ -576,93 +613,49 @@ 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== -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== - -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== - -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== + binary-extensions "^2.0.0" 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== dependencies: is-extglob "^2.1.1" -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-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== isexe@^2.0.0: version "2.0.0" @@ -683,6 +676,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" @@ -714,10 +714,34 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -lodash@^4.17.20: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== +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= + +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" @@ -731,60 +755,68 @@ 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== -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= -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" +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== once@^1.3.0: version "1.4.0" @@ -805,6 +837,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" @@ -812,6 +858,11 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" +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" @@ -822,10 +873,10 @@ path-key@^3.1.0: resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" 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== +picomatch@^2.0.4, picomatch@^2.2.1: + 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" @@ -849,19 +900,23 @@ 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== +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" resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" @@ -872,20 +927,6 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -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" @@ -904,9 +945,9 @@ 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" @@ -916,12 +957,19 @@ safe-buffer@^5.1.0: integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== 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" @@ -973,7 +1021,15 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -string-width@^4.2.0: +"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.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== @@ -982,30 +1038,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" @@ -1014,11 +1052,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" @@ -1033,41 +1078,22 @@ supports-color@^7.0.0, supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -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@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" @@ -1078,10 +1104,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= +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: + is-number "^7.0.0" type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -1090,21 +1118,16 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.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== + 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" - uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -1117,35 +1140,88 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== -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: 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= +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==