How to use the @effectful/transducers.Tag.id 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 / debug.js View on Github external
i,
                D.setComment(
                  Kit.enter(i.pos, Tag.VariableDeclaration, {
                    node: {
                      kind: "var"
                      // kind:"const"
                    },
                    eff: i.value.eff
                  }),
                  "S",
                  "font-size:xx-large;color:orange"
                )
              );
              yield Kit.enter(Tag.declarations, Tag.Array);
              yield Kit.enter(Tag.push, Tag.VariableDeclarator);
              yield Kit.tok(Tag.id, Tag.Identifier, { sym: i.value.sym });
              yield Kit.enter(Tag.init, Kit.Subst);
            } else {
              yield D.copyComment(
                i,
                D.setComment(
                  Kit.enter(i.pos, Tag.ExpressionStatement, {
                    node: {},
                    eff: i.value.eff
                  }),
                  "S",
                  "font-size:xx-large;color:orange"
                )
              );
              yield Kit.enter(Tag.expression, Kit.Subst);
            }
          }
github awto / effectfuljs / packages / core / src / kit / snippets.js View on Github external
export function* openVarDecl(idNode, s, kind = "var") {
  const value =
    idNode.node === null
      ? { node: idNode, lhs: true, decl: true, rhs: false }
      : idNode;
  yield s.enter(Tag.init, Tag.VariableDeclaration, { node: { kind } });
  yield s.enter(Tag.declarations, Tag.Array);
  yield s.enter(Tag.push, Tag.VariableDeclarator);
  yield tok(Tag.id, Tag.Identifier, value);
}
github awto / effectfuljs / packages / core / src / state.js View on Github external
const callee = s.curLev();
              if (callee) {
                switch (callee.type) {
                  case Tag.FunctionExpression:
                  case Tag.ArrowFunctionExpression:
                    callee.value.isLocal = true;
                    callee.value.localFuncRef = callee.value;
                }
              }
            }
            break;
          case Tag.FunctionDeclaration:
            yield* s.one();
          case Tag.FunctionExpression:
            const j = s.curLev();
            if (j && j.pos === Tag.id) {
              j.value.source = i.value;
            }
            break;
          case Tag.AssignmentExpression:
          case Tag.VariableDeclarator:
            yield i;
            const first = [...s.one()];
            const l = s.curLev();
            if (l) first[0].value.source = l.value;
            yield* walk(s.one());
            yield* first;
            continue;
        }
      }
      yield i;
    }
github awto / effectfuljs / packages / core / src / kit / core.js View on Github external
function* prepare(s) {
    const stack = [];
    const si = lookahead(s);
    for (const i of si) {
      let key = false;
      switch (i.pos) {
        case Tag.label:
          if (i.enter) skip(sub(si));
          continue;
        case Tag.id:
          key = true;
          break;
        case Tag.property:
        case Tag.key:
          if (i.enter && i.type === Tag.Identifier) {
            const f = stack[0];
            if (f && f.computed) key = true;
          }
          break;
      }
      if (i.enter) {
        const tv = tagValue(i.pos, i.type, { node: i.value.node });
        if (key) tv.expr = false;
        stack.unshift(tv);
      }
      yield {
github awto / effectfuljs / packages / core / src / state.js View on Github external
init: Kit.reposOneArr(v.init, Tag.right)
                      });
                    }
                  } else vars.push(v);
                }
              }
              if (vars.length) {
                const lab = sl.label();
                yield sl.enter(Tag.push, Tag.VariableDeclaration, {
                  node: { kind: "var" }
                });
                yield sl.enter(Tag.declarations, Tag.Array);
                for (const { sym, init } of vars) {
                  if (sym.substSym) continue;
                  yield sl.enter(Tag.push, Tag.VariableDeclarator);
                  yield sl.tok(Tag.id, Tag.Identifier, { sym, decl: true });
                  if (init) yield* init;
                  yield* sl.leave();
                }
                yield* lab();
              }

              for (const j of decls) if (j[1].raw != null) yield* j[1].raw;
              if (assigns.length) {
                for (const { sym, init } of assigns) {
                  yield sl.enter(Tag.push, Tag.ExpressionStatement);
                  yield sl.enter(Tag.expression, Tag.AssignmentExpression, {
                    node: { operator: "=" }
                  });
                  yield sl.tok(Tag.left, Tag.Identifier, {
                    sym,
                    lhs: true,