Skip to content

Commit

Permalink
fix: Make sure regeneratorRuntime isn't included in the cjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
gvergnaud committed Feb 15, 2024
1 parent 5fffafd commit dbff156
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,18 @@ function chainable<pattern extends Matcher<any, any, any, any, any>>(

const variadic = <pattern extends {}>(pattern: pattern): Variadic<pattern> =>
Object.assign(pattern, {
*[Symbol.iterator]() {
yield Object.assign(pattern, {
[Symbol.iterator](): Iterator<pattern, void, undefined> {
let i = 0;
const variadicPattern = Object.assign(pattern, {
[symbols.isVariadic]: true,
});
const values: IteratorResult<pattern, void>[] = [
{ value: variadicPattern, done: false },
{ done: true, value: undefined },
];
return {
next: () => values[i++] ?? values.at(-1)!,
};
},
});

Expand Down

0 comments on commit dbff156

Please sign in to comment.