@ohm-js/wasm 0.6.7 → 0.6.8

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.
@@ -16,7 +16,7 @@ export class AstBuilder {
16
16
  const handleEmptyListOf = () => [];
17
17
  const handleNonemptyListOf = (first, iterSepAndElem) => [
18
18
  this.toAst(first),
19
- ...iterSepAndElem.map((_, elem) => this.toAst(elem)),
19
+ ...iterSepAndElem.collect((_, elem) => this.toAst(elem)),
20
20
  ];
21
21
  this._mapping = {
22
22
  listOf: handleListOf,
@@ -60,10 +60,10 @@ export declare class CstNode {
60
60
  isSyntactic(ruleName?: string): boolean;
61
61
  isLexical(ruleName?: string): boolean;
62
62
  toString(): string;
63
- map<T>(callbackFn: (...args: CstNode[]) => T): T[];
64
- when<T>({ some, none }: {
65
- some: (...args: CstNode[]) => T;
66
- none: () => T;
63
+ collect<T>(callbackFn: (...args: CstNode[]) => T): T[];
64
+ when<T>({ Some, None }: {
65
+ Some: (...args: CstNode[]) => T;
66
+ None: () => T;
67
67
  }): T;
68
68
  }
69
69
  export declare function dumpCstNode(node: CstNode, depth?: number): void;
@@ -329,7 +329,7 @@ export class CstNode {
329
329
  return `CstNode {ctorName: ${ctorName}, sourceString: ${sourceString}, startIdx: ${startIdx} }`;
330
330
  }
331
331
  // Other possible names: collect, mapChildren, mapUnpack, unpackEach, …
332
- map(callbackFn) {
332
+ collect(callbackFn) {
333
333
  const { arity, children } = this;
334
334
  assert(callbackFn.length === arity, 'bad arity');
335
335
  const ans = [];
@@ -338,12 +338,12 @@ export class CstNode {
338
338
  }
339
339
  return ans;
340
340
  }
341
- when({ some, none }) {
341
+ when({ Some, None }) {
342
342
  assert(this.isOptional(), 'Not an optional');
343
343
  if (this.children.length === 0)
344
- return none();
345
- assert(some.length === this.children.length, `bad arity: expected ${this.children.length}, got ${some.length}`);
346
- return some(...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.7",
3
+ "version": "0.6.8",
4
4
  "description": "Compile Ohm.js grammars to WebAsssembly",
5
5
  "main": "dist/index.js",
6
6
  "exports": {