UNPKG

@virtualstate/examples

Version:
34 lines 1.03 kB
import { Fragment, h } from "@virtualstate/fringe"; import { isTrue } from "./truth.js"; import { True, False } from "./truth.js"; export async function* Not(o, state) { // We have no child state, input is not true if (!state) return yield h(True, null); // We have a non fragment child, input is true if (state.reference !== Fragment) { if (isTrue(state)) { return; } else { return h(True, null); } } const children = state.children; // We have no fragment children, input is not true if (!children) return; let everYielded = false; for await (const result of children) { const not = !result.some(isTrue); if (not && !everYielded) continue; yield not ? h(True, null) : h(False, null); everYielded = true; } // If we yielded earlier, the final result is the matching result if (!everYielded) { yield h(True, null); } } //# sourceMappingURL=not.js.map