@ohm-js/wasm 0.6.6 → 0.6.7

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.
@@ -61,7 +61,10 @@ export declare class CstNode {
61
61
  isLexical(ruleName?: string): boolean;
62
62
  toString(): string;
63
63
  map<T>(callbackFn: (...args: CstNode[]) => T): T[];
64
- unpack<T>(someFn: (...args: CstNode[]) => T, noneFn: () => T): T;
64
+ when<T>({ some, none }: {
65
+ some: (...args: CstNode[]) => T;
66
+ none: () => T;
67
+ }): T;
65
68
  }
66
69
  export declare function dumpCstNode(node: CstNode, depth?: number): void;
67
70
  export declare class MatchResult {
@@ -338,12 +338,12 @@ export class CstNode {
338
338
  }
339
339
  return ans;
340
340
  }
341
- unpack(someFn, noneFn) {
341
+ when({ some, none }) {
342
342
  assert(this.isOptional(), 'Not an optional');
343
343
  if (this.children.length === 0)
344
- return noneFn();
345
- assert(someFn.length === this.children.length, `bad arity: expected ${this.children.length}, got ${someFn.length}`);
346
- return someFn(...this.children);
344
+ return none();
345
+ assert(some.length === this.children.length, `bad arity: expected ${this.children.length}, got ${some.length}`);
346
+ return some(...this.children);
347
347
  }
348
348
  }
349
349
  export function dumpCstNode(node, depth = 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohm-js/wasm",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Compile Ohm.js grammars to WebAsssembly",
5
5
  "main": "dist/index.js",
6
6
  "exports": {