@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.
- package/dist/src/miniohm.d.ts +4 -1
- package/dist/src/miniohm.js +4 -4
- package/package.json +1 -1
package/dist/src/miniohm.d.ts
CHANGED
|
@@ -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
|
-
|
|
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 {
|
package/dist/src/miniohm.js
CHANGED
|
@@ -338,12 +338,12 @@ export class CstNode {
|
|
|
338
338
|
}
|
|
339
339
|
return ans;
|
|
340
340
|
}
|
|
341
|
-
|
|
341
|
+
when({ some, none }) {
|
|
342
342
|
assert(this.isOptional(), 'Not an optional');
|
|
343
343
|
if (this.children.length === 0)
|
|
344
|
-
return
|
|
345
|
-
assert(
|
|
346
|
-
return
|
|
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) {
|