From 19f70fa452a34e21d6b3450d9b0e6dbedc7d2b5c Mon Sep 17 00:00:00 2001 From: Curran Kelleher Date: Wed, 17 Jun 2020 10:58:44 -0400 Subject: [PATCH 1/3] Expose pad from linear. --- src/linear.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/linear.js b/src/linear.js index b91f712..df80e32 100644 --- a/src/linear.js +++ b/src/linear.js @@ -70,3 +70,8 @@ export default function linear() { return linearish(scale); } + +export function pad([x0, x1], k) { + const dx = (x1 - x0) * k / 2; + return [x0 - dx, x1 + dx]; +} From b8bdb34efde3ae76093cd9b1dc61368b43dd1e7b Mon Sep 17 00:00:00 2001 From: Curran Date: Wed, 17 Jun 2020 11:09:09 -0400 Subject: [PATCH 2/3] Expose padLinear, add tests --- src/index.js | 3 ++- src/linear.js | 2 +- test/linear-test.js | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 510103c..ba317c7 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,8 @@ export { } from "./identity.js"; export { - default as scaleLinear + default as scaleLinear, + pad as padLinear } from "./linear.js"; export { diff --git a/src/linear.js b/src/linear.js index df80e32..d52efca 100644 --- a/src/linear.js +++ b/src/linear.js @@ -72,6 +72,6 @@ export default function linear() { } export function pad([x0, x1], k) { - const dx = (x1 - x0) * k / 2; + var dx = (x1 - x0) * k / 2; return [x0 - dx, x1 + dx]; } diff --git a/test/linear-test.js b/test/linear-test.js index 62de558..5d1d57b 100644 --- a/test/linear-test.js +++ b/test/linear-test.js @@ -509,3 +509,9 @@ tape("linear.copy() returns a copy with changes to the unknown value are isolate test.equal(x.unknown(), 2); test.end(); }); + +tape.only("padLinear returns a padded domain array", function(test) { + test.deepEqual(scale.padLinear([0, 8], 0.5), [-2, 10]) + test.deepEqual(scale.padLinear([0, 8], 0.25), [-1, 9]) + test.end(); +}); From 662820d9801345565471efaa17b45cc947763964 Mon Sep 17 00:00:00 2001 From: Curran Date: Wed, 17 Jun 2020 11:14:19 -0400 Subject: [PATCH 3/3] Bring back all tests. --- test/linear-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linear-test.js b/test/linear-test.js index 5d1d57b..e239552 100644 --- a/test/linear-test.js +++ b/test/linear-test.js @@ -510,7 +510,7 @@ tape("linear.copy() returns a copy with changes to the unknown value are isolate test.end(); }); -tape.only("padLinear returns a padded domain array", function(test) { +tape("padLinear returns a padded domain array", function(test) { test.deepEqual(scale.padLinear([0, 8], 0.5), [-2, 10]) test.deepEqual(scale.padLinear([0, 8], 0.25), [-1, 9]) test.end();