collectGroupBy() retains every value and rebuilds all groups on each emission
- Ngôn ngữ chính
- TypeScript
- Star
- 29
- Fork
- 3
- Merge trung bình
- 3 giờ 5 phút
- Pull request đã merge (30 ngày)
- 11
Mô tả
#70 removed the unbounded retention from `scanLatestEach()`, but `collectGroupBy()`
— which that implementation used to be built on — still has it
(`src/lib/stores/operators.ts:65-82`):
```ts
export function collectGroupBy(f: (a: A) => K): OperatorFunction> {
return pipe(
scanArray(),
map((xs) => {
const dict = new Map();
xs.forEach((x) => { ... dict.set(key, [...value, x]); ... });
return dict;
})
);
}
```
It retains every value it has ever seen via `scanArray()` and rebuilds the whole
grouping, copying each group, on every emission. Cost per value rises with the
length of the stream — the measurements in #70 were 79 ms at 1 000 values, 603 ms at
2 000 and 5 214 ms at 4 000.
Nothing inside the library uses it any more, but it is still exported from
`src/lib/stores/index.ts` as public API. A consumer applying it to a long-lived
forward-req stream reproduces exactly the bug #70 fixed.
Determined by code reading; the measurements are from #70.
## Direction
Remove it from the public API, or reimplement it to keep only what it emits.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.