mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
33 lines
823 B
TypeScript
33 lines
823 B
TypeScript
import { Trigger } from "."
|
|
|
|
export function successFailure(o: {
|
|
duringSuccess: Trigger
|
|
duringError: Trigger
|
|
}): Trigger {
|
|
return async function* (getInput) {
|
|
while (true) {
|
|
const beforeSuccess = o.duringSuccess(getInput)
|
|
yield
|
|
let currentValue = getInput()
|
|
beforeSuccess.next()
|
|
for (
|
|
let res = await beforeSuccess.next();
|
|
currentValue?.lastResult !== "passing" && !res.done;
|
|
res = await beforeSuccess.next()
|
|
) {
|
|
yield
|
|
currentValue = getInput()
|
|
}
|
|
const duringError = o.duringError(getInput)
|
|
for (
|
|
let res = await duringError.next();
|
|
currentValue?.lastResult === "passing" && !res.done;
|
|
res = await duringError.next()
|
|
) {
|
|
yield
|
|
currentValue = getInput()
|
|
}
|
|
}
|
|
}
|
|
}
|