[wip] im tired boss
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user