How to use @effectful/transducers - 10 common examples

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
yield D.copyComment(
                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 / state.js View on Github external
});
                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,
                    rhs: false,
                    decl: false
                  });
                  yield* init;
                  yield* sl.leave();
                  yield* sl.leave();
                }
              }
              // babel's hoist re-hack
              if (i.value.babelHoistReHack) {
github awto / effectfuljs / packages / core / src / state.js View on Github external
});
                  yield sl.tok(Tag.left, Tag.Identifier, {
                    sym,
                    lhs: true,
                    rhs: false,
                    decl: false
                  });
                  yield* init;
                  yield* sl.leave();
                  yield* sl.leave();
                }
              }
              // babel's hoist re-hack
              if (i.value.babelHoistReHack) {
                yield sl.enter(Tag.push, Tag.BlockStatement);
                yield sl.enter(Tag.body, Tag.Array);
                yield* _restoreDecls(sl.sub());
                yield* sl.leave();
                yield* sl.leave();
              }
              break;
            }
          }
        }
      }
    }
  }
}
github awto / effectfuljs / packages / core / src / state.js View on Github external
function* _restoreDecls(sw) {
    for (const i of sw) {
      yield i;
      if (i.enter) {
        if (
          ((i.value.savedDecls != null && i.value.savedDecls.size) ||
            (i.value.paramSyms && i.value.paramSyms.length)) &&
          !i.leave &&
          sl.curLev()
        ) {
          for (const j of sl.sub()) {
            yield j;
            if (j.enter && j.type === Tag.Array && j.pos === Tag.body) {
              const assigns = [];
              const decls = [];
              const { funcId } = i.value;
              if (funcId) {
                const copy = Kit.scope.newSym(funcId.orig);
                copy.num = -copy.num;
                copy.strict = true;
                funcId.strict = false;
                i.value.funcAlias = copy;
                if (
                  funcId.interpr === Bind.ctxField &&
                  funcId.declScope === i.value &&
                  // funcId.hasReads
                  ((noOpts && funcId.bound) || funcId.hasReads)
                ) {
                  assigns.push({
github awto / effectfuljs / packages / core / src / debug.js View on Github external
function* debDumbBindStmt(s) {
    for (const i of s) {
      switch (symName(i.type)) {
        case "letStmt":
          const hasBind = i.value.sym != null;
          if (i.enter) {
            if (hasBind) {
              yield D.copyComment(
                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"
github awto / effectfuljs / packages / core / src / debug.js View on Github external
function* debDumbBindStmt(s) {
    for (const i of s) {
      switch (symName(i.type)) {
        case "letStmt":
          const hasBind = i.value.sym != null;
          if (i.enter) {
            if (hasBind) {
              yield D.copyComment(
                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 {
github awto / effectfuljs / packages / core / src / debug.js View on Github external
if (hasBind) {
              yield D.copyComment(
                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 / state.js View on Github external
node: { operator: "=" }
                  });
                  yield sl.tok(Tag.left, Tag.Identifier, {
                    sym,
                    lhs: true,
                    rhs: false,
                    decl: false
                  });
                  yield* init;
                  yield* sl.leave();
                  yield* sl.leave();
                }
              }
              // babel's hoist re-hack
              if (i.value.babelHoistReHack) {
                yield sl.enter(Tag.push, Tag.BlockStatement);
                yield sl.enter(Tag.body, Tag.Array);
                yield* _restoreDecls(sl.sub());
                yield* sl.leave();
                yield* sl.leave();
              }
              break;
            }
          }
        }
      }
    }
  }
}
github awto / effectfuljs / packages / core / src / state.js View on Github external
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,
                    rhs: false,
                    decl: false
                  });
                  yield* init;
                  yield* sl.leave();
                  yield* sl.leave();
                }
              }
              // babel's hoist re-hack
              if (i.value.babelHoistReHack) {
                yield sl.enter(Tag.push, Tag.BlockStatement);
github awto / effectfuljs / packages / core / src / debug.js View on Github external
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);
            }
          }
          if (i.leave) yield* Kit.repeat(hasBind ? 4 : 2, Kit.leave());