webpipe-js 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -520,23 +520,30 @@ var Parser = class {
520
520
  this.skipSpaces();
521
521
  this.expect("then:");
522
522
  this.skipSpaces();
523
- const thenBranch = this.parseIfPipeline("else:");
523
+ const thenBranch = this.parseIfPipeline("else:", "end");
524
524
  this.skipSpaces();
525
525
  const elseBranch = this.tryParse(() => {
526
526
  this.expect("else:");
527
527
  this.skipSpaces();
528
- return this.parsePipeline();
528
+ return this.parseIfPipeline("end");
529
+ });
530
+ this.skipSpaces();
531
+ this.tryParse(() => {
532
+ this.expect("end");
533
+ return true;
529
534
  });
530
535
  return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
531
536
  }
532
- parseIfPipeline(stopKeyword) {
537
+ parseIfPipeline(...stopKeywords) {
533
538
  const steps = [];
534
539
  while (true) {
535
540
  const save = this.pos;
536
541
  this.skipWhitespaceOnly();
537
- if (this.text.startsWith(stopKeyword, this.pos)) {
538
- this.pos = save;
539
- break;
542
+ for (const keyword of stopKeywords) {
543
+ if (this.text.startsWith(keyword, this.pos)) {
544
+ this.pos = save;
545
+ return { steps };
546
+ }
540
547
  }
541
548
  if (!this.text.startsWith("|>", this.pos)) {
542
549
  this.pos = save;
package/dist/index.mjs CHANGED
@@ -471,23 +471,30 @@ var Parser = class {
471
471
  this.skipSpaces();
472
472
  this.expect("then:");
473
473
  this.skipSpaces();
474
- const thenBranch = this.parseIfPipeline("else:");
474
+ const thenBranch = this.parseIfPipeline("else:", "end");
475
475
  this.skipSpaces();
476
476
  const elseBranch = this.tryParse(() => {
477
477
  this.expect("else:");
478
478
  this.skipSpaces();
479
- return this.parsePipeline();
479
+ return this.parseIfPipeline("end");
480
+ });
481
+ this.skipSpaces();
482
+ this.tryParse(() => {
483
+ this.expect("end");
484
+ return true;
480
485
  });
481
486
  return { kind: "If", condition, thenBranch, elseBranch: elseBranch || void 0 };
482
487
  }
483
- parseIfPipeline(stopKeyword) {
488
+ parseIfPipeline(...stopKeywords) {
484
489
  const steps = [];
485
490
  while (true) {
486
491
  const save = this.pos;
487
492
  this.skipWhitespaceOnly();
488
- if (this.text.startsWith(stopKeyword, this.pos)) {
489
- this.pos = save;
490
- break;
493
+ for (const keyword of stopKeywords) {
494
+ if (this.text.startsWith(keyword, this.pos)) {
495
+ this.pos = save;
496
+ return { steps };
497
+ }
491
498
  }
492
499
  if (!this.text.startsWith("|>", this.pos)) {
493
500
  this.pos = save;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",