Skip to content

Commit

Permalink
Update dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 22, 2020
1 parent 4b25ce4 commit 0870205
Show file tree
Hide file tree
Showing 45 changed files with 2,214 additions and 2,555 deletions.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@
],
"scripts": {
"pretest": "rollup -c",
"test": "tape 'test/**/*-test.js' && eslint src",
"test": "./test/run.sh",
"prepublishOnly": "rm -rf dist && yarn test",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
},
"sideEffects": false,
"devDependencies": {
"eslint": "6",
"jsdom": "15",
"rollup": "1",
"rollup-plugin-terser": "5",
"seedrandom": "2",
"tape": "4"
"d3-random": "2",
"eslint": "7",
"jsdom": "16",
"rollup": "2",
"rollup-plugin-terser": "7",
"tape": "4",
"tape-await": "0.1"
}
}
44 changes: 20 additions & 24 deletions test/ascending-test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
var tape = require("tape"),
arrays = require("../");
const tape = require("tape-await");
const d3 = require("../");

require("./isNaN");

tape("ascending(a, b) returns a negative number if a < b", function(test) {
test.ok(arrays.ascending(0, 1) < 0);
test.ok(arrays.ascending("a", "b") < 0);
test.end();
tape("ascending(a, b) returns a negative number if a < b", (test) => {
test.ok(d3.ascending(0, 1) < 0);
test.ok(d3.ascending("a", "b") < 0);
});

tape("ascending(a, b) returns a positive number if a > b", function(test) {
test.ok(arrays.ascending(1, 0) > 0);
test.ok(arrays.ascending("b", "a") > 0);
test.end();
tape("ascending(a, b) returns a positive number if a > b", (test) => {
test.ok(d3.ascending(1, 0) > 0);
test.ok(d3.ascending("b", "a") > 0);
});

tape("ascending(a, b) returns zero if a >= b and a <= b", function(test) {
test.equal(arrays.ascending(0, 0), 0);
test.equal(arrays.ascending("a", "a"), 0);
test.equal(arrays.ascending("0", 0), 0);
test.equal(arrays.ascending(0, "0"), 0);
test.end();
tape("ascending(a, b) returns zero if a >= b and a <= b", (test) => {
test.equal(d3.ascending(0, 0), 0);
test.equal(d3.ascending("a", "a"), 0);
test.equal(d3.ascending("0", 0), 0);
test.equal(d3.ascending(0, "0"), 0);
});

tape("ascending(a, b) returns NaN if a and b are not comparable", function(test) {
test.isNaN(arrays.ascending(0, undefined));
test.isNaN(arrays.ascending(undefined, 0));
test.isNaN(arrays.ascending(undefined, undefined));
test.isNaN(arrays.ascending(0, NaN));
test.isNaN(arrays.ascending(NaN, 0));
test.isNaN(arrays.ascending(NaN, NaN));
test.end();
tape("ascending(a, b) returns NaN if a and b are not comparable", (test) => {
test.isNaN(d3.ascending(0, undefined));
test.isNaN(d3.ascending(undefined, 0));
test.isNaN(d3.ascending(undefined, undefined));
test.isNaN(d3.ascending(0, NaN));
test.isNaN(d3.ascending(NaN, 0));
test.isNaN(d3.ascending(NaN, NaN));
});
91 changes: 39 additions & 52 deletions test/bin-test.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,73 @@
var tape = require("tape"),
arrays = require("../");
const tape = require("tape-await");
const d3 = require("../");

tape("histogram is a deprecated alias for bin", function(test) {
test.strictEqual(arrays.histogram, arrays.bin);
test.end();
tape("histogram is a deprecated alias for bin", (test) => {
test.strictEqual(d3.histogram, d3.bin);
});

tape("bin() returns a default bin generator", function(test) {
var h = arrays.bin();
tape("bin() returns a default bin generator", (test) => {
const h = d3.bin();
test.equal(h.value()(42), 42);
test.equal(h.domain(), arrays.extent);
test.deepEqual(h.thresholds(), arrays.thresholdSturges);
test.end();
test.equal(h.domain(), d3.extent);
test.deepEqual(h.thresholds(), d3.thresholdSturges);
});

tape("bin(data) computes bins of the specified array of data", function(test) {
var h = arrays.bin();
tape("bin(data) computes bins of the specified array of data", (test) => {
const h = d3.bin();
test.deepEqual(h([0, 0, 0, 10, 20, 20]), [
bin([0, 0, 0], 0, 5),
bin([], 5, 10),
bin([10], 10, 15),
bin([20, 20], 15, 20) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin(iterable) is equivalent to bin(array)", function(test) {
var h = arrays.bin();
tape("bin(iterable) is equivalent to bin(array)", (test) => {
const h = d3.bin();
test.deepEqual(h(iterable([0, 0, 0, 10, 20, 20])), [
bin([0, 0, 0], 0, 5),
bin([], 5, 10),
bin([10], 10, 15),
bin([20, 20], 15, 20) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin.value(number) sets the constant value", function(test) {
var h = arrays.bin().value(12); // Pointless, but for consistency.
tape("bin.value(number) sets the constant value", (test) => {
const h = d3.bin().value(12); // Pointless, but for consistency.
test.deepEqual(h([0, 0, 0, 1, 2, 2]), [
bin([0, 0, 0, 1, 2, 2], 12, 12),
]);
test.end();
});

tape("bin.value(function) sets the value accessor", function(test) {
var h = arrays.bin().value(function(d) { return d.value; }),
a = {value: 0},
b = {value: 10},
c = {value: 20};
tape("bin.value(function) sets the value accessor", (test) => {
const h = d3.bin().value((d) => d.value);
const a = {value: 0};
const b = {value: 10};
const c = {value: 20};
test.deepEqual(h([a, a, a, b, c, c]), [
bin([a, a, a], 0, 5),
bin([], 5, 10),
bin([b], 10, 15),
bin([c, c], 15, 20)
]);
test.end();
});

tape("bin.domain(array) sets the domain", function(test) {
var h = arrays.bin().domain([0, 20]);
tape("bin.domain(array) sets the domain", (test) => {
const h = d3.bin().domain([0, 20]);
test.deepEqual(h.domain()(), [0, 20]);
test.deepEqual(h([1, 2, 2, 10, 18, 18]), [
bin([1, 2, 2], 0, 5),
bin([], 5, 10),
bin([10], 10, 15),
bin([18, 18], 15, 20)
]);
test.end();
});

tape("bin.domain(function) sets the domain accessor", function(test) {
var values = [1, 2, 2, 10, 18, 18],
actual,
domain = function(values) { actual = values; return [0, 20]; },
h = arrays.bin().domain(domain);
tape("bin.domain(function) sets the domain accessor", (test) => {
let actual;
const values = [1, 2, 2, 10, 18, 18];
const domain = (values) => { actual = values; return [0, 20]; };
const h = d3.bin().domain(domain);
test.equal(h.domain(), domain);
test.deepEqual(h(values), [
bin([1, 2, 2], 0, 5),
Expand All @@ -83,71 +76,65 @@ tape("bin.domain(function) sets the domain accessor", function(test) {
bin([18, 18], 15, 20)
]);
test.deepEqual(actual, values);
test.end();
});

tape("bin.thresholds(number) sets the approximate number of bin thresholds", function(test) {
var h = arrays.bin().thresholds(3);
tape("bin.thresholds(number) sets the approximate number of bin thresholds", (test) => {
const h = d3.bin().thresholds(3);
test.deepEqual(h([0, 0, 0, 10, 30, 30]), [
bin([0, 0, 0], 0, 10),
bin([10], 10, 20),
bin([30, 30], 20, 30) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin.thresholds(array) sets the bin thresholds", function(test) {
var h = arrays.bin().thresholds([10, 20]);
tape("bin.thresholds(array) sets the bin thresholds", (test) => {
const h = d3.bin().thresholds([10, 20]);
test.deepEqual(h([0, 0, 0, 10, 30, 30]), [
bin([0, 0, 0], 0, 10),
bin([10], 10, 20),
bin([30, 30], 20, 30) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin.thresholds(array) ignores thresholds outside the domain", function(test) {
var h = arrays.bin().thresholds([0, 1, 2, 3]);
tape("bin.thresholds(array) ignores thresholds outside the domain", (test) => {
const h = d3.bin().thresholds([0, 1, 2, 3]);
test.deepEqual(h([0, 1, 2, 3]), [
bin([0], 0, 1),
bin([1], 1, 2),
bin([2], 2, 3),
bin([3], 3, 3) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin.thresholds(function) sets the bin thresholds accessor", function(test) {
var actual,
values = [0, 0, 0, 10, 30, 30],
h = arrays.bin().thresholds(function(values, x0, x1) { actual = [values, x0, x1]; return [10, 20]; });
tape("bin.thresholds(function) sets the bin thresholds accessor", (test) => {
let actual;
const values = [0, 0, 0, 10, 30, 30];
const h = d3.bin().thresholds((values, x0, x1) => { actual = [values, x0, x1]; return [10, 20]; });
test.deepEqual(h(values), [
bin([0, 0, 0], 0, 10),
bin([10], 10, 20),
bin([30, 30], 20, 30) // Note: inclusive upper bound for last bin.
]);
test.deepEqual(actual, [values, 0, 30]);
test.deepEqual(h.thresholds(function() { return 5; })(values), [
test.deepEqual(h.thresholds(() => 5)(values), [
bin([0, 0, 0], 0, 5),
bin([], 5, 10),
bin([10], 10, 15),
bin([], 15, 20),
bin([], 20, 25),
bin([30, 30], 25, 30) // Note: inclusive upper bound for last bin.
]);
test.end();
});

tape("bin()() returns bins whose rightmost bin is not too wide", function(test) {
var h = arrays.bin();
tape("bin()() returns bins whose rightmost bin is not too wide", (test) => {
const h = d3.bin();
test.deepEqual(h([9.8, 10, 11, 12, 13, 13.2]), [
bin([9.8], 9.8, 10),
bin([10], 10, 11),
bin([11], 11, 12),
bin([12], 12, 13),
bin([13, 13.2], 13, 13.2),
]);
test.end();
});

function bin(bin, x0, x1) {
Expand Down
Loading

0 comments on commit 0870205

Please sign in to comment.