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