[wip] im tired boss

This commit is contained in:
2025-08-30 15:49:55 -04:00
parent 5e33e33cce
commit 782dd738cc
5 changed files with 155 additions and 127 deletions

View File

@@ -1,12 +1,18 @@
import { merge, Observable } from "kefir";
export const transform = <
T,
Mutations extends [Observable<any, any>, (prev: T, evt: any) => T][]
>(
initValue: T,
...mutations: Mutations
): Observable<T, unknown> =>
export type ValueWithin<O extends Observable<any, any>> = Parameters<
Parameters<O["map"]>[0]
>[0];
type Mutation<A, O extends Observable<any, any>> = [
O,
(prev: A, value: ValueWithin<O>) => A
];
export const multiScan = <A, M extends Mutation<A, any>[]>(
initValue: A,
...mutations: M
): Observable<A, any> =>
merge(
mutations.map(([source, mutation]) =>
source.map((event) => ({ event, mutation }))
@@ -27,3 +33,5 @@ export const partition =
])
);
};
export const isEmpty = (container: { length: number }) => container.length == 0;