Skip to content

Commit

Permalink
Merge pull request #224 from gvergnaud/gvergnaud/fix-regenerator-runt…
Browse files Browse the repository at this point in the history
…ime-calls-in-cjs

fix: Make sure regeneratorRuntime isn't included in the cjs build
  • Loading branch information
gvergnaud authored Feb 15, 2024
2 parents 5fffafd + dbff156 commit f0cf3d4
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 f0cf3d4

Please sign in to comment.