1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export type Primitive = number | string | boolean | Date;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export interface Numeric {
|
26 | valueOf(): number;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export function min(iterable: Iterable<string>): string | undefined;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | export function min<T extends Numeric>(iterable: Iterable<T>): T | undefined;
|
42 |
|
43 |
|
44 |
|
45 | export function min<T>(
|
46 | iterable: Iterable<T>,
|
47 | accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null
|
48 | ): string | undefined;
|
49 |
|
50 |
|
51 |
|
52 | export function min<T, U extends Numeric>(
|
53 | iterable: Iterable<T>,
|
54 | accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null
|
55 | ): U | undefined;
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | export function minIndex(iterable: Iterable<unknown>): number;
|
61 |
|
62 |
|
63 |
|
64 | export function minIndex<TDatum>(
|
65 | iterable: Iterable<TDatum>,
|
66 | accessor: (datum: TDatum, index: number, array: Iterable<TDatum>) => unknown
|
67 | ): number;
|
68 |
|
69 |
|
70 |
|
71 | export function minIndex(iterable: Iterable<unknown>): number;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | export function max(iterable: Iterable<string>): string | undefined;
|
77 |
|
78 |
|
79 |
|
80 | export function max<T extends Numeric>(iterable: Iterable<T>): T | undefined;
|
81 |
|
82 |
|
83 |
|
84 | export function max<T>(
|
85 | iterable: Iterable<T>,
|
86 | accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null
|
87 | ): string | undefined;
|
88 |
|
89 |
|
90 |
|
91 | export function max<T, U extends Numeric>(
|
92 | iterable: Iterable<T>,
|
93 | accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null
|
94 | ): U | undefined;
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export function maxIndex(iterable: Iterable<unknown>): number;
|
100 |
|
101 |
|
102 |
|
103 | export function maxIndex<TDatum>(
|
104 | iterable: Iterable<TDatum>,
|
105 | accessor: (datum: TDatum, index: number, array: Iterable<TDatum>) => unknown
|
106 | ): number;
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | export function extent(iterable: Iterable<string>): [string, string] | [undefined, undefined];
|
112 |
|
113 |
|
114 |
|
115 | export function extent<T extends Numeric>(iterable: Iterable<T>): [T, T] | [undefined, undefined];
|
116 |
|
117 |
|
118 |
|
119 | export function extent<T>(
|
120 | iterable: Iterable<T>,
|
121 | accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null
|
122 | ): [string, string] | [undefined, undefined];
|
123 |
|
124 |
|
125 |
|
126 | export function extent<T, U extends Numeric>(
|
127 | iterable: Iterable<T>,
|
128 | accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null
|
129 | ): [U, U] | [undefined, undefined];
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | export function mode(iterable: Iterable<Numeric | undefined | null>): number;
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | export function mode<T>(iterable: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number;
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | export function sum(iterable: Iterable<Numeric | undefined | null>): number;
|
152 |
|
153 |
|
154 |
|
155 | export function sum<T>(
|
156 | iterable: Iterable<T>,
|
157 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
158 | ): number;
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | export function mean(iterable: Iterable<Numeric | undefined | null>): number | undefined;
|
164 |
|
165 |
|
166 |
|
167 | export function mean<T>(
|
168 | iterable: Iterable<T>,
|
169 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
170 | ): number | undefined;
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | export function median(iterable: Iterable<Numeric | undefined | null>): number | undefined;
|
176 |
|
177 |
|
178 |
|
179 | export function median<T>(
|
180 | iterable: Iterable<T>,
|
181 | accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null
|
182 | ): number | undefined;
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | export function cumsum(iterable: Iterable<Numeric | undefined | null>): Float64Array;
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | export function cumsum<T>(
|
198 | iterable: Iterable<T>,
|
199 | accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null
|
200 | ): Float64Array;
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | export function quantile(iterable: Iterable<Numeric | undefined | null>, p: number): number | undefined;
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | export function quantile<T>(
|
214 | iterable: Iterable<T>,
|
215 | p: number,
|
216 | accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null
|
217 | ): number | undefined;
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | export function quantileSorted(
|
224 | array: Array<Numeric | undefined | null>,
|
225 | p: number
|
226 | ): number | undefined;
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | export function quantileSorted<T>(
|
232 | array: T[],
|
233 | p: number,
|
234 | accessor: (element: T, i: number, array: T[]) => number | undefined | null
|
235 | ): number | undefined;
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 | export function variance(iterable: Iterable<Numeric | undefined | null>): number | undefined;
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 | export function variance<T>(
|
251 | iterable: Iterable<T>,
|
252 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
253 | ): number | undefined;
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | export function deviation(iterable: Iterable<Numeric | undefined | null>): number | undefined;
|
259 |
|
260 |
|
261 |
|
262 |
|
263 | export function deviation<T>(
|
264 | iterable: Iterable<T>,
|
265 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
266 | ): number | undefined;
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 | export function fsum(values: Iterable<Numeric | undefined | null>): number;
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | export function fsum<T>(
|
278 | values: Iterable<T>,
|
279 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
280 | ): number;
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 | export function fcumsum(values: Iterable<Numeric | undefined | null>): Float64Array;
|
287 |
|
288 |
|
289 |
|
290 |
|
291 | export function fcumsum<T>(
|
292 | values: Iterable<T>,
|
293 | accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
|
294 | ): Float64Array;
|
295 |
|
296 | export class Adder {
|
297 | |
298 |
|
299 |
|
300 | constructor();
|
301 |
|
302 | /**
|
303 | * Adds the specified number to the adder’s current value and returns the adder.
|
304 | */
|
305 | add(number: number): Adder;
|
306 |
|
307 | /**
|
308 | * Returns the IEEE 754 double precision representation of the adder’s current value.
|
309 | * Most useful as the short-hand notation +adder.
|
310 | */
|
311 | valueOf(): number;
|
312 | }
|
313 |
|
314 | // --------------------------------------------------------------------------------------
|
315 | // Search
|
316 | // --------------------------------------------------------------------------------------
|
317 |
|
318 | /**
|
319 | * Returns the least element of the specified iterable according to the specified comparator.
|
320 | * If comparator is not specified, it defaults to ascending.
|
321 | */
|
322 | export function least<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T | undefined;
|
323 | /**
|
324 | * Returns the least element of the specified iterable according to the specified accessor.
|
325 | */
|
326 | export function least<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): T | undefined;
|
327 |
|
328 | /**
|
329 | * Returns the index of the least element of the specified iterable according to the specified comparator.
|
330 | */
|
331 | export function leastIndex(iterable: Iterable<unknown>): number | undefined;
|
332 | /**
|
333 | * Returns the index of the least element of the specified iterable according to the specified comparator.
|
334 | */
|
335 | export function leastIndex<T>(iterable: Iterable<T>, comparator: (a: T, b: T) => number): number | undefined;
|
336 | /**
|
337 | * Returns the index of the least element of the specified iterable according to the specified accessor.
|
338 | */
|
339 | // tslint:disable-next-line:unified-signatures
|
340 | export function leastIndex<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): number | undefined;
|
341 |
|
342 | /**
|
343 | * Returns the greatest element of the specified iterable according to the specified comparator or accessor.
|
344 | * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns undefined.
|
345 | * If comparator is not specified, it defaults to ascending.
|
346 | */
|
347 | export function greatest<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T | undefined;
|
348 | /**
|
349 | * Returns the greatest element of the specified iterable according to the specified comparator or accessor.
|
350 | * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns undefined.
|
351 | * If comparator is not specified, it defaults to ascending.
|
352 | */
|
353 | export function greatest<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): T | undefined;
|
354 |
|
355 | /**
|
356 | * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
|
357 | * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
|
358 | * If comparator is not specified, it defaults to ascending.
|
359 | */
|
360 | export function greatestIndex(iterable: Iterable<unknown>): number | undefined;
|
361 | /**
|
362 | * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
|
363 | * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
|
364 | * If comparator is not specified, it defaults to ascending.
|
365 | */
|
366 | export function greatestIndex<T>(iterable: Iterable<T>, comparator: (a: T, b: T) => number): number | undefined;
|
367 | /**
|
368 | * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
|
369 | * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
|
370 | * If comparator is not specified, it defaults to ascending.
|
371 | */
|
372 | // tslint:disable-next-line:unified-signatures
|
373 | export function greatestIndex<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): number | undefined;
|
374 |
|
375 | export function bisectLeft(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
376 | export function bisectLeft(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
377 | export function bisectLeft(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
|
378 |
|
379 | export function bisectRight(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
380 | export function bisectRight(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
381 | export function bisectRight(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
|
382 |
|
383 | export function bisectCenter(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
384 | export function bisectCenter(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
385 | export function bisectCenter(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
|
386 |
|
387 | export const bisect: typeof bisectRight;
|
388 |
|
389 | export interface Bisector<T, U> {
|
390 | left(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
|
391 | right(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
|
392 | center(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
|
393 | }
|
394 |
|
395 | export function bisector<T, U>(comparator: (a: T, b: U) => number): Bisector<T, U>;
|
396 |
|
397 | export function bisector<T, U>(accessor: (x: T) => U): Bisector<T, U>;
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 | export function quickselect<T>(array: ArrayLike<T>, k: number, left?: number, right?: number, compare?: (a: Primitive | undefined, b: Primitive | undefined) => number): T[];
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 | export function ascending(a: Primitive | undefined, b: Primitive | undefined): number;
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 | export function descending(a: Primitive | undefined, b: Primitive | undefined): number;
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 | export function group<TObject, TKey>(iterable: Iterable<TObject>, key: (value: TObject) => TKey): InternMap<TKey, TObject[]>;
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | export function group<TObject, TKey1, TKey2>(
|
441 | iterable: Iterable<TObject>,
|
442 | key1: (value: TObject) => TKey1,
|
443 | key2: (value: TObject) => TKey2
|
444 | ): InternMap<TKey1, InternMap<TKey2, TObject[]>>;
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 | export function group<TObject, TKey1, TKey2, TKey3>(
|
454 | iterable: Iterable<TObject>,
|
455 | key1: (value: TObject) => TKey1,
|
456 | key2: (value: TObject) => TKey2,
|
457 | key3: (value: TObject) => TKey3
|
458 | ): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TObject[]>>>;
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 | export function groups<TObject, TKey>(
|
467 | iterable: Iterable<TObject>,
|
468 | key: (value: TObject) => TKey
|
469 | ): Array<[TKey, TObject[]]>;
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | export function groups<TObject, TKey1, TKey2>(
|
478 | iterable: Iterable<TObject>,
|
479 | key1: (value: TObject) => TKey1,
|
480 | key2: (value: TObject) => TKey2
|
481 | ): Array<[TKey1, Array<[TKey2, TObject[]]>]>;
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | export function groups<TObject, TKey1, TKey2, TKey3>(
|
491 | iterable: Iterable<TObject>,
|
492 | key1: (value: TObject) => TKey1,
|
493 | key2: (value: TObject) => TKey2,
|
494 | key3: (value: TObject) => TKey3
|
495 | ): Array<[TKey1, Array<[TKey2, Array<[TKey3, TObject[]]>]>]>;
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 | export function flatGroup<TObject, TKey>(
|
504 | iterable: Iterable<TObject>,
|
505 | key: (value: TObject) => TKey
|
506 | ): Array<[TKey, TObject[]]>;
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 | export function flatGroup<TObject, TKey1, TKey2>(
|
515 | iterable: Iterable<TObject>,
|
516 | key1: (value: TObject) => TKey1,
|
517 | key2: (value: TObject) => TKey2
|
518 | ): Array<[TKey1, TKey2, TObject[]]>;
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 | export function flatGroup<TObject, TKey1, TKey2, TKey3>(
|
528 | iterable: Iterable<TObject>,
|
529 | key1: (value: TObject) => TKey1,
|
530 | key2: (value: TObject) => TKey2,
|
531 | key3: (value: TObject) => TKey3
|
532 | ): Array<[TKey1, TKey2, TKey3, TObject[]]>;
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | export function index<TObject, TKey>(iterable: Iterable<TObject>, key: (value: TObject) => TKey): InternMap<TKey, TObject>;
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 | export function index<TObject, TKey1, TKey2>(
|
549 | iterable: Iterable<TObject>,
|
550 | key1: (value: TObject) => TKey1,
|
551 | key2: (value: TObject) => TKey2
|
552 | ): InternMap<TKey1, InternMap<TKey2, TObject>>;
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 | export function index<TObject, TKey1, TKey2, TKey3>(
|
562 | iterable: Iterable<TObject>,
|
563 | key1: (value: TObject) => TKey1,
|
564 | key2: (value: TObject) => TKey2,
|
565 | key3: (value: TObject) => TKey3
|
566 | ): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TObject>>>;
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | export function indexes<TObject, TKey>(
|
575 | iterable: Iterable<TObject>,
|
576 | key: (value: TObject) => TKey
|
577 | ): Array<[TKey, TObject]>;
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 | export function indexes<TObject, TKey1, TKey2>(
|
586 | iterable: Iterable<TObject>,
|
587 | key1: (value: TObject) => TKey1,
|
588 | key2: (value: TObject) => TKey2
|
589 | ): Array<[TKey1, Array<[TKey2, TObject]>]>;
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 | export function indexes<TObject, TKey1, TKey2, TKey3>(
|
599 | iterable: Iterable<TObject>,
|
600 | key1: (value: TObject) => TKey1,
|
601 | key2: (value: TObject) => TKey2,
|
602 | key3: (value: TObject) => TKey3
|
603 | ): Array<[TKey1, Array<[TKey2, Array<[TKey3, TObject]>]>]>;
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 | export function rollup<TObject, TReduce, TKey>(
|
613 | iterable: Iterable<TObject>,
|
614 | reduce: (value: TObject[]) => TReduce,
|
615 | key: (value: TObject) => TKey
|
616 | ): InternMap<TKey, TReduce>;
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 | export function rollup<TObject, TReduce, TKey1, TKey2>(
|
626 | iterable: Iterable<TObject>,
|
627 | reduce: (value: TObject[]) => TReduce,
|
628 | key1: (value: TObject) => TKey1,
|
629 | key2: (value: TObject) => TKey2
|
630 | ): InternMap<TKey1, InternMap<TKey2, TReduce>>;
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 | export function rollup<TObject, TReduce, TKey1, TKey2, TKey3>(
|
641 | iterable: Iterable<TObject>,
|
642 | reduce: (value: TObject[]) => TReduce,
|
643 | key1: (value: TObject) => TKey1,
|
644 | key2: (value: TObject) => TKey2,
|
645 | key3: (value: TObject) => TKey3
|
646 | ): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TReduce>>>;
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 | export function rollups<TObject, TReduce, TKey>(
|
656 | iterable: Iterable<TObject>,
|
657 | reduce: (value: TObject[]) => TReduce,
|
658 | key: (value: TObject) => TKey
|
659 | ): Array<[TKey, TReduce]>;
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 | export function rollups<TObject, TReduce, TKey1, TKey2>(
|
669 | iterable: Iterable<TObject>,
|
670 | reduce: (value: TObject[]) => TReduce,
|
671 | key1: (value: TObject) => TKey1,
|
672 | key2: (value: TObject) => TKey2
|
673 | ): Array<[TKey1, Array<[TKey2, TReduce]>]>;
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | export function rollups<TObject, TReduce, TKey1, TKey2, TKey3>(
|
684 | iterable: Iterable<TObject>,
|
685 | reduce: (value: TObject[]) => TReduce,
|
686 | key1: (value: TObject) => TKey1,
|
687 | key2: (value: TObject) => TKey2,
|
688 | key3: (value: TObject) => TKey3
|
689 | ): Array<[TKey1, Array<[TKey2, Array<[TKey3, TReduce]>]>]>;
|
690 |
|
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 | export function flatRollup<TObject, TReduce, TKey>(
|
699 | iterable: Iterable<TObject>,
|
700 | reduce: (value: TObject[]) => TReduce,
|
701 | key: (value: TObject) => TKey
|
702 | ): Array<[TKey, TReduce]>;
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 | export function flatRollup<TObject, TReduce, TKey1, TKey2>(
|
712 | iterable: Iterable<TObject>,
|
713 | reduce: (value: TObject[]) => TReduce,
|
714 | key1: (value: TObject) => TKey1,
|
715 | key2: (value: TObject) => TKey2
|
716 | ): Array<[TKey1, TKey2, TReduce]>;
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 | export function flatRollup<TObject, TReduce, TKey1, TKey2, TKey3>(
|
727 | iterable: Iterable<TObject>,
|
728 | reduce: (value: TObject[]) => TReduce,
|
729 | key1: (value: TObject) => TKey1,
|
730 | key2: (value: TObject) => TKey2,
|
731 | key3: (value: TObject) => TKey3
|
732 | ): Array<[TKey1, TKey2, TKey3, TReduce]>;
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 | export function groupSort<TObject, TKey>(
|
739 | iterable: Iterable<TObject>,
|
740 | comparator: (a: TObject[], b: TObject[]) => number,
|
741 | key: (value: TObject) => TKey
|
742 | ): TKey[];
|
743 |
|
744 |
|
745 |
|
746 | export function groupSort<TObject, TKey>(
|
747 | iterable: Iterable<TObject>,
|
748 |
|
749 | accessor: (value: TObject[]) => unknown,
|
750 | key: (value: TObject) => TKey
|
751 | ): TKey[];
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | export function count(iterable: Iterable<unknown>): number;
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | export function count<TObject>(
|
766 | iterable: Iterable<TObject>,
|
767 | accessor: (a: TObject, b: TObject) => number | null | undefined
|
768 | ): number;
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 | export function cross<S, T>(a: Iterable<S>, b: Iterable<T>): Array<[S, T]>;
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | export function cross<S, T, U>(a: Iterable<S>, b: Iterable<T>, reducer: (a: S, b: T) => U): U[];
|
790 |
|
791 |
|
792 |
|
793 |
|
794 | export function merge<T>(iterables: Iterable<Iterable<T>>): T[];
|
795 |
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 | export function pairs<T>(iterable: Iterable<T>): Array<[T, T]>;
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 | export function pairs<T, U>(iterable: Iterable<T>, reducer: (a: T, b: T) => U): U[];
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 | export function permute<T>(source: { [key: number]: T; }, keys: Iterable<number>): T[];
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 | export function permute<T, K extends keyof T>(source: T, keys: Iterable<K>): Array<T[K]>;
|
827 |
|
828 |
|
829 |
|
830 |
|
831 | export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
|
832 | export function shuffle(array: Int8Array, lo?: number, hi?: number): Int8Array;
|
833 | export function shuffle(array: Uint8Array, lo?: number, hi?: number): Uint8Array;
|
834 | export function shuffle(array: Uint8ClampedArray, lo?: number, hi?: number): Uint8ClampedArray;
|
835 | export function shuffle(array: Int16Array, lo?: number, hi?: number): Int16Array;
|
836 | export function shuffle(array: Uint16Array, lo?: number, hi?: number): Uint16Array;
|
837 | export function shuffle(array: Int32Array, lo?: number, hi?: number): Int32Array;
|
838 | export function shuffle(array: Uint32Array, lo?: number, hi?: number): Uint32Array;
|
839 | export function shuffle(array: Float32Array, lo?: number, hi?: number): Float32Array;
|
840 | export function shuffle(array: Float64Array, lo?: number, hi?: number): Float64Array;
|
841 |
|
842 |
|
843 |
|
844 |
|
845 | export function shuffler(random: () => number): typeof shuffle;
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 | export function ticks(start: number, stop: number, count: number): number[];
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 | export function tickIncrement(start: number, stop: number, count: number): number;
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 | export function tickStep(start: number, stop: number, count: number): number;
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 | export function nice(start: number, stop: number, count: number): [number, number];
|
898 |
|
899 |
|
900 |
|
901 |
|
902 | export function range(stop: number): number[];
|
903 |
|
904 |
|
905 |
|
906 |
|
907 | export function range(start: number, stop: number, step?: number): number[];
|
908 |
|
909 |
|
910 |
|
911 |
|
912 | export function transpose<T>(matrix: ArrayLike<ArrayLike<T>>): T[][];
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 | export function zip<T>(...arrays: Array<ArrayLike<T>>): T[][];
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 | export function every<T>(
|
931 | iterable: Iterable<T>,
|
932 | test: (value: T, index: number, iterable: Iterable<T>) => unknown
|
933 | ): boolean;
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 | export function some<T>(
|
941 | iterable: Iterable<T>,
|
942 | test: (value: T, index: number, iterable: Iterable<T>) => unknown
|
943 | ): boolean;
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 | export function filter<T>(
|
950 | iterable: Iterable<T>,
|
951 | test: (value: T, index: number, iterable: Iterable<T>) => unknown
|
952 | ): T[];
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 | export function map<T, U>(iterable: Iterable<T>, mapper: (value: T, index: number, iterable: Iterable<T>) => U): U[];
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 | export function reduce<T>(
|
965 | iterable: Iterable<T>,
|
966 | reducer: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T,
|
967 | initialValue?: T
|
968 | ): T;
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | export function reduce<T, U>(
|
974 | iterable: Iterable<T>,
|
975 | reducer: (previousValue: U, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,
|
976 | initialValue: U
|
977 | ): U;
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 | export function reverse<T>(iterable: Iterable<T>): T[];
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 | export function sort<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T[];
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 | export function sort<T>(iterable: Iterable<T>, ...accessors: Array<(a: T) => unknown>): T[];
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 | export function difference<T>(iterable: Iterable<T>, ...others: Array<Iterable<T>>): Set<T>;
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 | export function union<T>(...iterables: Array<Iterable<T>>): Set<T>;
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 | export function intersection<T>(...iterables: Array<Iterable<T>>): Set<T>;
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 | export function superset<T>(a: Iterable<T>, b: Iterable<T>): boolean;
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 | export function subset<T>(a: Iterable<T>, b: Iterable<T>): boolean;
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 | export function disjoint<T>(a: Iterable<T>, b: Iterable<T>): boolean;
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 | export interface Bin<Datum, Value extends number | Date | undefined> extends Array<Datum> {
|
1040 | x0: Value | undefined;
|
1041 | x1: Value | undefined;
|
1042 | }
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 | export type ThresholdCountGenerator<Value extends number | undefined = number | undefined> =
|
1048 | (values: ArrayLike<Value>, min: number, max: number) => number;
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 | export type ThresholdNumberArrayGenerator<Value extends number | undefined> =
|
1054 | (values: ArrayLike<Value>, min: number, max: number) => Value[];
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 | export type ThresholdDateArrayGenerator<Value extends Date | undefined> =
|
1060 | (values: ArrayLike<Value>, min: Date, max: Date) => Value[];
|
1061 |
|
1062 | export interface HistogramCommon<Datum, Value extends number | Date | undefined> {
|
1063 | (data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
|
1064 |
|
1065 | value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
|
1066 | value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
|
1067 | }
|
1068 |
|
1069 | export interface HistogramGeneratorDate<Datum, Value extends Date | undefined> extends HistogramCommon<Datum, Date> {
|
1070 | domain(): (values: ArrayLike<Value>) => [Date, Date];
|
1071 | domain(domain: [Date, Date] | ((values: ArrayLike<Value>) => [Date, Date])): this;
|
1072 |
|
1073 | thresholds(): ThresholdDateArrayGenerator<Value>;
|
1074 | /**
|
1075 | * Set the array of values to be used as thresholds in determining the bins.
|
1076 | *
|
1077 | * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
1078 | * and the last bin.x1 is always equal to the maximum domain value.
|
1079 | *
|
1080 | * @param thresholds Either an array of threshold values used for binning. The elements must
|
1081 | * be of the same type as the materialized values of the histogram.
|
1082 | * Or a function which accepts as arguments the array of materialized values, and
|
1083 | * optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
|
1084 | * thresholds in determining the bins.
|
1085 | */
|
1086 | thresholds(thresholds: ArrayLike<Value> | ThresholdDateArrayGenerator<Value>): this;
|
1087 | }
|
1088 |
|
1089 | export interface HistogramGeneratorNumber<Datum, Value extends number | undefined> extends HistogramCommon<Datum, Value> {
|
1090 | domain(): (values: Iterable<Value>) => [number, number] | [undefined, undefined];
|
1091 | domain(domain: [number, number] | ((values: Iterable<Value>) => [number, number] | [undefined, undefined])): this;
|
1092 |
|
1093 | thresholds(): ThresholdCountGenerator<Value> | ThresholdNumberArrayGenerator<Value>;
|
1094 | /**
|
1095 | * Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
|
1096 | * setting approach only works, when the materialized values are numbers!
|
1097 | *
|
1098 | * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
1099 | * and the last bin.x1 is always equal to the maximum domain value.
|
1100 | *
|
1101 | * @param count Either the desired number of uniform bins or a function which accepts as arguments the array of
|
1102 | * materialized values, and optionally the domain minimum and maximum. The function calculates and returns the
|
1103 | * suggested number of bins.
|
1104 | */
|
1105 | thresholds(count: number | ThresholdCountGenerator<Value>): this;
|
1106 | /**
|
1107 | * Set the array of values to be used as thresholds in determining the bins.
|
1108 | *
|
1109 | * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
1110 | * and the last bin.x1 is always equal to the maximum domain value.
|
1111 | *
|
1112 | * @param thresholds Either an array of threshold values used for binning. The elements must
|
1113 | * be of the same type as the materialized values of the histogram.
|
1114 | * Or a function which accepts as arguments the array of materialized values, and
|
1115 | * optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
|
1116 | * thresholds in determining the bins.
|
1117 | */
|
1118 | // tslint:disable-next-line:unified-signatures
|
1119 | thresholds(thresholds: ArrayLike<Value> | ThresholdNumberArrayGenerator<Value>): this;
|
1120 | }
|
1121 |
|
1122 | /**
|
1123 | * @deprecated. Use bin instead.
|
1124 | */
|
1125 | export function histogram(): HistogramGeneratorNumber<number, number>;
|
1126 |
|
1127 | /**
|
1128 | * @deprecated Use bin instead.
|
1129 | */
|
1130 | // tslint:disable-next-line:no-unnecessary-generics
|
1131 | export function histogram<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
|
1132 |
|
1133 | /**
|
1134 | * @deprecated Use bin instead.
|
1135 | */
|
1136 | // tslint:disable-next-line:no-unnecessary-generics
|
1137 | export function histogram<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
|
1138 |
|
1139 | export function bin(): HistogramGeneratorNumber<number, number>;
|
1140 | // tslint:disable-next-line:no-unnecessary-generics
|
1141 | export function bin<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
|
1142 | // tslint:disable-next-line:no-unnecessary-generics
|
1143 | export function bin<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
|
1144 |
|
1145 | // --------------------------------------------------------------------------------------
|
1146 | // Histogram Thresholds
|
1147 | // --------------------------------------------------------------------------------------
|
1148 |
|
1149 | export function thresholdFreedmanDiaconis(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
|
1150 |
|
1151 | export function thresholdScott(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
|
1152 |
|
1153 | export function thresholdSturges(values: ArrayLike<number | undefined>): number; // of type ThresholdCountGenerator
|
1154 |
|
1155 | // --------------------------------------------------------------------------------------
|
1156 | // Interning
|
1157 | // --------------------------------------------------------------------------------------
|
1158 |
|
1159 | /**
|
1160 | * The InternMap class extends the native JavaScript Map class, allowing Dates and other non-primitive keys by bypassing the SameValueZero algorithm when determining key equality.
|
1161 | */
|
1162 | export class InternMap<K = any, V = any> extends Map<K, V> {
|
1163 | }
|
1164 |
|
1165 | /**
|
1166 | * The InternSet class extends the native JavaScript Set class, allowing Dates and other non-primitive keys by bypassing the SameValueZero algorithm when determining key equality.
|
1167 | */
|
1168 | export class InternSet<T = any> extends Set<T> {
|
1169 | }
|
1170 |
|
\ | No newline at end of file |