Skip to content

Commit 37eb83f

Browse files
committed
Split tree version of orderBy into its own file to enable tree shaking the sorted-btree dependency.
1 parent 845bbe6 commit 37eb83f

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

packages/d2mini/src/operators/orderBy.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { IStreamBuilder } from '../types'
22
import { KeyValue } from '../types.js'
33
import { topK, topKWithIndex } from './topK.js'
44
import { topKWithFractionalIndex } from './topKWithFractionalIndex.js'
5-
import { topKWithFractionalIndexBTree } from './topKWithFractionalIndexBTree.js'
65
import { map } from './map.js'
76
import { innerJoin } from './join.js'
87
import { consolidate } from './consolidate.js'
98

10-
interface OrderByOptions<Ve> {
9+
export interface OrderByOptions<Ve> {
1110
comparator?: (a: Ve, b: Ve) => number
1211
limit?: number
1312
offset?: number
@@ -129,7 +128,7 @@ export function orderByWithIndex<
129128
}
130129
}
131130

132-
function orderByWithFractionalIndexBase<
131+
export function orderByWithFractionalIndexBase<
133132
T extends KeyValue<unknown, unknown>,
134133
Ve = unknown,
135134
>(
@@ -212,19 +211,3 @@ export function orderByWithFractionalIndex<
212211
options,
213212
)
214213
}
215-
216-
export function orderByWithFractionalIndexBTree<
217-
T extends KeyValue<unknown, unknown>,
218-
Ve = unknown,
219-
>(
220-
valueExtractor: (
221-
value: T extends KeyValue<unknown, infer V> ? V : never,
222-
) => Ve,
223-
options?: OrderByOptions<Ve>,
224-
) {
225-
return orderByWithFractionalIndexBase(
226-
topKWithFractionalIndexBTree,
227-
valueExtractor,
228-
options,
229-
)
230-
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { KeyValue } from '../types.js'
2+
import { OrderByOptions, orderByWithFractionalIndexBase } from './orderBy.js'
3+
import { topKWithFractionalIndexBTree } from './topKWithFractionalIndexBTree.js'
4+
5+
export function orderByWithFractionalIndexBTree<
6+
T extends KeyValue<unknown, unknown>,
7+
Ve = unknown,
8+
>(
9+
valueExtractor: (
10+
value: T extends KeyValue<unknown, infer V> ? V : never,
11+
) => Ve,
12+
options?: OrderByOptions<Ve>,
13+
) {
14+
return orderByWithFractionalIndexBase(
15+
topKWithFractionalIndexBTree,
16+
valueExtractor,
17+
options,
18+
)
19+
}

packages/d2mini/tests/operators/orderByWithFractionalIndex.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { D2 } from '../../src/d2.js'
33
import { MultiSet } from '../../src/multiset.js'
44
import {
55
orderByWithFractionalIndex,
6-
orderByWithFractionalIndexBTree,
76
output,
87
} from '../../src/operators/index.js'
8+
import { orderByWithFractionalIndexBTree } from '../../src/operators/orderByBTree.js'
99
import { KeyValue } from '../../src/types.js'
1010
import { loadBTree } from '../../src/operators/topKWithFractionalIndexBTree.js'
1111

0 commit comments

Comments
 (0)