Skip to content

Commit

Permalink
apply all function to all patterns before the stack. supports e.g. …
Browse files Browse the repository at this point in the history
…`all(steps(4))`
  • Loading branch information
yaxu committed Jun 26, 2024
1 parent f514cd8 commit 60531a5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/core/repl.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ export function repl({
await beforeEval?.({ code });
shouldHush && hush();
let { pattern, meta } = await _evaluate(code, transpiler, transpilerOptions);

if (allTransform) {
for (const [key, value] of Object.entries(pPatterns)) {
pPatterns[key] = allTransform(value);
}
}

if (Object.keys(pPatterns).length) {
pattern = stack(...Object.values(pPatterns));
}
if (allTransform) {
pattern = allTransform(pattern);
}
if (!isPattern(pattern)) {
const message = `got "${typeof evaluated}" instead of pattern`;
throw new Error(message + (typeof evaluated === 'function' ? ', did you forget to call a function?' : '.'));
Expand Down

0 comments on commit 60531a5

Please sign in to comment.