How to use the @effectful/transducers.invariant function in @effectful/transducers

To help you get started, we’ve selected a few @effectful/transducers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github awto / effectfuljs / packages / core / src / kit / core.js View on Github external
export function enter() {
  let [pos, type, value] = guessType.apply(null, arguments);
  invariant(pos && type && value);
  value = tagValue(pos, type, value);
  return { enter: true, leave: false, type, pos, value };
}
github awto / effectfuljs / packages / core / src / state.js View on Github external
yield* blab();
                  yield* _saveDecls();
                  yield* lab();
                }
                continue;
              }
              break;
            case Tag.VariableDeclaration:
              const kind = i.value.node.kind;
              i.value.node.kind = "var";
              const declarators = [];
              const stmt = i.pos !== Tag.init && i.pos !== Tag.left;
              sl.peel(i);
              sl.peel();
              for (const j of sl.sub()) {
                invariant(j.enter);
                invariant(j.type === Tag.VariableDeclarator);
                let hasInit = false;
                const asgn = [];
                const id = [...sl.one()];
                asgn.push(...id);
                for (const j of id) {
                  if (j.enter && j.type === Tag.Identifier && j.value.decl) {
                    const sym = j.value.sym;
                    if (!sym.noDecl && !decls.has(sym)) {
                      decls.set(sym, { raw: null, node: j.value.node });
                    }
                    j.value.decl = false;
                  }
                }
                if (sl.cur().pos === Tag.init) {
                  asgn.push(...Kit.reposOne(sl.one(), Tag.right));
github awto / effectfuljs / packages / core / src / state.js View on Github external
if (!root.ref) break;
            let classSym = root.ref.classId;
            if (!classSym) classSym = root.ref.classId = Kit.scope.newSym("C");
            yield* s.toks(
              i.pos,
              static_
                ? "=$1.getPrototypeOf($2.prototype)"
                : "=$1.getPrototypeOf($2.prototype)",
              Kit.scope.ObjectSym,
              classSym
            );
            s.close(i);
            continue;
          case Tag.Identifier:
            if (i.value.sym === Kit.scope.argumentsSym) {
              invariant(argsSym);
              Kit.skip(s.copy(i));
              yield s.tok(i.pos, Tag.Identifier, {
                sym: argsSym,
                lhs: false,
                rhs: true,
                decl: false
              });
              continue;
            }
        }
      }
      yield i;
    }
  }
  return walk();
github awto / effectfuljs / packages / core / src / kit / core.js View on Github external
function* walk() {
    for (const i of sl.sub()) {
      if (i.type === Subst) {
        if (i.enter) {
          invariant(!i.leave);
          yield* subst(i.pos);
        }
      } else yield i;
    }
  }
  yield* walk();
github awto / effectfuljs / packages / core / src / kit / core.js View on Github external
export function* nextLevel(s) {
  const i = s.take();
  invariant(i.enter);
  yield i;
  if (!i.leave) {
    yield* tillLevel(i.level, s);
  }
}