@virtualstate/examples
Version:
28 lines • 842 B
JavaScript
import { Fragment, h } from "@virtualstate/fringe";
import { isTrue } from "./truth.js";
import { True, False } from "./truth.js";
export async function* Or(o, state) {
// We have no child state, no input is true
if (!state)
return;
// We have a non fragment child, all input is true
if (state.reference !== Fragment) {
if (isTrue(state)) {
yield h(True, null);
}
return;
}
const children = state.children;
// We have no fragment children, no input is true
if (!children)
return;
let everYielded = false;
for await (const values of children) {
const found = values.find(isTrue);
if (!found && !everYielded)
continue;
everYielded = true;
yield found ?? h(False, null);
}
}
//# sourceMappingURL=or.js.map