UNPKG

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