UNPKG

51.5 kBTypeScriptView Raw
1// Type definitions for D3JS d3-array module 3.0
2// Project: https://github.com/d3/d3-array, https://d3js.org/d3-array
3// Definitions by: Alex Ford <https://github.com/gustavderdrache>
4// Boris Yankov <https://github.com/borisyankov>
5// Tom Wanzek <https://github.com/tomwanzek>
6// denisname <https://github.com/denisname>
7// Hugues Stefanski <https://github.com/ledragon>
8// Nathan Bierema <https://github.com/Methuselah96>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10
11// Last module patch version validated against: 3.1.0
12
13// --------------------------------------------------------------------------
14// Shared Types and Interfaces
15// --------------------------------------------------------------------------
16
17/**
18 * Administrivia: JavaScript primitive types and Date
19 */
20export type Primitive = number | string | boolean | Date;
21
22/**
23 * Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations
24 */
25export interface Numeric {
26 valueOf(): number;
27}
28
29// --------------------------------------------------------------------------------------
30// Statistics
31// --------------------------------------------------------------------------------------
32
33/**
34 * Return the minimum value in the array using natural order.
35 */
36export function min(iterable: Iterable<string>): string | undefined;
37
38/**
39 * Return the minimum value in the array using natural order.
40 */
41export function min<T extends Numeric>(iterable: Iterable<T>): T | undefined;
42/**
43 * Return the minimum value in the array using natural order.
44 */
45export function min<T>(
46 iterable: Iterable<T>,
47 accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null
48): string | undefined;
49/**
50 * Return the minimum value in the array using natural order.
51 */
52export 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 * Return the index of the minimum value in the array using natural order.
59 */
60export function minIndex(iterable: Iterable<unknown>): number;
61/**
62 * Return the index of the minimum value in the array using natural order and a projection function to map values.
63 */
64export function minIndex<TDatum>(
65 iterable: Iterable<TDatum>,
66 accessor: (datum: TDatum, index: number, array: Iterable<TDatum>) => unknown
67): number;
68/**
69 * Return the index of the minimum value in the array using natural order.
70 */
71export function minIndex(iterable: Iterable<unknown>): number;
72
73/**
74 * Return the maximum value in the array of strings using natural order.
75 */
76export function max(iterable: Iterable<string>): string | undefined;
77/**
78 * Return the maximum value in the array of numbers using natural order.
79 */
80export function max<T extends Numeric>(iterable: Iterable<T>): T | undefined;
81/**
82 * Return the maximum value in the array using natural order and a projection function to map values to strings.
83 */
84export function max<T>(
85 iterable: Iterable<T>,
86 accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null
87): string | undefined;
88/**
89 * Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values.
90 */
91export 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 * Return the index of the maximum value in the array using natural order.
98 */
99export function maxIndex(iterable: Iterable<unknown>): number;
100/**
101 * Return the index of the maximum value in the array using natural order and a projection function to map values.
102 */
103export function maxIndex<TDatum>(
104 iterable: Iterable<TDatum>,
105 accessor: (datum: TDatum, index: number, array: Iterable<TDatum>) => unknown
106): number;
107
108/**
109 * Return the min and max simultaneously.
110 */
111export function extent(iterable: Iterable<string>): [string, string] | [undefined, undefined];
112/**
113 * Return the min and max simultaneously.
114 */
115export function extent<T extends Numeric>(iterable: Iterable<T>): [T, T] | [undefined, undefined];
116/**
117 * Return the min and max simultaneously.
118 */
119export 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 * Return the min and max simultaneously.
125 */
126export 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 * Returns the mode of the given iterable, i.e. the value which appears the most often.
133 * In case of equality, returns the first of the relevant values.
134 * If the iterable contains no comparable values, returns undefined.
135 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the mode.
136 * This method ignores undefined, null and NaN values; this is useful for ignoring missing data.
137 */
138export function mode(iterable: Iterable<Numeric | undefined | null>): number;
139/**
140 * Returns the mode of the given iterable, i.e. the value which appears the most often.
141 * In case of equality, returns the first of the relevant values.
142 * If the iterable contains no comparable values, returns undefined.
143 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the mode.
144 * This method ignores undefined, null and NaN values; this is useful for ignoring missing data.
145 */
146export function mode<T>(iterable: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number;
147
148/**
149 * Compute the sum of an array of numbers.
150 */
151export function sum(iterable: Iterable<Numeric | undefined | null>): number;
152/**
153 * Compute the sum of an array, using the given accessor to convert values to numbers.
154 */
155export function sum<T>(
156 iterable: Iterable<T>,
157 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
158): number;
159
160/**
161 * Return the mean of an array of numbers
162 */
163export function mean(iterable: Iterable<Numeric | undefined | null>): number | undefined;
164/**
165 * Return the mean of an array of numbers
166 */
167export 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 * Return the median of an array of numbers
174 */
175export function median(iterable: Iterable<Numeric | undefined | null>): number | undefined;
176/**
177 * Return the median of an array of numbers
178 */
179export 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 * Returns the cumulative sum of the given iterable of numbers, as a Float64Array of the same length.
186 * If the iterable contains no numbers, returns zeros.
187 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the cumulative sum.
188 * This method ignores undefined and NaN values; this is useful for ignoring missing data.
189 */
190export function cumsum(iterable: Iterable<Numeric | undefined | null>): Float64Array;
191/**
192 * Returns the cumulative sum of the given iterable of numbers, as a Float64Array of the same length.
193 * If the iterable contains no numbers, returns zeros.
194 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the cumulative sum.
195 * This method ignores undefined and NaN values; this is useful for ignoring missing data.
196 */
197export function cumsum<T>(
198 iterable: Iterable<T>,
199 accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null
200): Float64Array;
201
202/**
203 * Returns the p-quantile of the given iterable of numbers, where p is a number in the range [0, 1].
204 *
205 * An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the quantile.
206 */
207export function quantile(iterable: Iterable<Numeric | undefined | null>, p: number): number | undefined;
208/**
209 * Returns the p-quantile of the given iterable of numbers, where p is a number in the range [0, 1].
210 *
211 * An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the quantile.
212 */
213export 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 * Similar to quantile, but expects the input to be a sorted array of values.
221 * In contrast with quantile, the accessor is only called on the elements needed to compute the quantile.
222 */
223export function quantileSorted(
224 array: Array<Numeric | undefined | null>,
225 p: number
226): number | undefined;
227/**
228 * Similar to quantile, but expects the input to be a sorted array of values.
229 * In contrast with quantile, the accessor is only called on the elements needed to compute the quantile.
230 */
231export 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 * Returns an array with the rank of each value in the iterable, i.e. the index of the value when the iterable is sorted.
239 * Nullish values are sorted to the end and ranked NaN.
240 * An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the ranks.
241 * Ties (equivalent values) all get the same rank, defined as the first time the value is found.
242 */
243export function rank(iterable: Iterable<Numeric | undefined | null>): Float64Array;
244/**
245 * Returns an array with the rank of each value in the iterable, i.e. the index of the value when the iterable is sorted.
246 * Nullish values are sorted to the end and ranked NaN.
247 * An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the ranks.
248 * Ties (equivalent values) all get the same rank, defined as the first time the value is found.
249 */
250export function rank<T>(
251 iterable: Iterable<T>,
252 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
253): Float64Array;
254
255/**
256 * Returns an unbiased estimator of the population variance of the given iterable of numbers using Welford’s algorithm.
257 * If the iterable has fewer than two numbers, returns undefined.
258 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the variance.
259 * This method ignores undefined and NaN values; this is useful for ignoring missing data.
260 */
261export function variance(iterable: Iterable<Numeric | undefined | null>): number | undefined;
262/**
263 * Returns an unbiased estimator of the population variance of the given iterable of numbers using Welford’s algorithm.
264 * If the iterable has fewer than two numbers, returns undefined.
265 * An optional accessor function may be specified, which is equivalent to calling Array.from before computing the variance.
266 * This method ignores undefined and NaN values; this is useful for ignoring missing data.
267 */
268export function variance<T>(
269 iterable: Iterable<T>,
270 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
271): number | undefined;
272
273/**
274 * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers.
275 */
276export function deviation(iterable: Iterable<Numeric | undefined | null>): number | undefined;
277/**
278 * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
279 * using the given accessor to convert values to numbers.
280 */
281export function deviation<T>(
282 iterable: Iterable<T>,
283 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
284): number | undefined;
285
286/**
287 * Returns a full precision summation of the given values.
288 * Although slower, d3.fsum can replace d3.sum wherever greater precision is needed. Uses d3.Adder.
289 */
290export function fsum(values: Iterable<Numeric | undefined | null>): number;
291/**
292 * Returns a full precision summation of the given values.
293 * Although slower, d3.fsum can replace d3.sum wherever greater precision is needed. Uses d3.Adder.
294 */
295export function fsum<T>(
296 values: Iterable<T>,
297 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
298): number;
299
300/**
301 * Returns a full precision cumulative sum of the given values.
302 * Although slower, d3.fcumsum can replace d3.cumsum when greater precision is needed. Uses d3.Adder.
303 */
304export function fcumsum(values: Iterable<Numeric | undefined | null>): Float64Array;
305/**
306 * Returns a full precision cumulative sum of the given values.
307 * Although slower, d3.fcumsum can replace d3.cumsum when greater precision is needed. Uses d3.Adder.
308 */
309export function fcumsum<T>(
310 values: Iterable<T>,
311 accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
312): Float64Array;
313
314export class Adder {
315 /**
316 * Creates a full precision adder for IEEE 754 floating point numbers, setting its initial value to 0.
317 */
318 constructor();
319
320 /**
321 * Adds the specified number to the adder’s current value and returns the adder.
322 */
323 add(number: number): Adder;
324
325 /**
326 * Returns the IEEE 754 double precision representation of the adder’s current value.
327 * Most useful as the short-hand notation +adder.
328 */
329 valueOf(): number;
330}
331
332// --------------------------------------------------------------------------------------
333// Search
334// --------------------------------------------------------------------------------------
335
336/**
337 * Returns the least element of the specified iterable according to the specified comparator.
338 * If comparator is not specified, it defaults to ascending.
339 */
340export function least<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T | undefined;
341/**
342 * Returns the least element of the specified iterable according to the specified accessor.
343 */
344export function least<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): T | undefined;
345
346/**
347 * Returns the index of the least element of the specified iterable according to the specified comparator.
348 */
349export function leastIndex(iterable: Iterable<unknown>): number | undefined;
350/**
351 * Returns the index of the least element of the specified iterable according to the specified comparator.
352 */
353export function leastIndex<T>(iterable: Iterable<T>, comparator: (a: T, b: T) => number): number | undefined;
354/**
355 * Returns the index of the least element of the specified iterable according to the specified accessor.
356 */
357// tslint:disable-next-line:unified-signatures
358export function leastIndex<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): number | undefined;
359
360/**
361 * Returns the greatest element of the specified iterable according to the specified comparator or accessor.
362 * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns undefined.
363 * If comparator is not specified, it defaults to ascending.
364 */
365export function greatest<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T | undefined;
366/**
367 * Returns the greatest element of the specified iterable according to the specified comparator or accessor.
368 * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns undefined.
369 * If comparator is not specified, it defaults to ascending.
370 */
371export function greatest<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): T | undefined;
372
373/**
374 * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
375 * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
376 * If comparator is not specified, it defaults to ascending.
377 */
378export function greatestIndex(iterable: Iterable<unknown>): number | undefined;
379/**
380 * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
381 * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
382 * If comparator is not specified, it defaults to ascending.
383 */
384export function greatestIndex<T>(iterable: Iterable<T>, comparator: (a: T, b: T) => number): number | undefined;
385/**
386 * Returns the index of the greatest element of the specified iterable according to the specified comparator or accessor.
387 * If the given iterable contains no comparable elements (i.e., the comparator returns NaN when comparing each element to itself), returns -1.
388 * If comparator is not specified, it defaults to ascending.
389 */
390// tslint:disable-next-line:unified-signatures
391export function greatestIndex<T>(iterable: Iterable<T>, accessor: (a: T) => unknown): number | undefined;
392
393export function bisectLeft(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
394export function bisectLeft(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
395export function bisectLeft(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
396
397export function bisectRight(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
398export function bisectRight(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
399export function bisectRight(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
400
401export function bisectCenter(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
402export function bisectCenter(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
403export function bisectCenter(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
404
405export const bisect: typeof bisectRight;
406
407export interface Bisector<T, U> {
408 left(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
409 right(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
410 center(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
411}
412
413export function bisector<T, U>(comparator: (a: T, b: U) => number): Bisector<T, U>;
414// tslint:disable-next-line:unified-signatures
415export function bisector<T, U>(accessor: (x: T) => U): Bisector<T, U>;
416
417/**
418 * Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
419 *
420 * @param array The array to partially sort (in place).
421 * @param k The middle index for partial sorting.
422 * @param left The left index of the range to sort.
423 * @param right The right index.
424 * @param compare The compare function.
425 */
426export function quickselect<T>(array: ArrayLike<T>, k: number, left?: number, right?: number, compare?: (a: Primitive | undefined, b: Primitive | undefined) => number): T[];
427
428// NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances.
429/**
430 * Compares two primitive values for sorting (in ascending order).
431 */
432export function ascending(a: Primitive | undefined, b: Primitive | undefined): number;
433
434// NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances.
435/**
436 * Compares two primitive values for sorting (in descending order).
437 */
438export function descending(a: Primitive | undefined, b: Primitive | undefined): number;
439
440// --------------------------------------------------------------------------------------
441// Transformations
442// --------------------------------------------------------------------------------------
443
444/**
445 * Groups the specified array of values into an InternMap from key to array of value.
446 *
447 * @param iterable The array to group.
448 * @param key The key function.
449 */
450export function group<TObject, TKey>(iterable: Iterable<TObject>, key: (value: TObject) => TKey): InternMap<TKey, TObject[]>;
451/**
452 * Groups the specified array of values into an InternMap from key to array of value.
453 *
454 * @param iterable The array to group.
455 * @param key1 The first key function.
456 * @param key2 The second key function.
457 */
458export function group<TObject, TKey1, TKey2>(
459 iterable: Iterable<TObject>,
460 key1: (value: TObject) => TKey1,
461 key2: (value: TObject) => TKey2
462): InternMap<TKey1, InternMap<TKey2, TObject[]>>;
463/**
464 * Groups the specified array of values into an InternMap from key to array of value.
465 *
466 * @param iterable The array to group.
467 * @param key1 The first key function.
468 * @param key2 The second key function.
469 * @param key3 The third key function.
470 */
471export function group<TObject, TKey1, TKey2, TKey3>(
472 iterable: Iterable<TObject>,
473 key1: (value: TObject) => TKey1,
474 key2: (value: TObject) => TKey2,
475 key3: (value: TObject) => TKey3
476): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TObject[]>>>;
477
478/**
479 * Equivalent to group, but returns nested arrays instead of nested maps.
480 *
481 * @param iterable The array to group.
482 * @param key The key function.
483 */
484export function groups<TObject, TKey>(
485 iterable: Iterable<TObject>,
486 key: (value: TObject) => TKey
487): Array<[TKey, TObject[]]>;
488/**
489 * Equivalent to group, but returns nested arrays instead of nested maps.
490 *
491 * @param iterable The array to group.
492 * @param key1 The first key function.
493 * @param key2 The second key function.
494 */
495export function groups<TObject, TKey1, TKey2>(
496 iterable: Iterable<TObject>,
497 key1: (value: TObject) => TKey1,
498 key2: (value: TObject) => TKey2
499): Array<[TKey1, Array<[TKey2, TObject[]]>]>;
500/**
501 * Equivalent to group, but returns nested arrays instead of nested maps.
502 *
503 * @param iterable The array to group.
504 * @param key1 The first key function.
505 * @param key2 The second key function.
506 * @param key3 The third key function.
507 */
508export function groups<TObject, TKey1, TKey2, TKey3>(
509 iterable: Iterable<TObject>,
510 key1: (value: TObject) => TKey1,
511 key2: (value: TObject) => TKey2,
512 key3: (value: TObject) => TKey3
513): Array<[TKey1, Array<[TKey2, Array<[TKey3, TObject[]]>]>]>;
514
515/**
516 * Equivalent to group, but returns a flat array of [key0, key1, …, values] instead of nested maps.
517 *
518 * @param iterable The array to group.
519 * @param key The key function.
520 */
521export function flatGroup<TObject, TKey>(
522 iterable: Iterable<TObject>,
523 key: (value: TObject) => TKey
524): Array<[TKey, TObject[]]>;
525/**
526 * Equivalent to group, but returns a flat array of [key0, key1, …, values] instead of nested maps.
527 *
528 * @param iterable The array to group.
529 * @param key1 The first key function.
530 * @param key2 The second key function.
531 */
532export function flatGroup<TObject, TKey1, TKey2>(
533 iterable: Iterable<TObject>,
534 key1: (value: TObject) => TKey1,
535 key2: (value: TObject) => TKey2
536): Array<[TKey1, TKey2, TObject[]]>;
537/**
538 * Equivalent to group, but returns a flat array of [key0, key1, …, values] instead of nested maps.
539 *
540 * @param iterable The array to group.
541 * @param key1 The first key function.
542 * @param key2 The second key function.
543 * @param key3 The third key function.
544 */
545export function flatGroup<TObject, TKey1, TKey2, TKey3>(
546 iterable: Iterable<TObject>,
547 key1: (value: TObject) => TKey1,
548 key2: (value: TObject) => TKey2,
549 key3: (value: TObject) => TKey3
550): Array<[TKey1, TKey2, TKey3, TObject[]]>;
551
552/**
553 * Equivalent to group but returns a unique value per compound key instead of an array, throwing if the key is not unique.
554 *
555 * @param iterable The array to group.
556 * @param key The key function.
557 */
558export function index<TObject, TKey>(iterable: Iterable<TObject>, key: (value: TObject) => TKey): InternMap<TKey, TObject>;
559/**
560 * Equivalent to group but returns a unique value per compound key instead of an array, throwing if the key is not unique.
561 *
562 * @param iterable The array to group.
563 * @param key1 The first key function.
564 * @param key2 The second key function.
565 */
566export function index<TObject, TKey1, TKey2>(
567 iterable: Iterable<TObject>,
568 key1: (value: TObject) => TKey1,
569 key2: (value: TObject) => TKey2
570): InternMap<TKey1, InternMap<TKey2, TObject>>;
571/**
572 * Equivalent to group but returns a unique value per compound key instead of an array, throwing if the key is not unique.
573 *
574 * @param iterable The array to group.
575 * @param key1 The first key function.
576 * @param key2 The second key function.
577 * @param key3 The third key function.
578 */
579export function index<TObject, TKey1, TKey2, TKey3>(
580 iterable: Iterable<TObject>,
581 key1: (value: TObject) => TKey1,
582 key2: (value: TObject) => TKey2,
583 key3: (value: TObject) => TKey3
584): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TObject>>>;
585
586/**
587 * Equivalent to index, but returns nested arrays instead of nested maps.
588 *
589 * @param iterable The array to group.
590 * @param key The key function.
591 */
592export function indexes<TObject, TKey>(
593 iterable: Iterable<TObject>,
594 key: (value: TObject) => TKey
595): Array<[TKey, TObject]>;
596/**
597 * Equivalent to index, but returns nested arrays instead of nested maps.
598 *
599 * @param iterable The array to group.
600 * @param key1 The first key function.
601 * @param key2 The second key function.
602 */
603export function indexes<TObject, TKey1, TKey2>(
604 iterable: Iterable<TObject>,
605 key1: (value: TObject) => TKey1,
606 key2: (value: TObject) => TKey2
607): Array<[TKey1, Array<[TKey2, TObject]>]>;
608/**
609 * Equivalent to index, but returns nested arrays instead of nested maps.
610 *
611 * @param iterable The array to group.
612 * @param key1 The first key function.
613 * @param key2 The second key function.
614 * @param key3 The third key function.
615 */
616export function indexes<TObject, TKey1, TKey2, TKey3>(
617 iterable: Iterable<TObject>,
618 key1: (value: TObject) => TKey1,
619 key2: (value: TObject) => TKey2,
620 key3: (value: TObject) => TKey3
621): Array<[TKey1, Array<[TKey2, Array<[TKey3, TObject]>]>]>;
622
623/**
624 * Groups and reduces the specified array of values into an InternMap from key to value.
625 *
626 * @param iterable The array to group.
627 * @param reduce The reduce function.
628 * @param key The key function.
629 */
630export function rollup<TObject, TReduce, TKey>(
631 iterable: Iterable<TObject>,
632 reduce: (value: TObject[]) => TReduce,
633 key: (value: TObject) => TKey
634): InternMap<TKey, TReduce>;
635/**
636 * Groups and reduces the specified array of values into an InternMap from key to value.
637 *
638 * @param iterable The array to group.
639 * @param reduce The reduce function.
640 * @param key1 The first key function.
641 * @param key2 The second key function.
642 */
643export function rollup<TObject, TReduce, TKey1, TKey2>(
644 iterable: Iterable<TObject>,
645 reduce: (value: TObject[]) => TReduce,
646 key1: (value: TObject) => TKey1,
647 key2: (value: TObject) => TKey2
648): InternMap<TKey1, InternMap<TKey2, TReduce>>;
649/**
650 * Groups and reduces the specified array of values into an InternMap from key to value.
651 *
652 * @param iterable The array to group.
653 * @param reduce The reduce function.
654 * @param key1 The first key function.
655 * @param key2 The second key function.
656 * @param key3 The third key function.
657 */
658export function rollup<TObject, TReduce, TKey1, TKey2, TKey3>(
659 iterable: Iterable<TObject>,
660 reduce: (value: TObject[]) => TReduce,
661 key1: (value: TObject) => TKey1,
662 key2: (value: TObject) => TKey2,
663 key3: (value: TObject) => TKey3
664): InternMap<TKey1, InternMap<TKey2, InternMap<TKey3, TReduce>>>;
665
666/**
667 * Equivalent to rollup, but returns nested arrays instead of nested maps.
668 *
669 * @param iterable The array to group.
670 * @param reduce The reduce function.
671 * @param key The key function.
672 */
673export function rollups<TObject, TReduce, TKey>(
674 iterable: Iterable<TObject>,
675 reduce: (value: TObject[]) => TReduce,
676 key: (value: TObject) => TKey
677): Array<[TKey, TReduce]>;
678/**
679 * Equivalent to rollup, but returns nested arrays instead of nested maps.
680 *
681 * @param iterable The array to group.
682 * @param reduce The reduce function.
683 * @param key1 The first key function.
684 * @param key2 The second key function.
685 */
686export function rollups<TObject, TReduce, TKey1, TKey2>(
687 iterable: Iterable<TObject>,
688 reduce: (value: TObject[]) => TReduce,
689 key1: (value: TObject) => TKey1,
690 key2: (value: TObject) => TKey2
691): Array<[TKey1, Array<[TKey2, TReduce]>]>;
692/**
693 * Equivalent to rollup, but returns nested arrays instead of nested maps.
694 *
695 * @param iterable The array to group.
696 * @param reduce The reduce function.
697 * @param key1 The first key function.
698 * @param key2 The second key function.
699 * @param key3 The third key function.
700 */
701export function rollups<TObject, TReduce, TKey1, TKey2, TKey3>(
702 iterable: Iterable<TObject>,
703 reduce: (value: TObject[]) => TReduce,
704 key1: (value: TObject) => TKey1,
705 key2: (value: TObject) => TKey2,
706 key3: (value: TObject) => TKey3
707): Array<[TKey1, Array<[TKey2, Array<[TKey3, TReduce]>]>]>;
708
709/**
710 * Equivalent to rollup, but returns a flat array of [key0, key1, …, value] instead of nested maps.
711 *
712 * @param iterable The array to group.
713 * @param reduce The reduce function.
714 * @param key The key function.
715 */
716export function flatRollup<TObject, TReduce, TKey>(
717 iterable: Iterable<TObject>,
718 reduce: (value: TObject[]) => TReduce,
719 key: (value: TObject) => TKey
720): Array<[TKey, TReduce]>;
721/**
722 * Equivalent to rollup, but returns a flat array of [key0, key1, …, value] instead of nested maps.
723 *
724 * @param iterable The array to group.
725 * @param reduce The reduce function.
726 * @param key1 The first key function.
727 * @param key2 The second key function.
728 */
729export function flatRollup<TObject, TReduce, TKey1, TKey2>(
730 iterable: Iterable<TObject>,
731 reduce: (value: TObject[]) => TReduce,
732 key1: (value: TObject) => TKey1,
733 key2: (value: TObject) => TKey2
734): Array<[TKey1, TKey2, TReduce]>;
735/**
736 * Equivalent to rollup, but returns a flat array of [key0, key1, …, value] instead of nested maps.
737 *
738 * @param iterable The array to group.
739 * @param reduce The reduce function.
740 * @param key1 The first key function.
741 * @param key2 The second key function.
742 * @param key3 The third key function.
743 */
744export function flatRollup<TObject, TReduce, TKey1, TKey2, TKey3>(
745 iterable: Iterable<TObject>,
746 reduce: (value: TObject[]) => TReduce,
747 key1: (value: TObject) => TKey1,
748 key2: (value: TObject) => TKey2,
749 key3: (value: TObject) => TKey3
750): Array<[TKey1, TKey2, TKey3, TReduce]>;
751
752/**
753 * Groups the specified iterable of elements according to the specified key function, sorts the groups according to the specified comparator, and then returns an array of keys in sorted order.
754 * The comparator will be asked to compare two groups a and b and should return a negative value if a should be before b, a positive value if a should be after b, or zero for a partial ordering.
755 */
756export function groupSort<TObject, TKey>(
757 iterable: Iterable<TObject>,
758 comparator: (a: TObject[], b: TObject[]) => number,
759 key: (value: TObject) => TKey
760): TKey[];
761/**
762 * Groups the specified iterable of elements according to the specified key function, sorts the groups according to the specified accessor, and then returns an array of keys in sorted order.
763 */
764export function groupSort<TObject, TKey>(
765 iterable: Iterable<TObject>,
766 // tslint:disable-next-line:unified-signatures
767 accessor: (value: TObject[]) => unknown,
768 key: (value: TObject) => TKey
769): TKey[];
770
771/**
772 * Returns the number of valid number values (i.e., not null, NaN, or undefined) in the specified iterable; accepts an accessor.
773 *
774 * @param iterable Input array.
775 */
776export function count(iterable: Iterable<unknown>): number;
777/**
778 * Returns the number of valid number values (i.e., not null, NaN, or undefined) in the specified iterable; accepts an accessor.
779 *
780 * @param iterable Input array.
781 * @param accessor Accessor method.
782 */
783export function count<TObject>(
784 iterable: Iterable<TObject>,
785 accessor: (a: TObject, b: TObject) => number | null | undefined
786): number;
787
788/**
789 * Returns the Cartesian product of the two arrays a and b.
790 * For each element i in the specified array a and each element j in the specified array b, in order,
791 * it creates a two-element array for each pair.
792 *
793 * @param a First input array.
794 * @param b Second input array.
795 */
796export function cross<S, T>(a: Iterable<S>, b: Iterable<T>): Array<[S, T]>;
797
798/**
799 * Returns the Cartesian product of the two arrays a and b.
800 * For each element i in the specified array a and each element j in the specified array b, in order,
801 * invokes the specified reducer function passing the element i and element j.
802 *
803 * @param a First input array.
804 * @param b Second input array.
805 * @param reducer A reducer function taking as input an element from "a" and "b" and returning a reduced value.
806 */
807export function cross<S, T, U>(a: Iterable<S>, b: Iterable<T>, reducer: (a: S, b: T) => U): U[];
808
809/**
810 * Merges the specified arrays into a single array.
811 */
812export function merge<T>(iterables: Iterable<Iterable<T>>): T[];
813
814/**
815 * For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1.
816 * Returns the empty array if the input array has fewer than two elements.
817 *
818 * @param iterable Array of input elements
819 */
820export function pairs<T>(iterable: Iterable<T>): Array<[T, T]>;
821/**
822 * For each adjacent pair of elements in the specified array, in order, invokes the specified reducer function passing the element i and element i - 1.
823 * Returns the resulting array of pair-wise reduced elements.
824 * Returns the empty array if the input array has fewer than two elements.
825 *
826 * @param iterable Array of input elements
827 * @param reducer A reducer function taking as input to adjacent elements of the input array and returning a reduced value.
828 */
829export function pairs<T, U>(iterable: Iterable<T>, reducer: (a: T, b: T) => U): U[];
830
831/**
832 * Returns a permutation of the specified source object (or array) using the specified iterable of keys.
833 * The returned array contains the corresponding property of the source object for each key in keys, in order.
834 * For example, `permute(["a", "b", "c"], [1, 2, 0]) // ["b", "c", "a"]`
835 *
836 * It is acceptable to have more keys than source elements, and for keys to be duplicated or omitted.
837 */
838export function permute<T>(source: { [key: number]: T; }, keys: Iterable<number>): T[];
839/**
840 * Extract the values from an object into an array with a stable order. For example:
841 * `var object = {yield: 27, year: 1931, site: "University Farm"};`
842 * `d3.permute(object, ["site", "yield"]); // ["University Farm", 27]`
843 */
844export function permute<T, K extends keyof T>(source: T, keys: Iterable<K>): Array<T[K]>;
845
846/**
847 * Randomizes the order of the specified array using the Fisher–Yates shuffle.
848 */
849export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
850export function shuffle(array: Int8Array, lo?: number, hi?: number): Int8Array;
851export function shuffle(array: Uint8Array, lo?: number, hi?: number): Uint8Array;
852export function shuffle(array: Uint8ClampedArray, lo?: number, hi?: number): Uint8ClampedArray;
853export function shuffle(array: Int16Array, lo?: number, hi?: number): Int16Array;
854export function shuffle(array: Uint16Array, lo?: number, hi?: number): Uint16Array;
855export function shuffle(array: Int32Array, lo?: number, hi?: number): Int32Array;
856export function shuffle(array: Uint32Array, lo?: number, hi?: number): Uint32Array;
857export function shuffle(array: Float32Array, lo?: number, hi?: number): Float32Array;
858export function shuffle(array: Float64Array, lo?: number, hi?: number): Float64Array;
859
860/**
861 * Returns a shuffle function given the specified random source.
862 */
863export function shuffler(random: () => number): typeof shuffle;
864
865/**
866 * Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
867 * Each value is a power of ten multiplied by 1, 2 or 5. See also d3.tickIncrement, d3.tickStep and linear.ticks.
868 *
869 * Ticks are inclusive in the sense that they may include the specified start and stop values if (and only if) they are exact,
870 * nicely-rounded values consistent with the inferred step. More formally, each returned tick t satisfies start ≤ t and t ≤ stop.
871 *
872 * @param start Start value for ticks
873 * @param stop Stop value for ticks
874 * @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
875 */
876export function ticks(start: number, stop: number, count: number): number[];
877
878/**
879 * Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
880 * a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
881 *
882 * Like d3.tickStep, except requires that start is always less than or equal to stop, and if the tick step for the given start,
883 * stop and count would be less than one, returns the negative inverse tick step instead.
884 *
885 * This method is always guaranteed to return an integer, and is used by d3.ticks to avoid guarantee that the returned tick values
886 * are represented as precisely as possible in IEEE 754 floating point.
887 *
888 * @param start Start value for ticks
889 * @param stop Stop value for ticks
890 * @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
891 */
892export function tickIncrement(start: number, stop: number, count: number): number;
893
894/**
895 * Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
896 * a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
897 *
898 * Note that due to the limited precision of IEEE 754 floating point, the returned value may not be exact decimals;
899 * use d3-format to format numbers for human consumption.
900 *
901 * @param start Start value for ticks
902 * @param stop Stop value for ticks
903 * @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
904 */
905export function tickStep(start: number, stop: number, count: number): number;
906
907/**
908 * Returns a new interval [niceStart, niceStop] covering the given interval [start, stop] and where niceStart and niceStop are guaranteed to align with the corresponding tick step.
909 * Like d3.tickIncrement, this requires that start is less than or equal to stop.
910 *
911 * @param start Start value for ticks
912 * @param stop Stop value for ticks
913 * @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
914 */
915export function nice(start: number, stop: number, count: number): [number, number];
916
917/**
918 * Generates a 0-based numeric sequence. The output range does not include 'stop'.
919 */
920export function range(stop: number): number[];
921/**
922 * Generates a numeric sequence starting from the given start and stop values. 'step' defaults to 1. The output range does not include 'stop'.
923 */
924// tslint:disable-next-line:unified-signatures
925export function range(start: number, stop: number, step?: number): number[];
926
927/**
928 * Transpose a matrix provided in Array of Arrays format.
929 */
930export function transpose<T>(matrix: ArrayLike<ArrayLike<T>>): T[][];
931
932/**
933 * Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays.
934 * The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array
935 * contains one-element arrays. With no arguments, the returned array is empty.
936 */
937export function zip<T>(...arrays: Array<ArrayLike<T>>): T[][];
938
939// --------------------------------------------------------------------------------------
940// Iterables
941// --------------------------------------------------------------------------------------
942
943/**
944 * Returns true if the given test function returns true for every value in the given iterable.
945 * This method returns as soon as test returns a non-truthy value or all values are iterated over.
946 * Equivalent to array.every.
947 */
948export function every<T>(
949 iterable: Iterable<T>,
950 test: (value: T, index: number, iterable: Iterable<T>) => unknown
951): boolean;
952
953/**
954 * Returns true if the given test function returns true for any value in the given iterable.
955 * This method returns as soon as test returns a truthy value or all values are iterated over.
956 * Equivalent to array.some.
957 */
958export function some<T>(
959 iterable: Iterable<T>,
960 test: (value: T, index: number, iterable: Iterable<T>) => unknown
961): boolean;
962
963/**
964 * Returns a new array containing the values from iterable, in order, for which the given test function returns true.
965 * Equivalent to array.filter.
966 */
967export function filter<T>(
968 iterable: Iterable<T>,
969 test: (value: T, index: number, iterable: Iterable<T>) => unknown
970): T[];
971
972/**
973 * Returns a new array containing the mapped values from iterable, in order, as defined by given mapper function.
974 * Equivalent to array.map and Array.from.
975 */
976export function map<T, U>(iterable: Iterable<T>, mapper: (value: T, index: number, iterable: Iterable<T>) => U): U[];
977
978/**
979 * Returns the reduced value defined by given reducer function, which is repeatedly invoked for each value in iterable, being passed the current reduced value and the next value.
980 * Equivalent to array.reduce.
981 */
982export function reduce<T>(
983 iterable: Iterable<T>,
984 reducer: (previousValue: T, currentValue: T, currentIndex: number, iterable: Iterable<T>) => T,
985 initialValue?: T
986): T;
987/**
988 * Returns the reduced value defined by given reducer function, which is repeatedly invoked for each value in iterable, being passed the current reduced value and the next value.
989 * Equivalent to array.reduce.
990 */
991export function reduce<T, U>(
992 iterable: Iterable<T>,
993 reducer: (previousValue: U, currentValue: T, currentIndex: number, iterable: Iterable<T>) => U,
994 initialValue: U
995): U;
996
997/**
998 * Returns an array containing the values in the given iterable in reverse order.
999 * Equivalent to array.reverse, except that it does not mutate the given iterable.
1000 */
1001export function reverse<T>(iterable: Iterable<T>): T[];
1002
1003/**
1004 * Returns an array containing the values in the given iterable in the sorted order defined by the given comparator function.
1005 * If comparator is not specified, it defaults to d3.ascending.
1006 * Equivalent to array.sort, except that it does not mutate the given iterable, and the comparator defaults to natural order instead of lexicographic order.
1007 */
1008export function sort<T>(iterable: Iterable<T>, comparator?: (a: T, b: T) => number): T[];
1009/**
1010 * Returns an array containing the values in the given iterable in the sorted order defined by the given accessor function.
1011 * This is equivalent to a comparator using natural order.
1012 * The accessor is only invoked once per element, and thus may be nondeterministic.
1013 * Multiple accessors may be specified to break ties.
1014 */
1015export function sort<T>(iterable: Iterable<T>, ...accessors: Array<(a: T) => unknown>): T[];
1016
1017// --------------------------------------------------------------------------------------
1018// Sets
1019// --------------------------------------------------------------------------------------
1020
1021/**
1022 * Returns a new InternSet containing every value in iterable that is not in any of the others iterables.
1023 */
1024export function difference<T>(iterable: Iterable<T>, ...others: Array<Iterable<T>>): InternSet<T>;
1025
1026/**
1027 * Returns a new InternSet containing every (distinct) value that appears in any of the given iterables.
1028 * The order of values in the returned set is based on their first occurrence in the given iterables.
1029 */
1030export function union<T>(...iterables: Array<Iterable<T>>): InternSet<T>;
1031
1032/**
1033 * Returns a new InternSet containing every (distinct) value that appears in all of the given iterables.
1034 * The order of values in the returned set is based on their first occurrence in the given iterables.
1035 */
1036export function intersection<T>(...iterables: Array<Iterable<T>>): InternSet<T>;
1037
1038/**
1039 * Returns true if a is a superset of b: if every value in the given iterable b is also in the given iterable a.
1040 */
1041export function superset<T>(a: Iterable<T>, b: Iterable<T>): boolean;
1042
1043/**
1044 * Returns true if a is a subset of b: if every value in the given iterable a is also in the given iterable b.
1045 */
1046export function subset<T>(a: Iterable<T>, b: Iterable<T>): boolean;
1047
1048/**
1049 * Returns true if a and b are disjoint: if a and b contain no shared value.
1050 */
1051export function disjoint<T>(a: Iterable<T>, b: Iterable<T>): boolean;
1052
1053// --------------------------------------------------------------------------------------
1054// Bins
1055// --------------------------------------------------------------------------------------
1056
1057export interface Bin<Datum, Value extends number | Date | undefined> extends Array<Datum> {
1058 x0: Value | undefined;
1059 x1: Value | undefined;
1060}
1061
1062/**
1063 * Type definition for threshold generator which returns the count of recommended thresholds
1064 */
1065export type ThresholdCountGenerator<Value extends number | undefined = number | undefined> =
1066 (values: ArrayLike<Value>, min: number, max: number) => number;
1067
1068/**
1069 * Type definition for threshold generator which returns an array of recommended numbers thresholds
1070 */
1071export type ThresholdNumberArrayGenerator<Value extends number | undefined> =
1072 (values: ArrayLike<Value>, min: number, max: number) => Value[];
1073
1074/**
1075 * Type definition for threshold generator which returns an array of recommended dates thresholds
1076 */
1077export type ThresholdDateArrayGenerator<Value extends Date | undefined> =
1078 (values: ArrayLike<Value>, min: Date, max: Date) => Value[];
1079
1080export interface HistogramCommon<Datum, Value extends number | Date | undefined> {
1081 (data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
1082
1083 value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
1084 value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
1085}
1086
1087export interface HistogramGeneratorDate<Datum, Value extends Date | undefined> extends HistogramCommon<Datum, Date> {
1088 domain(): (values: ArrayLike<Value>) => [Date, Date];
1089 domain(domain: [Date, Date] | ((values: ArrayLike<Value>) => [Date, Date])): this;
1090
1091 thresholds(): ThresholdDateArrayGenerator<Value>;
1092 /**
1093 * Set the array of values to be used as thresholds in determining the bins.
1094 *
1095 * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
1096 * and the last bin.x1 is always equal to the maximum domain value.
1097 *
1098 * @param thresholds Either an array of threshold values used for binning. The elements must
1099 * be of the same type as the materialized values of the histogram.
1100 * Or a function which accepts as arguments the array of materialized values, and
1101 * optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
1102 * thresholds in determining the bins.
1103 */
1104 thresholds(thresholds: ArrayLike<Value> | ThresholdDateArrayGenerator<Value>): this;
1105}
1106
1107export interface HistogramGeneratorNumber<Datum, Value extends number | undefined> extends HistogramCommon<Datum, Value> {
1108 domain(): (values: Iterable<Value>) => [number, number] | [undefined, undefined];
1109 domain(domain: [number, number] | ((values: Iterable<Value>) => [number, number] | [undefined, undefined])): this;
1110
1111 thresholds(): ThresholdCountGenerator<Value> | ThresholdNumberArrayGenerator<Value>;
1112 /**
1113 * Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
1114 * setting approach only works, when the materialized values are numbers!
1115 *
1116 * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
1117 * and the last bin.x1 is always equal to the maximum domain value.
1118 *
1119 * @param count Either the desired number of uniform bins or a function which accepts as arguments the array of
1120 * materialized values, and optionally the domain minimum and maximum. The function calculates and returns the
1121 * suggested number of bins.
1122 */
1123 thresholds(count: number | ThresholdCountGenerator<Value>): this;
1124 /**
1125 * Set the array of values to be used as thresholds in determining the bins.
1126 *
1127 * Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
1128 * and the last bin.x1 is always equal to the maximum domain value.
1129 *
1130 * @param thresholds Either an array of threshold values used for binning. The elements must
1131 * be of the same type as the materialized values of the histogram.
1132 * Or a function which accepts as arguments the array of materialized values, and
1133 * optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
1134 * thresholds in determining the bins.
1135 */
1136 // tslint:disable-next-line:unified-signatures
1137 thresholds(thresholds: ArrayLike<Value> | ThresholdNumberArrayGenerator<Value>): this;
1138}
1139
1140/**
1141 * @deprecated. Use bin instead.
1142 */
1143export function histogram(): HistogramGeneratorNumber<number, number>;
1144
1145/**
1146 * @deprecated Use bin instead.
1147 */
1148// tslint:disable-next-line:no-unnecessary-generics
1149export function histogram<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
1150
1151/**
1152 * @deprecated Use bin instead.
1153 */
1154// tslint:disable-next-line:no-unnecessary-generics
1155export function histogram<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
1156
1157export function bin(): HistogramGeneratorNumber<number, number>;
1158// tslint:disable-next-line:no-unnecessary-generics
1159export function bin<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
1160// tslint:disable-next-line:no-unnecessary-generics
1161export function bin<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
1162
1163// --------------------------------------------------------------------------------------
1164// Histogram Thresholds
1165// --------------------------------------------------------------------------------------
1166
1167export function thresholdFreedmanDiaconis(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
1168
1169export function thresholdScott(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
1170
1171export function thresholdSturges(values: ArrayLike<number | undefined>): number; // of type ThresholdCountGenerator
1172
1173// --------------------------------------------------------------------------------------
1174// Interning
1175// --------------------------------------------------------------------------------------
1176
1177/**
1178 * 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.
1179 */
1180export class InternMap<K = any, V = any> extends Map<K, V> {
1181}
1182
1183/**
1184 * 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.
1185 */
1186export class InternSet<T = any> extends Set<T> {
1187}
1188
\No newline at end of file