@plotdb/chart 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/CHANGELOG.md +0 -29
- package/build +0 -45
- package/doc/charts.md +0 -58
- package/doc/config.md +0 -44
- package/doc/draft/chart.md +0 -146
- package/doc/draft/data.md +0 -8
- package/doc/draft/definition.md +0 -0
- package/doc/draft/events.md +0 -0
- package/doc/draft/filter.md +0 -0
- package/doc/draft/lifecycle.md +0 -89
- package/doc/spec.md +0 -89
- package/doc/todo.md +0 -27
- package/doc/utils/tip.md +0 -84
- package/src/data/en-US/category +0 -20
- package/src/data/en-US/fruit +0 -39
- package/src/data/en-US/movie +0 -125
- package/src/data/en-US/name +0 -58
- package/src/data/index.ls +0 -34
- package/src/data/zh-TW/category +0 -20
- package/src/data/zh-TW/fruits +0 -38
- package/src/data/zh-TW/movie +0 -125
- package/src/data/zh-TW/names +0 -105
- package/src/index.ls +0 -323
- package/src/index.styl +0 -6
- package/src/utils/axis.ls +0 -229
- package/src/utils/config.ls +0 -11
- package/src/utils/data.ls +0 -104
- package/src/utils/format.ls +0 -30
- package/src/utils/legend.ls +0 -134
- package/src/utils/legend.styl +0 -37
- package/src/utils/tint.ls +0 -66
- package/src/utils/tip.ls +0 -97
- package/web/src/pug/base.pug +0 -21
- package/web/src/pug/block/axis/0.0.1/index.ls +0 -32
- package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
- package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -137
- package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
- package/web/src/pug/block/bar/0.0.1/index.ls +0 -270
- package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
- package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -81
- package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
- package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -79
- package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
- package/web/src/pug/block/base/0.0.1/index.ls +0 -66
- package/web/src/pug/block/base/0.0.1/index.pug +0 -5
- package/web/src/pug/block/blank/0.0.1/index.ls +0 -21
- package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
- package/web/src/pug/block/bubble/0.0.1/index.ls +0 -218
- package/web/src/pug/block/bubble/0.0.1/index.pug +0 -42
- package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -85
- package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
- package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
- package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -86
- package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
- package/web/src/pug/block/empty/0.0.1/index.ls +0 -28
- package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
- package/web/src/pug/block/gauge/0.0.1/index.ls +0 -96
- package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
- package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
- package/web/src/pug/block/line/0.0.1/index.ls +0 -297
- package/web/src/pug/block/line/0.0.1/index.pug +0 -33
- package/web/src/pug/block/number/0.0.1/index.ls +0 -65
- package/web/src/pug/block/number/0.0.1/index.pug +0 -20
- package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -161
- package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
- package/web/src/pug/block/pie/0.0.1/index.ls +0 -121
- package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
- package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
- package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -181
- package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
- package/web/src/pug/block/radar/0.0.1/index.ls +0 -109
- package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
- package/web/src/pug/block/radar/0.0.1/xx +0 -285
- package/web/src/pug/block/scatter/0.0.1/index.ls +0 -124
- package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
- package/web/src/pug/block/sheet/0.0.1/index.ls +0 -34
- package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
- package/web/src/pug/block/table/0.0.1/index.ls +0 -36
- package/web/src/pug/block/table/0.0.1/index.pug +0 -3
- package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -70
- package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
- package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -44
- package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
- package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -49
- package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
- package/web/src/pug/block/treemap/0.0.1/index.ls +0 -168
- package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -170
- package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
- package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
- package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -57
- package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
- package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -77
- package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
- package/web/src/pug/index.ls +0 -72
- package/web/src/pug/index.pug +0 -51
- package/web/src/styl/index.styl +0 -6
- package/web/static/assets/block/cache.js +0 -4
- package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
- package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
- package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
- package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
- package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
- package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
- package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
- package/web/static/assets/data/countrycode.json +0 -1
- package/web/static/assets/data/world-110m.json +0 -1
- package/web/static/assets/data/zh-to-alpha2.json +0 -1
- package/web/static/assets/img/fluid.svg +0 -16
- package/web/static/block/axis/0.0.1/index.html +0 -74
- package/web/static/block/axis-bubble/0.0.1/index.html +0 -217
- package/web/static/block/bar/0.0.1/index.html +0 -576
- package/web/static/block/bar-list/0.0.1/index.html +0 -226
- package/web/static/block/bar-race/0.0.1/index.html +0 -179
- package/web/static/block/base/0.0.1/index.html +0 -197
- package/web/static/block/blank/0.0.1/index.html +0 -37
- package/web/static/block/bubble/0.0.1/index.html +0 -422
- package/web/static/block/bubble/0.0.1/test.html +0 -0
- package/web/static/block/curve-bar/0.0.1/index.html +0 -143
- package/web/static/block/dumbbell/0.0.1/index.html +0 -173
- package/web/static/block/empty/0.0.1/index.html +0 -76
- package/web/static/block/gauge/0.0.1/index.html +0 -145
- package/web/static/block/line/0.0.1/index.html +0 -566
- package/web/static/block/number/0.0.1/index.html +0 -147
- package/web/static/block/percent-list/0.0.1/index.html +0 -311
- package/web/static/block/pie/0.0.1/index.html +0 -276
- package/web/static/block/pie-bubble/0.0.1/index.html +0 -353
- package/web/static/block/radar/0.0.1/index.html +0 -144
- package/web/static/block/scatter/0.0.1/index.html +0 -246
- package/web/static/block/sheet/0.0.1/index.html +0 -98
- package/web/static/block/table/0.0.1/index.html +0 -67
- package/web/static/block/taiwancounty/0.0.1/index.html +0 -197
- package/web/static/block/taiwantown/0.0.1/index.html +0 -205
- package/web/static/block/taiwanvillage/0.0.1/index.html +0 -215
- package/web/static/block/treemap/0.0.1/index.html +0 -355
- package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -345
- package/web/static/block/wordcloud/0.0.1/index.html +0 -87
- package/web/static/block/worldmap/0.0.1/index.html +0 -202
- package/web/static/css/index.css +0 -6
- package/web/static/css/index.min.css +0 -1
- package/web/static/favicon.ico +0 -0
- package/web/static/index.html +0 -153
|
@@ -1,1182 +0,0 @@
|
|
|
1
|
-
// https://d3js.org/d3-array/ v2.12.1 Copyright 2021 Mike Bostock
|
|
2
|
-
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
5
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
|
|
6
|
-
}(this, (function (exports) { 'use strict';
|
|
7
|
-
|
|
8
|
-
function ascending(a, b) {
|
|
9
|
-
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function bisector(f) {
|
|
13
|
-
let delta = f;
|
|
14
|
-
let compare = f;
|
|
15
|
-
|
|
16
|
-
if (f.length === 1) {
|
|
17
|
-
delta = (d, x) => f(d) - x;
|
|
18
|
-
compare = ascendingComparator(f);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function left(a, x, lo, hi) {
|
|
22
|
-
if (lo == null) lo = 0;
|
|
23
|
-
if (hi == null) hi = a.length;
|
|
24
|
-
while (lo < hi) {
|
|
25
|
-
const mid = (lo + hi) >>> 1;
|
|
26
|
-
if (compare(a[mid], x) < 0) lo = mid + 1;
|
|
27
|
-
else hi = mid;
|
|
28
|
-
}
|
|
29
|
-
return lo;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function right(a, x, lo, hi) {
|
|
33
|
-
if (lo == null) lo = 0;
|
|
34
|
-
if (hi == null) hi = a.length;
|
|
35
|
-
while (lo < hi) {
|
|
36
|
-
const mid = (lo + hi) >>> 1;
|
|
37
|
-
if (compare(a[mid], x) > 0) hi = mid;
|
|
38
|
-
else lo = mid + 1;
|
|
39
|
-
}
|
|
40
|
-
return lo;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function center(a, x, lo, hi) {
|
|
44
|
-
if (lo == null) lo = 0;
|
|
45
|
-
if (hi == null) hi = a.length;
|
|
46
|
-
const i = left(a, x, lo, hi - 1);
|
|
47
|
-
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {left, center, right};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function ascendingComparator(f) {
|
|
54
|
-
return (d, x) => ascending(f(d), x);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function number(x) {
|
|
58
|
-
return x === null ? NaN : +x;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function* numbers(values, valueof) {
|
|
62
|
-
if (valueof === undefined) {
|
|
63
|
-
for (let value of values) {
|
|
64
|
-
if (value != null && (value = +value) >= value) {
|
|
65
|
-
yield value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
let index = -1;
|
|
70
|
-
for (let value of values) {
|
|
71
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
72
|
-
yield value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const ascendingBisect = bisector(ascending);
|
|
79
|
-
const bisectRight = ascendingBisect.right;
|
|
80
|
-
const bisectLeft = ascendingBisect.left;
|
|
81
|
-
const bisectCenter = bisector(number).center;
|
|
82
|
-
|
|
83
|
-
function count(values, valueof) {
|
|
84
|
-
let count = 0;
|
|
85
|
-
if (valueof === undefined) {
|
|
86
|
-
for (let value of values) {
|
|
87
|
-
if (value != null && (value = +value) >= value) {
|
|
88
|
-
++count;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
let index = -1;
|
|
93
|
-
for (let value of values) {
|
|
94
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
95
|
-
++count;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return count;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function length$1(array) {
|
|
103
|
-
return array.length | 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function empty(length) {
|
|
107
|
-
return !(length > 0);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function arrayify(values) {
|
|
111
|
-
return typeof values !== "object" || "length" in values ? values : Array.from(values);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function reducer(reduce) {
|
|
115
|
-
return values => reduce(...values);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function cross(...values) {
|
|
119
|
-
const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop());
|
|
120
|
-
values = values.map(arrayify);
|
|
121
|
-
const lengths = values.map(length$1);
|
|
122
|
-
const j = values.length - 1;
|
|
123
|
-
const index = new Array(j + 1).fill(0);
|
|
124
|
-
const product = [];
|
|
125
|
-
if (j < 0 || lengths.some(empty)) return product;
|
|
126
|
-
while (true) {
|
|
127
|
-
product.push(index.map((j, i) => values[i][j]));
|
|
128
|
-
let i = j;
|
|
129
|
-
while (++index[i] === lengths[i]) {
|
|
130
|
-
if (i === 0) return reduce ? product.map(reduce) : product;
|
|
131
|
-
index[i--] = 0;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function cumsum(values, valueof) {
|
|
137
|
-
var sum = 0, index = 0;
|
|
138
|
-
return Float64Array.from(values, valueof === undefined
|
|
139
|
-
? v => (sum += +v || 0)
|
|
140
|
-
: v => (sum += +valueof(v, index++, values) || 0));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function descending(a, b) {
|
|
144
|
-
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function variance(values, valueof) {
|
|
148
|
-
let count = 0;
|
|
149
|
-
let delta;
|
|
150
|
-
let mean = 0;
|
|
151
|
-
let sum = 0;
|
|
152
|
-
if (valueof === undefined) {
|
|
153
|
-
for (let value of values) {
|
|
154
|
-
if (value != null && (value = +value) >= value) {
|
|
155
|
-
delta = value - mean;
|
|
156
|
-
mean += delta / ++count;
|
|
157
|
-
sum += delta * (value - mean);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
let index = -1;
|
|
162
|
-
for (let value of values) {
|
|
163
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
164
|
-
delta = value - mean;
|
|
165
|
-
mean += delta / ++count;
|
|
166
|
-
sum += delta * (value - mean);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (count > 1) return sum / (count - 1);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function deviation(values, valueof) {
|
|
174
|
-
const v = variance(values, valueof);
|
|
175
|
-
return v ? Math.sqrt(v) : v;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function extent(values, valueof) {
|
|
179
|
-
let min;
|
|
180
|
-
let max;
|
|
181
|
-
if (valueof === undefined) {
|
|
182
|
-
for (const value of values) {
|
|
183
|
-
if (value != null) {
|
|
184
|
-
if (min === undefined) {
|
|
185
|
-
if (value >= value) min = max = value;
|
|
186
|
-
} else {
|
|
187
|
-
if (min > value) min = value;
|
|
188
|
-
if (max < value) max = value;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
let index = -1;
|
|
194
|
-
for (let value of values) {
|
|
195
|
-
if ((value = valueof(value, ++index, values)) != null) {
|
|
196
|
-
if (min === undefined) {
|
|
197
|
-
if (value >= value) min = max = value;
|
|
198
|
-
} else {
|
|
199
|
-
if (min > value) min = value;
|
|
200
|
-
if (max < value) max = value;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return [min, max];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// https://github.com/python/cpython/blob/a74eea238f5baba15797e2e8b570d153bc8690a7/Modules/mathmodule.c#L1423
|
|
209
|
-
class Adder {
|
|
210
|
-
constructor() {
|
|
211
|
-
this._partials = new Float64Array(32);
|
|
212
|
-
this._n = 0;
|
|
213
|
-
}
|
|
214
|
-
add(x) {
|
|
215
|
-
const p = this._partials;
|
|
216
|
-
let i = 0;
|
|
217
|
-
for (let j = 0; j < this._n && j < 32; j++) {
|
|
218
|
-
const y = p[j],
|
|
219
|
-
hi = x + y,
|
|
220
|
-
lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);
|
|
221
|
-
if (lo) p[i++] = lo;
|
|
222
|
-
x = hi;
|
|
223
|
-
}
|
|
224
|
-
p[i] = x;
|
|
225
|
-
this._n = i + 1;
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
valueOf() {
|
|
229
|
-
const p = this._partials;
|
|
230
|
-
let n = this._n, x, y, lo, hi = 0;
|
|
231
|
-
if (n > 0) {
|
|
232
|
-
hi = p[--n];
|
|
233
|
-
while (n > 0) {
|
|
234
|
-
x = hi;
|
|
235
|
-
y = p[--n];
|
|
236
|
-
hi = x + y;
|
|
237
|
-
lo = y - (hi - x);
|
|
238
|
-
if (lo) break;
|
|
239
|
-
}
|
|
240
|
-
if (n > 0 && ((lo < 0 && p[n - 1] < 0) || (lo > 0 && p[n - 1] > 0))) {
|
|
241
|
-
y = lo * 2;
|
|
242
|
-
x = hi + y;
|
|
243
|
-
if (y == x - hi) hi = x;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return hi;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function fsum(values, valueof) {
|
|
251
|
-
const adder = new Adder();
|
|
252
|
-
if (valueof === undefined) {
|
|
253
|
-
for (let value of values) {
|
|
254
|
-
if (value = +value) {
|
|
255
|
-
adder.add(value);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
} else {
|
|
259
|
-
let index = -1;
|
|
260
|
-
for (let value of values) {
|
|
261
|
-
if (value = +valueof(value, ++index, values)) {
|
|
262
|
-
adder.add(value);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return +adder;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function fcumsum(values, valueof) {
|
|
270
|
-
const adder = new Adder();
|
|
271
|
-
let index = -1;
|
|
272
|
-
return Float64Array.from(values, valueof === undefined
|
|
273
|
-
? v => adder.add(+v || 0)
|
|
274
|
-
: v => adder.add(+valueof(v, ++index, values) || 0)
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
class InternMap extends Map {
|
|
279
|
-
constructor(entries, key = keyof) {
|
|
280
|
-
super();
|
|
281
|
-
Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
|
|
282
|
-
if (entries != null) for (const [key, value] of entries) this.set(key, value);
|
|
283
|
-
}
|
|
284
|
-
get(key) {
|
|
285
|
-
return super.get(intern_get(this, key));
|
|
286
|
-
}
|
|
287
|
-
has(key) {
|
|
288
|
-
return super.has(intern_get(this, key));
|
|
289
|
-
}
|
|
290
|
-
set(key, value) {
|
|
291
|
-
return super.set(intern_set(this, key), value);
|
|
292
|
-
}
|
|
293
|
-
delete(key) {
|
|
294
|
-
return super.delete(intern_delete(this, key));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
class InternSet extends Set {
|
|
299
|
-
constructor(values, key = keyof) {
|
|
300
|
-
super();
|
|
301
|
-
Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
|
|
302
|
-
if (values != null) for (const value of values) this.add(value);
|
|
303
|
-
}
|
|
304
|
-
has(value) {
|
|
305
|
-
return super.has(intern_get(this, value));
|
|
306
|
-
}
|
|
307
|
-
add(value) {
|
|
308
|
-
return super.add(intern_set(this, value));
|
|
309
|
-
}
|
|
310
|
-
delete(value) {
|
|
311
|
-
return super.delete(intern_delete(this, value));
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function intern_get({_intern, _key}, value) {
|
|
316
|
-
const key = _key(value);
|
|
317
|
-
return _intern.has(key) ? _intern.get(key) : value;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function intern_set({_intern, _key}, value) {
|
|
321
|
-
const key = _key(value);
|
|
322
|
-
if (_intern.has(key)) return _intern.get(key);
|
|
323
|
-
_intern.set(key, value);
|
|
324
|
-
return value;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function intern_delete({_intern, _key}, value) {
|
|
328
|
-
const key = _key(value);
|
|
329
|
-
if (_intern.has(key)) {
|
|
330
|
-
value = _intern.get(value);
|
|
331
|
-
_intern.delete(key);
|
|
332
|
-
}
|
|
333
|
-
return value;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function keyof(value) {
|
|
337
|
-
return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function identity(x) {
|
|
341
|
-
return x;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function group(values, ...keys) {
|
|
345
|
-
return nest(values, identity, identity, keys);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function groups(values, ...keys) {
|
|
349
|
-
return nest(values, Array.from, identity, keys);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function rollup(values, reduce, ...keys) {
|
|
353
|
-
return nest(values, identity, reduce, keys);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function rollups(values, reduce, ...keys) {
|
|
357
|
-
return nest(values, Array.from, reduce, keys);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function index(values, ...keys) {
|
|
361
|
-
return nest(values, identity, unique, keys);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function indexes(values, ...keys) {
|
|
365
|
-
return nest(values, Array.from, unique, keys);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function unique(values) {
|
|
369
|
-
if (values.length !== 1) throw new Error("duplicate key");
|
|
370
|
-
return values[0];
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function nest(values, map, reduce, keys) {
|
|
374
|
-
return (function regroup(values, i) {
|
|
375
|
-
if (i >= keys.length) return reduce(values);
|
|
376
|
-
const groups = new InternMap();
|
|
377
|
-
const keyof = keys[i++];
|
|
378
|
-
let index = -1;
|
|
379
|
-
for (const value of values) {
|
|
380
|
-
const key = keyof(value, ++index, values);
|
|
381
|
-
const group = groups.get(key);
|
|
382
|
-
if (group) group.push(value);
|
|
383
|
-
else groups.set(key, [value]);
|
|
384
|
-
}
|
|
385
|
-
for (const [key, values] of groups) {
|
|
386
|
-
groups.set(key, regroup(values, i));
|
|
387
|
-
}
|
|
388
|
-
return map(groups);
|
|
389
|
-
})(values, 0);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function permute(source, keys) {
|
|
393
|
-
return Array.from(keys, key => source[key]);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function sort(values, ...F) {
|
|
397
|
-
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
398
|
-
values = Array.from(values);
|
|
399
|
-
let [f = ascending] = F;
|
|
400
|
-
if (f.length === 1 || F.length > 1) {
|
|
401
|
-
const index = Uint32Array.from(values, (d, i) => i);
|
|
402
|
-
if (F.length > 1) {
|
|
403
|
-
F = F.map(f => values.map(f));
|
|
404
|
-
index.sort((i, j) => {
|
|
405
|
-
for (const f of F) {
|
|
406
|
-
const c = ascending(f[i], f[j]);
|
|
407
|
-
if (c) return c;
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
} else {
|
|
411
|
-
f = values.map(f);
|
|
412
|
-
index.sort((i, j) => ascending(f[i], f[j]));
|
|
413
|
-
}
|
|
414
|
-
return permute(values, index);
|
|
415
|
-
}
|
|
416
|
-
return values.sort(f);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function groupSort(values, reduce, key) {
|
|
420
|
-
return (reduce.length === 1
|
|
421
|
-
? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)))
|
|
422
|
-
: sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))))
|
|
423
|
-
.map(([key]) => key);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
var array = Array.prototype;
|
|
427
|
-
|
|
428
|
-
var slice = array.slice;
|
|
429
|
-
|
|
430
|
-
function constant(x) {
|
|
431
|
-
return function() {
|
|
432
|
-
return x;
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
var e10 = Math.sqrt(50),
|
|
437
|
-
e5 = Math.sqrt(10),
|
|
438
|
-
e2 = Math.sqrt(2);
|
|
439
|
-
|
|
440
|
-
function ticks(start, stop, count) {
|
|
441
|
-
var reverse,
|
|
442
|
-
i = -1,
|
|
443
|
-
n,
|
|
444
|
-
ticks,
|
|
445
|
-
step;
|
|
446
|
-
|
|
447
|
-
stop = +stop, start = +start, count = +count;
|
|
448
|
-
if (start === stop && count > 0) return [start];
|
|
449
|
-
if (reverse = stop < start) n = start, start = stop, stop = n;
|
|
450
|
-
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
|
|
451
|
-
|
|
452
|
-
if (step > 0) {
|
|
453
|
-
let r0 = Math.round(start / step), r1 = Math.round(stop / step);
|
|
454
|
-
if (r0 * step < start) ++r0;
|
|
455
|
-
if (r1 * step > stop) --r1;
|
|
456
|
-
ticks = new Array(n = r1 - r0 + 1);
|
|
457
|
-
while (++i < n) ticks[i] = (r0 + i) * step;
|
|
458
|
-
} else {
|
|
459
|
-
step = -step;
|
|
460
|
-
let r0 = Math.round(start * step), r1 = Math.round(stop * step);
|
|
461
|
-
if (r0 / step < start) ++r0;
|
|
462
|
-
if (r1 / step > stop) --r1;
|
|
463
|
-
ticks = new Array(n = r1 - r0 + 1);
|
|
464
|
-
while (++i < n) ticks[i] = (r0 + i) / step;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (reverse) ticks.reverse();
|
|
468
|
-
|
|
469
|
-
return ticks;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function tickIncrement(start, stop, count) {
|
|
473
|
-
var step = (stop - start) / Math.max(0, count),
|
|
474
|
-
power = Math.floor(Math.log(step) / Math.LN10),
|
|
475
|
-
error = step / Math.pow(10, power);
|
|
476
|
-
return power >= 0
|
|
477
|
-
? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
|
|
478
|
-
: -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function tickStep(start, stop, count) {
|
|
482
|
-
var step0 = Math.abs(stop - start) / Math.max(0, count),
|
|
483
|
-
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
|
|
484
|
-
error = step0 / step1;
|
|
485
|
-
if (error >= e10) step1 *= 10;
|
|
486
|
-
else if (error >= e5) step1 *= 5;
|
|
487
|
-
else if (error >= e2) step1 *= 2;
|
|
488
|
-
return stop < start ? -step1 : step1;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
function nice(start, stop, count) {
|
|
492
|
-
let prestep;
|
|
493
|
-
while (true) {
|
|
494
|
-
const step = tickIncrement(start, stop, count);
|
|
495
|
-
if (step === prestep || step === 0 || !isFinite(step)) {
|
|
496
|
-
return [start, stop];
|
|
497
|
-
} else if (step > 0) {
|
|
498
|
-
start = Math.floor(start / step) * step;
|
|
499
|
-
stop = Math.ceil(stop / step) * step;
|
|
500
|
-
} else if (step < 0) {
|
|
501
|
-
start = Math.ceil(start * step) / step;
|
|
502
|
-
stop = Math.floor(stop * step) / step;
|
|
503
|
-
}
|
|
504
|
-
prestep = step;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
function sturges(values) {
|
|
509
|
-
return Math.ceil(Math.log(count(values)) / Math.LN2) + 1;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function bin() {
|
|
513
|
-
var value = identity,
|
|
514
|
-
domain = extent,
|
|
515
|
-
threshold = sturges;
|
|
516
|
-
|
|
517
|
-
function histogram(data) {
|
|
518
|
-
if (!Array.isArray(data)) data = Array.from(data);
|
|
519
|
-
|
|
520
|
-
var i,
|
|
521
|
-
n = data.length,
|
|
522
|
-
x,
|
|
523
|
-
values = new Array(n);
|
|
524
|
-
|
|
525
|
-
for (i = 0; i < n; ++i) {
|
|
526
|
-
values[i] = value(data[i], i, data);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
var xz = domain(values),
|
|
530
|
-
x0 = xz[0],
|
|
531
|
-
x1 = xz[1],
|
|
532
|
-
tz = threshold(values, x0, x1);
|
|
533
|
-
|
|
534
|
-
// Convert number of thresholds into uniform thresholds, and nice the
|
|
535
|
-
// default domain accordingly.
|
|
536
|
-
if (!Array.isArray(tz)) {
|
|
537
|
-
const max = x1, tn = +tz;
|
|
538
|
-
if (domain === extent) [x0, x1] = nice(x0, x1, tn);
|
|
539
|
-
tz = ticks(x0, x1, tn);
|
|
540
|
-
|
|
541
|
-
// If the last threshold is coincident with the domain’s upper bound, the
|
|
542
|
-
// last bin will be zero-width. If the default domain is used, and this
|
|
543
|
-
// last threshold is coincident with the maximum input value, we can
|
|
544
|
-
// extend the niced upper bound by one tick to ensure uniform bin widths;
|
|
545
|
-
// otherwise, we simply remove the last threshold. Note that we don’t
|
|
546
|
-
// coerce values or the domain to numbers, and thus must be careful to
|
|
547
|
-
// compare order (>=) rather than strict equality (===)!
|
|
548
|
-
if (tz[tz.length - 1] >= x1) {
|
|
549
|
-
if (max >= x1 && domain === extent) {
|
|
550
|
-
const step = tickIncrement(x0, x1, tn);
|
|
551
|
-
if (isFinite(step)) {
|
|
552
|
-
if (step > 0) {
|
|
553
|
-
x1 = (Math.floor(x1 / step) + 1) * step;
|
|
554
|
-
} else if (step < 0) {
|
|
555
|
-
x1 = (Math.ceil(x1 * -step) + 1) / -step;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
} else {
|
|
559
|
-
tz.pop();
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// Remove any thresholds outside the domain.
|
|
565
|
-
var m = tz.length;
|
|
566
|
-
while (tz[0] <= x0) tz.shift(), --m;
|
|
567
|
-
while (tz[m - 1] > x1) tz.pop(), --m;
|
|
568
|
-
|
|
569
|
-
var bins = new Array(m + 1),
|
|
570
|
-
bin;
|
|
571
|
-
|
|
572
|
-
// Initialize bins.
|
|
573
|
-
for (i = 0; i <= m; ++i) {
|
|
574
|
-
bin = bins[i] = [];
|
|
575
|
-
bin.x0 = i > 0 ? tz[i - 1] : x0;
|
|
576
|
-
bin.x1 = i < m ? tz[i] : x1;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// Assign data to bins by value, ignoring any outside the domain.
|
|
580
|
-
for (i = 0; i < n; ++i) {
|
|
581
|
-
x = values[i];
|
|
582
|
-
if (x0 <= x && x <= x1) {
|
|
583
|
-
bins[bisectRight(tz, x, 0, m)].push(data[i]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
return bins;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
histogram.value = function(_) {
|
|
591
|
-
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
histogram.domain = function(_) {
|
|
595
|
-
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
histogram.thresholds = function(_) {
|
|
599
|
-
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
return histogram;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
function max(values, valueof) {
|
|
606
|
-
let max;
|
|
607
|
-
if (valueof === undefined) {
|
|
608
|
-
for (const value of values) {
|
|
609
|
-
if (value != null
|
|
610
|
-
&& (max < value || (max === undefined && value >= value))) {
|
|
611
|
-
max = value;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
} else {
|
|
615
|
-
let index = -1;
|
|
616
|
-
for (let value of values) {
|
|
617
|
-
if ((value = valueof(value, ++index, values)) != null
|
|
618
|
-
&& (max < value || (max === undefined && value >= value))) {
|
|
619
|
-
max = value;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
return max;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
function min(values, valueof) {
|
|
627
|
-
let min;
|
|
628
|
-
if (valueof === undefined) {
|
|
629
|
-
for (const value of values) {
|
|
630
|
-
if (value != null
|
|
631
|
-
&& (min > value || (min === undefined && value >= value))) {
|
|
632
|
-
min = value;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
} else {
|
|
636
|
-
let index = -1;
|
|
637
|
-
for (let value of values) {
|
|
638
|
-
if ((value = valueof(value, ++index, values)) != null
|
|
639
|
-
&& (min > value || (min === undefined && value >= value))) {
|
|
640
|
-
min = value;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
return min;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
// Based on https://github.com/mourner/quickselect
|
|
648
|
-
// ISC license, Copyright 2018 Vladimir Agafonkin.
|
|
649
|
-
function quickselect(array, k, left = 0, right = array.length - 1, compare = ascending) {
|
|
650
|
-
while (right > left) {
|
|
651
|
-
if (right - left > 600) {
|
|
652
|
-
const n = right - left + 1;
|
|
653
|
-
const m = k - left + 1;
|
|
654
|
-
const z = Math.log(n);
|
|
655
|
-
const s = 0.5 * Math.exp(2 * z / 3);
|
|
656
|
-
const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
657
|
-
const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
658
|
-
const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
659
|
-
quickselect(array, k, newLeft, newRight, compare);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
const t = array[k];
|
|
663
|
-
let i = left;
|
|
664
|
-
let j = right;
|
|
665
|
-
|
|
666
|
-
swap(array, left, k);
|
|
667
|
-
if (compare(array[right], t) > 0) swap(array, left, right);
|
|
668
|
-
|
|
669
|
-
while (i < j) {
|
|
670
|
-
swap(array, i, j), ++i, --j;
|
|
671
|
-
while (compare(array[i], t) < 0) ++i;
|
|
672
|
-
while (compare(array[j], t) > 0) --j;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (compare(array[left], t) === 0) swap(array, left, j);
|
|
676
|
-
else ++j, swap(array, j, right);
|
|
677
|
-
|
|
678
|
-
if (j <= k) left = j + 1;
|
|
679
|
-
if (k <= j) right = j - 1;
|
|
680
|
-
}
|
|
681
|
-
return array;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
function swap(array, i, j) {
|
|
685
|
-
const t = array[i];
|
|
686
|
-
array[i] = array[j];
|
|
687
|
-
array[j] = t;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
function quantile(values, p, valueof) {
|
|
691
|
-
values = Float64Array.from(numbers(values, valueof));
|
|
692
|
-
if (!(n = values.length)) return;
|
|
693
|
-
if ((p = +p) <= 0 || n < 2) return min(values);
|
|
694
|
-
if (p >= 1) return max(values);
|
|
695
|
-
var n,
|
|
696
|
-
i = (n - 1) * p,
|
|
697
|
-
i0 = Math.floor(i),
|
|
698
|
-
value0 = max(quickselect(values, i0).subarray(0, i0 + 1)),
|
|
699
|
-
value1 = min(values.subarray(i0 + 1));
|
|
700
|
-
return value0 + (value1 - value0) * (i - i0);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
function quantileSorted(values, p, valueof = number) {
|
|
704
|
-
if (!(n = values.length)) return;
|
|
705
|
-
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
|
|
706
|
-
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
|
|
707
|
-
var n,
|
|
708
|
-
i = (n - 1) * p,
|
|
709
|
-
i0 = Math.floor(i),
|
|
710
|
-
value0 = +valueof(values[i0], i0, values),
|
|
711
|
-
value1 = +valueof(values[i0 + 1], i0 + 1, values);
|
|
712
|
-
return value0 + (value1 - value0) * (i - i0);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
function freedmanDiaconis(values, min, max) {
|
|
716
|
-
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(count(values), -1 / 3)));
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
function scott(values, min, max) {
|
|
720
|
-
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(count(values), -1 / 3)));
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
function maxIndex(values, valueof) {
|
|
724
|
-
let max;
|
|
725
|
-
let maxIndex = -1;
|
|
726
|
-
let index = -1;
|
|
727
|
-
if (valueof === undefined) {
|
|
728
|
-
for (const value of values) {
|
|
729
|
-
++index;
|
|
730
|
-
if (value != null
|
|
731
|
-
&& (max < value || (max === undefined && value >= value))) {
|
|
732
|
-
max = value, maxIndex = index;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
} else {
|
|
736
|
-
for (let value of values) {
|
|
737
|
-
if ((value = valueof(value, ++index, values)) != null
|
|
738
|
-
&& (max < value || (max === undefined && value >= value))) {
|
|
739
|
-
max = value, maxIndex = index;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
return maxIndex;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function mean(values, valueof) {
|
|
747
|
-
let count = 0;
|
|
748
|
-
let sum = 0;
|
|
749
|
-
if (valueof === undefined) {
|
|
750
|
-
for (let value of values) {
|
|
751
|
-
if (value != null && (value = +value) >= value) {
|
|
752
|
-
++count, sum += value;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
} else {
|
|
756
|
-
let index = -1;
|
|
757
|
-
for (let value of values) {
|
|
758
|
-
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
759
|
-
++count, sum += value;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
if (count) return sum / count;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
function median(values, valueof) {
|
|
767
|
-
return quantile(values, 0.5, valueof);
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
function* flatten(arrays) {
|
|
771
|
-
for (const array of arrays) {
|
|
772
|
-
yield* array;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
function merge(arrays) {
|
|
777
|
-
return Array.from(flatten(arrays));
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
function minIndex(values, valueof) {
|
|
781
|
-
let min;
|
|
782
|
-
let minIndex = -1;
|
|
783
|
-
let index = -1;
|
|
784
|
-
if (valueof === undefined) {
|
|
785
|
-
for (const value of values) {
|
|
786
|
-
++index;
|
|
787
|
-
if (value != null
|
|
788
|
-
&& (min > value || (min === undefined && value >= value))) {
|
|
789
|
-
min = value, minIndex = index;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
} else {
|
|
793
|
-
for (let value of values) {
|
|
794
|
-
if ((value = valueof(value, ++index, values)) != null
|
|
795
|
-
&& (min > value || (min === undefined && value >= value))) {
|
|
796
|
-
min = value, minIndex = index;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return minIndex;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
function pairs(values, pairof = pair) {
|
|
804
|
-
const pairs = [];
|
|
805
|
-
let previous;
|
|
806
|
-
let first = false;
|
|
807
|
-
for (const value of values) {
|
|
808
|
-
if (first) pairs.push(pairof(previous, value));
|
|
809
|
-
previous = value;
|
|
810
|
-
first = true;
|
|
811
|
-
}
|
|
812
|
-
return pairs;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
function pair(a, b) {
|
|
816
|
-
return [a, b];
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
function range(start, stop, step) {
|
|
820
|
-
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
|
|
821
|
-
|
|
822
|
-
var i = -1,
|
|
823
|
-
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
|
|
824
|
-
range = new Array(n);
|
|
825
|
-
|
|
826
|
-
while (++i < n) {
|
|
827
|
-
range[i] = start + i * step;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
return range;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
function least(values, compare = ascending) {
|
|
834
|
-
let min;
|
|
835
|
-
let defined = false;
|
|
836
|
-
if (compare.length === 1) {
|
|
837
|
-
let minValue;
|
|
838
|
-
for (const element of values) {
|
|
839
|
-
const value = compare(element);
|
|
840
|
-
if (defined
|
|
841
|
-
? ascending(value, minValue) < 0
|
|
842
|
-
: ascending(value, value) === 0) {
|
|
843
|
-
min = element;
|
|
844
|
-
minValue = value;
|
|
845
|
-
defined = true;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
} else {
|
|
849
|
-
for (const value of values) {
|
|
850
|
-
if (defined
|
|
851
|
-
? compare(value, min) < 0
|
|
852
|
-
: compare(value, value) === 0) {
|
|
853
|
-
min = value;
|
|
854
|
-
defined = true;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
return min;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function leastIndex(values, compare = ascending) {
|
|
862
|
-
if (compare.length === 1) return minIndex(values, compare);
|
|
863
|
-
let minValue;
|
|
864
|
-
let min = -1;
|
|
865
|
-
let index = -1;
|
|
866
|
-
for (const value of values) {
|
|
867
|
-
++index;
|
|
868
|
-
if (min < 0
|
|
869
|
-
? compare(value, value) === 0
|
|
870
|
-
: compare(value, minValue) < 0) {
|
|
871
|
-
minValue = value;
|
|
872
|
-
min = index;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
return min;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
function greatest(values, compare = ascending) {
|
|
879
|
-
let max;
|
|
880
|
-
let defined = false;
|
|
881
|
-
if (compare.length === 1) {
|
|
882
|
-
let maxValue;
|
|
883
|
-
for (const element of values) {
|
|
884
|
-
const value = compare(element);
|
|
885
|
-
if (defined
|
|
886
|
-
? ascending(value, maxValue) > 0
|
|
887
|
-
: ascending(value, value) === 0) {
|
|
888
|
-
max = element;
|
|
889
|
-
maxValue = value;
|
|
890
|
-
defined = true;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
} else {
|
|
894
|
-
for (const value of values) {
|
|
895
|
-
if (defined
|
|
896
|
-
? compare(value, max) > 0
|
|
897
|
-
: compare(value, value) === 0) {
|
|
898
|
-
max = value;
|
|
899
|
-
defined = true;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
return max;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
function greatestIndex(values, compare = ascending) {
|
|
907
|
-
if (compare.length === 1) return maxIndex(values, compare);
|
|
908
|
-
let maxValue;
|
|
909
|
-
let max = -1;
|
|
910
|
-
let index = -1;
|
|
911
|
-
for (const value of values) {
|
|
912
|
-
++index;
|
|
913
|
-
if (max < 0
|
|
914
|
-
? compare(value, value) === 0
|
|
915
|
-
: compare(value, maxValue) > 0) {
|
|
916
|
-
maxValue = value;
|
|
917
|
-
max = index;
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return max;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function scan(values, compare) {
|
|
924
|
-
const index = leastIndex(values, compare);
|
|
925
|
-
return index < 0 ? undefined : index;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
var shuffle = shuffler(Math.random);
|
|
929
|
-
|
|
930
|
-
function shuffler(random) {
|
|
931
|
-
return function shuffle(array, i0 = 0, i1 = array.length) {
|
|
932
|
-
let m = i1 - (i0 = +i0);
|
|
933
|
-
while (m) {
|
|
934
|
-
const i = random() * m-- | 0, t = array[m + i0];
|
|
935
|
-
array[m + i0] = array[i + i0];
|
|
936
|
-
array[i + i0] = t;
|
|
937
|
-
}
|
|
938
|
-
return array;
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
function sum(values, valueof) {
|
|
943
|
-
let sum = 0;
|
|
944
|
-
if (valueof === undefined) {
|
|
945
|
-
for (let value of values) {
|
|
946
|
-
if (value = +value) {
|
|
947
|
-
sum += value;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
} else {
|
|
951
|
-
let index = -1;
|
|
952
|
-
for (let value of values) {
|
|
953
|
-
if (value = +valueof(value, ++index, values)) {
|
|
954
|
-
sum += value;
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
return sum;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
function transpose(matrix) {
|
|
962
|
-
if (!(n = matrix.length)) return [];
|
|
963
|
-
for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) {
|
|
964
|
-
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {
|
|
965
|
-
row[j] = matrix[j][i];
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
return transpose;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
function length(d) {
|
|
972
|
-
return d.length;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
function zip() {
|
|
976
|
-
return transpose(arguments);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
function every(values, test) {
|
|
980
|
-
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
981
|
-
let index = -1;
|
|
982
|
-
for (const value of values) {
|
|
983
|
-
if (!test(value, ++index, values)) {
|
|
984
|
-
return false;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
return true;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
function some(values, test) {
|
|
991
|
-
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
992
|
-
let index = -1;
|
|
993
|
-
for (const value of values) {
|
|
994
|
-
if (test(value, ++index, values)) {
|
|
995
|
-
return true;
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
return false;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
function filter(values, test) {
|
|
1002
|
-
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
1003
|
-
const array = [];
|
|
1004
|
-
let index = -1;
|
|
1005
|
-
for (const value of values) {
|
|
1006
|
-
if (test(value, ++index, values)) {
|
|
1007
|
-
array.push(value);
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
return array;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
function map(values, mapper) {
|
|
1014
|
-
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
1015
|
-
if (typeof mapper !== "function") throw new TypeError("mapper is not a function");
|
|
1016
|
-
return Array.from(values, (value, index) => mapper(value, index, values));
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
function reduce(values, reducer, value) {
|
|
1020
|
-
if (typeof reducer !== "function") throw new TypeError("reducer is not a function");
|
|
1021
|
-
const iterator = values[Symbol.iterator]();
|
|
1022
|
-
let done, next, index = -1;
|
|
1023
|
-
if (arguments.length < 3) {
|
|
1024
|
-
({done, value} = iterator.next());
|
|
1025
|
-
if (done) return;
|
|
1026
|
-
++index;
|
|
1027
|
-
}
|
|
1028
|
-
while (({done, value: next} = iterator.next()), !done) {
|
|
1029
|
-
value = reducer(value, next, ++index, values);
|
|
1030
|
-
}
|
|
1031
|
-
return value;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
function reverse(values) {
|
|
1035
|
-
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
1036
|
-
return Array.from(values).reverse();
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
function difference(values, ...others) {
|
|
1040
|
-
values = new Set(values);
|
|
1041
|
-
for (const other of others) {
|
|
1042
|
-
for (const value of other) {
|
|
1043
|
-
values.delete(value);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return values;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
function disjoint(values, other) {
|
|
1050
|
-
const iterator = other[Symbol.iterator](), set = new Set();
|
|
1051
|
-
for (const v of values) {
|
|
1052
|
-
if (set.has(v)) return false;
|
|
1053
|
-
let value, done;
|
|
1054
|
-
while (({value, done} = iterator.next())) {
|
|
1055
|
-
if (done) break;
|
|
1056
|
-
if (Object.is(v, value)) return false;
|
|
1057
|
-
set.add(value);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
return true;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
function set(values) {
|
|
1064
|
-
return values instanceof Set ? values : new Set(values);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
function intersection(values, ...others) {
|
|
1068
|
-
values = new Set(values);
|
|
1069
|
-
others = others.map(set);
|
|
1070
|
-
out: for (const value of values) {
|
|
1071
|
-
for (const other of others) {
|
|
1072
|
-
if (!other.has(value)) {
|
|
1073
|
-
values.delete(value);
|
|
1074
|
-
continue out;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
return values;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
function superset(values, other) {
|
|
1082
|
-
const iterator = values[Symbol.iterator](), set = new Set();
|
|
1083
|
-
for (const o of other) {
|
|
1084
|
-
if (set.has(o)) continue;
|
|
1085
|
-
let value, done;
|
|
1086
|
-
while (({value, done} = iterator.next())) {
|
|
1087
|
-
if (done) return false;
|
|
1088
|
-
set.add(value);
|
|
1089
|
-
if (Object.is(o, value)) break;
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
return true;
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
function subset(values, other) {
|
|
1096
|
-
return superset(other, values);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
function union(...others) {
|
|
1100
|
-
const set = new Set();
|
|
1101
|
-
for (const other of others) {
|
|
1102
|
-
for (const o of other) {
|
|
1103
|
-
set.add(o);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
return set;
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
exports.Adder = Adder;
|
|
1110
|
-
exports.InternMap = InternMap;
|
|
1111
|
-
exports.InternSet = InternSet;
|
|
1112
|
-
exports.ascending = ascending;
|
|
1113
|
-
exports.bin = bin;
|
|
1114
|
-
exports.bisect = bisectRight;
|
|
1115
|
-
exports.bisectCenter = bisectCenter;
|
|
1116
|
-
exports.bisectLeft = bisectLeft;
|
|
1117
|
-
exports.bisectRight = bisectRight;
|
|
1118
|
-
exports.bisector = bisector;
|
|
1119
|
-
exports.count = count;
|
|
1120
|
-
exports.cross = cross;
|
|
1121
|
-
exports.cumsum = cumsum;
|
|
1122
|
-
exports.descending = descending;
|
|
1123
|
-
exports.deviation = deviation;
|
|
1124
|
-
exports.difference = difference;
|
|
1125
|
-
exports.disjoint = disjoint;
|
|
1126
|
-
exports.every = every;
|
|
1127
|
-
exports.extent = extent;
|
|
1128
|
-
exports.fcumsum = fcumsum;
|
|
1129
|
-
exports.filter = filter;
|
|
1130
|
-
exports.fsum = fsum;
|
|
1131
|
-
exports.greatest = greatest;
|
|
1132
|
-
exports.greatestIndex = greatestIndex;
|
|
1133
|
-
exports.group = group;
|
|
1134
|
-
exports.groupSort = groupSort;
|
|
1135
|
-
exports.groups = groups;
|
|
1136
|
-
exports.histogram = bin;
|
|
1137
|
-
exports.index = index;
|
|
1138
|
-
exports.indexes = indexes;
|
|
1139
|
-
exports.intersection = intersection;
|
|
1140
|
-
exports.least = least;
|
|
1141
|
-
exports.leastIndex = leastIndex;
|
|
1142
|
-
exports.map = map;
|
|
1143
|
-
exports.max = max;
|
|
1144
|
-
exports.maxIndex = maxIndex;
|
|
1145
|
-
exports.mean = mean;
|
|
1146
|
-
exports.median = median;
|
|
1147
|
-
exports.merge = merge;
|
|
1148
|
-
exports.min = min;
|
|
1149
|
-
exports.minIndex = minIndex;
|
|
1150
|
-
exports.nice = nice;
|
|
1151
|
-
exports.pairs = pairs;
|
|
1152
|
-
exports.permute = permute;
|
|
1153
|
-
exports.quantile = quantile;
|
|
1154
|
-
exports.quantileSorted = quantileSorted;
|
|
1155
|
-
exports.quickselect = quickselect;
|
|
1156
|
-
exports.range = range;
|
|
1157
|
-
exports.reduce = reduce;
|
|
1158
|
-
exports.reverse = reverse;
|
|
1159
|
-
exports.rollup = rollup;
|
|
1160
|
-
exports.rollups = rollups;
|
|
1161
|
-
exports.scan = scan;
|
|
1162
|
-
exports.shuffle = shuffle;
|
|
1163
|
-
exports.shuffler = shuffler;
|
|
1164
|
-
exports.some = some;
|
|
1165
|
-
exports.sort = sort;
|
|
1166
|
-
exports.subset = subset;
|
|
1167
|
-
exports.sum = sum;
|
|
1168
|
-
exports.superset = superset;
|
|
1169
|
-
exports.thresholdFreedmanDiaconis = freedmanDiaconis;
|
|
1170
|
-
exports.thresholdScott = scott;
|
|
1171
|
-
exports.thresholdSturges = sturges;
|
|
1172
|
-
exports.tickIncrement = tickIncrement;
|
|
1173
|
-
exports.tickStep = tickStep;
|
|
1174
|
-
exports.ticks = ticks;
|
|
1175
|
-
exports.transpose = transpose;
|
|
1176
|
-
exports.union = union;
|
|
1177
|
-
exports.variance = variance;
|
|
1178
|
-
exports.zip = zip;
|
|
1179
|
-
|
|
1180
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1181
|
-
|
|
1182
|
-
})));
|