forked from crossfilter/crossfilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
136 lines (110 loc) · 4.68 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
export = crossfilter;
declare function crossfilter<T>(records?: T[]): crossfilter.Crossfilter<T>;
declare namespace crossfilter {
export type ComparableValue = string | number | boolean;
export interface ComparableObject {
valueOf(): ComparableValue;
}
export type NaturallyOrderedValue = ComparableValue | ComparableObject;
export type Predicate<T> = (record: T) => boolean;
export type TSelectorValue = NaturallyOrderedValue | NaturallyOrderedValue[];
export type OrderedValueSelector<TRecord, TValue extends TSelectorValue = NaturallyOrderedValue> = (
record: TRecord,
) => TValue;
export type FilterValue =
| NaturallyOrderedValue
| [NaturallyOrderedValue, NaturallyOrderedValue]
| Predicate<NaturallyOrderedValue>;
export interface Grouping<TKey extends NaturallyOrderedValue, TValue> {
key: TKey;
value: TValue;
}
export interface Group<TRecord, TKey extends NaturallyOrderedValue, TValue> {
top(k: number): Array<Grouping<TKey, TValue>>;
all(): ReadonlyArray<Grouping<TKey, TValue>>;
reduce(
add: (p: TValue, v: TRecord, nf: boolean) => TValue,
remove: (p: TValue, v: TRecord, nf: boolean) => TValue,
initial: () => TValue,
): Group<TRecord, TKey, TValue>;
reduceCount(): Group<TRecord, TKey, TValue>;
reduceSum(selector: (record: TRecord) => number): Group<TRecord, TKey, TValue>;
order(selector: (value: TValue) => NaturallyOrderedValue): Group<TRecord, TKey, TValue>;
orderNatural(): Group<TRecord, TKey, TValue>;
size(): number;
dispose(): Group<TRecord, TKey, TValue>;
}
export interface GroupAll<TRecord, TValue> {
reduce(
add: (p: TValue, v: TRecord, nf: boolean) => TValue,
remove: (p: TValue, v: TRecord, nf: boolean) => TValue,
initial: () => TValue,
): GroupAll<TRecord, TValue>;
reduceCount(): GroupAll<TRecord, TValue>;
reduceSum(selector: (record: TRecord) => number): GroupAll<TRecord, TValue>;
dispose(): GroupAll<TRecord, TValue>;
value(): TValue;
}
export interface Dimension<TRecord, TValue extends NaturallyOrderedValue> {
filter(filterValue: FilterValue): Dimension<TRecord, TValue>;
filterExact(value: TValue): Dimension<TRecord, TValue>;
filterRange(range: [TValue, TValue]): Dimension<TRecord, TValue>;
filterFunction(predicate: Predicate<TValue>): Dimension<TRecord, TValue>;
filterAll(): Dimension<TRecord, TValue>;
currentFilter(): FilterValue | undefined;
hasCurrentFilter(): boolean;
top(k: number, offset?: number): TRecord[];
bottom(k: number, offset?: number): TRecord[];
group<TKey extends NaturallyOrderedValue, TGroupValue>(
groupValue?: (value: TValue) => TKey,
): Group<TRecord, TKey, TGroupValue>;
groupAll<TGroupValue>(): GroupAll<TRecord, TGroupValue>;
dispose(): Dimension<TRecord, TValue>;
accessor(record: TRecord): NaturallyOrderedValue;
id(): number;
}
export enum EventType {
DATA_ADDED = 'dataAdded',
DATA_REMOVED = 'dataRemoved',
FILTERED = 'filtered',
}
export interface Crossfilter<T> {
add(records: T[]): Crossfilter<T>;
remove(predicate?: Predicate<T>): void;
dimension<TValue extends NaturallyOrderedValue>(
selector: OrderedValueSelector<T, TValue | TValue[]>,
isArray?: boolean,
): Dimension<T, TValue>;
groupAll<TGroupValue>(): GroupAll<T, TGroupValue>;
size(): number;
all(): ReadonlyArray<T>;
allFiltered(): T[];
onChange(callback: (type: EventType) => void): () => void;
isElementFiltered(index: number, ignoreDimensions?: number[]): boolean;
}
export type HeapSelector<T> = (records: T[], lo: number, hi: number, k: number) => T[];
export interface Heap<T> {
(records: T[], lo: number, hi: number): T[];
sort(records: T[], lo: number, hi: number): T[];
}
export type Sorter<T> = (records: T[], lo: number, hi: number) => T[];
export type Bisection<T> = (records: T[], record: T, lo: number, hi: number) => number;
export interface Bisector<T> extends Bisection<T> {
left: Bisection<T>;
right: Bisection<T>;
}
export const version: string;
namespace heap {
export function by<T>(selector: OrderedValueSelector<T>): Heap<T>;
}
export function heap<T>(records: T[], lo: number, hi: number): T[];
namespace heapselect {
export function by<T>(selector: OrderedValueSelector<T>): HeapSelector<T>;
}
export function heapselect<T>(records: T[], lo: number, hi: number, k: number): T[];
namespace bisect {
export function by<T>(selector: OrderedValueSelector<T>): Bisector<T>;
}
export function bisect<T>(records: T[], record: T, lo: number, hi: number): number;
export function permute<T>(records: T[], index: number[], deep: number): T[];
}