Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 6e3114f6 authored by Simon Chan's avatar Simon Chan
Browse files

feat(stream): add MaybeConsumable.getValue helper method

parent dcda6459
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -9,6 +9,10 @@ import {
export type MaybeConsumable<T> = T | Consumable<T>;

export namespace MaybeConsumable {
    export function getValue<T>(value: MaybeConsumable<T>): T {
        return value instanceof Consumable ? value.value : value;
    }

    export function tryConsume<T, R>(
        value: T,
        callback: (value: T extends Consumable<infer U> ? U : T) => R,