@thi.ng/parse 1.0.4 → 2.0.3

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +85 -137
  2. package/README.md +15 -6
  3. package/api.d.ts +1 -1
  4. package/combinators/alt.d.ts +1 -1
  5. package/combinators/alt.js +1 -1
  6. package/combinators/boundary.d.ts +1 -1
  7. package/combinators/boundary.js +2 -2
  8. package/combinators/check.d.ts +1 -1
  9. package/combinators/check.js +2 -2
  10. package/combinators/dynamic.d.ts +1 -1
  11. package/combinators/expect.d.ts +1 -1
  12. package/combinators/expect.js +1 -1
  13. package/combinators/lookahead.d.ts +1 -1
  14. package/combinators/lookahead.js +1 -1
  15. package/combinators/maybe.d.ts +1 -1
  16. package/combinators/maybe.js +1 -1
  17. package/combinators/not.d.ts +1 -1
  18. package/combinators/not.js +1 -1
  19. package/combinators/repeat.d.ts +1 -1
  20. package/combinators/repeat.js +1 -1
  21. package/combinators/seq.d.ts +1 -1
  22. package/combinators/seq.js +1 -1
  23. package/combinators/wrap.d.ts +1 -1
  24. package/combinators/wrap.js +3 -3
  25. package/combinators/xform.d.ts +1 -1
  26. package/context.d.ts +1 -1
  27. package/context.js +8 -7
  28. package/error.d.ts +1 -1
  29. package/error.js +1 -1
  30. package/grammar.d.ts +1 -1
  31. package/grammar.js +65 -48
  32. package/index.d.ts +49 -49
  33. package/index.js +49 -49
  34. package/package.json +183 -31
  35. package/presets/alpha.d.ts +4 -4
  36. package/presets/alpha.js +3 -3
  37. package/presets/bits.d.ts +2 -2
  38. package/presets/bits.js +4 -4
  39. package/presets/digits.d.ts +2 -2
  40. package/presets/digits.js +2 -2
  41. package/presets/escape.d.ts +2 -2
  42. package/presets/escape.js +9 -9
  43. package/presets/hex.d.ts +3 -3
  44. package/presets/hex.js +5 -5
  45. package/presets/numbers.d.ts +5 -5
  46. package/presets/numbers.js +12 -12
  47. package/presets/string.d.ts +1 -1
  48. package/presets/string.js +7 -7
  49. package/presets/whitespace.d.ts +8 -8
  50. package/presets/whitespace.js +3 -3
  51. package/prims/always.d.ts +2 -2
  52. package/prims/always.js +1 -1
  53. package/prims/anchor.d.ts +1 -1
  54. package/prims/anchor.js +1 -1
  55. package/prims/fail.d.ts +1 -1
  56. package/prims/fail.js +1 -1
  57. package/prims/lit.d.ts +2 -2
  58. package/prims/lit.js +1 -1
  59. package/prims/none-of.d.ts +1 -1
  60. package/prims/none-of.js +3 -2
  61. package/prims/one-of.d.ts +1 -1
  62. package/prims/one-of.js +3 -2
  63. package/prims/pass.d.ts +1 -1
  64. package/prims/pass.js +1 -1
  65. package/prims/range.d.ts +1 -1
  66. package/prims/range.js +1 -1
  67. package/prims/satisfy.d.ts +1 -1
  68. package/prims/skip.d.ts +1 -1
  69. package/prims/skip.js +1 -1
  70. package/prims/string.d.ts +1 -1
  71. package/prims/string.js +2 -2
  72. package/readers/array-reader.d.ts +1 -1
  73. package/readers/string-reader.d.ts +1 -1
  74. package/utils.js +1 -0
  75. package/xform/collect.d.ts +1 -1
  76. package/xform/collect.js +1 -1
  77. package/xform/comp.d.ts +1 -1
  78. package/xform/count.d.ts +1 -1
  79. package/xform/count.js +1 -1
  80. package/xform/discard.d.ts +1 -1
  81. package/xform/discard.js +1 -1
  82. package/xform/hoist.d.ts +1 -1
  83. package/xform/hoist.js +1 -1
  84. package/xform/join.d.ts +1 -1
  85. package/xform/join.js +1 -1
  86. package/xform/nest.d.ts +1 -1
  87. package/xform/nest.js +4 -4
  88. package/xform/number.d.ts +1 -1
  89. package/xform/number.js +1 -1
  90. package/xform/print.d.ts +1 -1
  91. package/xform/print.js +2 -2
  92. package/xform/replace.d.ts +1 -1
  93. package/xform/replace.js +1 -1
  94. package/xform/trim.d.ts +1 -1
  95. package/xform/trim.js +1 -1
  96. package/xform/with-id.d.ts +1 -1
  97. package/xform/with-id.js +1 -1
  98. package/lib/index.js +0 -967
  99. package/lib/index.js.map +0 -1
  100. package/lib/index.umd.js +0 -1
  101. package/lib/index.umd.js.map +0 -1
package/presets/bits.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const BIT: import("..").LitParser<string>;
2
- export declare const BINARY_UINT: import("..").Parser<string>;
1
+ export declare const BIT: import("../api.js").LitParser<string>;
2
+ export declare const BINARY_UINT: import("../api.js").Parser<string>;
3
3
  //# sourceMappingURL=bits.d.ts.map
package/presets/bits.js CHANGED
@@ -1,6 +1,6 @@
1
- import { repeat } from "../combinators/repeat";
2
- import { xform } from "../combinators/xform";
3
- import { oneOf } from "../prims/one-of";
4
- import { xfInt } from "../xform/number";
1
+ import { repeat } from "../combinators/repeat.js";
2
+ import { xform } from "../combinators/xform.js";
3
+ import { oneOf } from "../prims/one-of.js";
4
+ import { xfInt } from "../xform/number.js";
5
5
  export const BIT = oneOf("01");
6
6
  export const BINARY_UINT = xform(repeat(BIT, 1, 32, "uint"), xfInt(2));
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Matches single decimal digit.
3
3
  */
4
- export declare const DIGIT: import("..").LitParser<string>;
4
+ export declare const DIGIT: import("../api.js").LitParser<string>;
5
5
  /**
6
6
  * Matches one or more {@link DIGIT}s.
7
7
  */
8
- export declare const DIGITS: import("..").Parser<string>;
8
+ export declare const DIGITS: import("../api.js").Parser<string>;
9
9
  //# sourceMappingURL=digits.d.ts.map
package/presets/digits.js CHANGED
@@ -1,5 +1,5 @@
1
- import { oneOrMore } from "../combinators/repeat";
2
- import { range } from "../prims/range";
1
+ import { oneOrMore } from "../combinators/repeat.js";
2
+ import { range } from "../prims/range.js";
3
3
  /**
4
4
  * Matches single decimal digit.
5
5
  */
@@ -1,7 +1,7 @@
1
- export declare const ESC: import("..").Parser<string>;
1
+ export declare const ESC: import("../api.js").Parser<string>;
2
2
  /**
3
3
  * Matches a single `\uNNNN` escaped unicode hex literal and transforms
4
4
  * it into it actual character via `String.fromCharCode()`.
5
5
  */
6
- export declare const UNICODE: import("..").Parser<string>;
6
+ export declare const UNICODE: import("../api.js").Parser<string>;
7
7
  //# sourceMappingURL=escape.d.ts.map
package/presets/escape.js CHANGED
@@ -1,12 +1,12 @@
1
- import { ESCAPES } from "@thi.ng/strings";
2
- import { repeat } from "../combinators/repeat";
3
- import { seq } from "../combinators/seq";
4
- import { xform } from "../combinators/xform";
5
- import { always } from "../prims/always";
6
- import { litD } from "../prims/lit";
7
- import { stringD } from "../prims/string";
8
- import { xfInt } from "../xform/number";
9
- import { HEX_DIGIT } from "./hex";
1
+ import { ESCAPES } from "@thi.ng/strings/escape";
2
+ import { repeat } from "../combinators/repeat.js";
3
+ import { seq } from "../combinators/seq.js";
4
+ import { xform } from "../combinators/xform.js";
5
+ import { always } from "../prims/always.js";
6
+ import { litD } from "../prims/lit.js";
7
+ import { stringD } from "../prims/string.js";
8
+ import { xfInt } from "../xform/number.js";
9
+ import { HEX_DIGIT } from "./hex.js";
10
10
  export const ESC = xform(seq([litD("\\"), always()], "esc"), ($) => {
11
11
  const id = $.children[0].result;
12
12
  const resolved = ESCAPES[id];
package/presets/hex.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Matches single hex digit (case insensitive).
3
3
  */
4
- export declare const HEX_DIGIT: import("..").LitParser<string>;
4
+ export declare const HEX_DIGIT: import("../api.js").LitParser<string>;
5
5
  /**
6
6
  * Matches one or more {@link HEX_DIGIT}s.
7
7
  */
8
- export declare const HEX_DIGITS: import("..").Parser<string>;
8
+ export declare const HEX_DIGITS: import("../api.js").Parser<string>;
9
9
  /**
10
10
  * Matches 1-8 successive {@link HEX_DIGIT} and transforms with
11
11
  * {@link xfInt} to JS number.
12
12
  */
13
- export declare const HEX_UINT: import("..").Parser<string>;
13
+ export declare const HEX_UINT: import("../api.js").Parser<string>;
14
14
  //# sourceMappingURL=hex.d.ts.map
package/presets/hex.js CHANGED
@@ -1,8 +1,8 @@
1
- import { HEX } from "@thi.ng/strings";
2
- import { oneOrMore, repeat } from "../combinators/repeat";
3
- import { xform } from "../combinators/xform";
4
- import { oneOf } from "../prims/one-of";
5
- import { xfInt } from "../xform/number";
1
+ import { HEX } from "@thi.ng/strings/groups";
2
+ import { oneOrMore, repeat } from "../combinators/repeat.js";
3
+ import { xform } from "../combinators/xform.js";
4
+ import { oneOf } from "../prims/one-of.js";
5
+ import { xfInt } from "../xform/number.js";
6
6
  /**
7
7
  * Matches single hex digit (case insensitive).
8
8
  */
@@ -1,24 +1,24 @@
1
1
  /**
2
2
  * Matches single `+` or `-` char.
3
3
  */
4
- export declare const SIGN: import("..").Parser<string>;
4
+ export declare const SIGN: import("../api.js").Parser<string>;
5
5
  /**
6
6
  * Matches optionally signed {@link DIGITS} and result transformed w/
7
7
  * {@link xfInt} to JS number.
8
8
  */
9
- export declare const INT: import("..").Parser<string>;
9
+ export declare const INT: import("../api.js").Parser<string>;
10
10
  /**
11
11
  * Matches same as {@link DIGITS} but result transformed w/
12
12
  * {@link xfInt} to JS number.
13
13
  */
14
- export declare const UINT: import("..").Parser<string>;
14
+ export declare const UINT: import("../api.js").Parser<string>;
15
15
  /**
16
16
  * Matches IEEE754 floating point number.
17
17
  */
18
- export declare const REAL: import("..").Parser<string>;
18
+ export declare const REAL: import("../api.js").Parser<string>;
19
19
  /**
20
20
  * Like {@link REAL} but transforms result w/ {@link xfFloat} to JS
21
21
  * number.
22
22
  */
23
- export declare const FLOAT: import("..").Parser<string>;
23
+ export declare const FLOAT: import("../api.js").Parser<string>;
24
24
  //# sourceMappingURL=numbers.d.ts.map
@@ -1,15 +1,15 @@
1
- import { alt } from "../combinators/alt";
2
- import { maybe } from "../combinators/maybe";
3
- import { zeroOrMore } from "../combinators/repeat";
4
- import { seq } from "../combinators/seq";
5
- import { xform } from "../combinators/xform";
6
- import { lit } from "../prims/lit";
7
- import { oneOf } from "../prims/one-of";
8
- import { comp } from "../xform/comp";
9
- import { join } from "../xform/join";
10
- import { xfFloat, xfInt } from "../xform/number";
11
- import { xfID } from "../xform/with-id";
12
- import { DIGIT, DIGITS } from "./digits";
1
+ import { alt } from "../combinators/alt.js";
2
+ import { maybe } from "../combinators/maybe.js";
3
+ import { zeroOrMore } from "../combinators/repeat.js";
4
+ import { seq } from "../combinators/seq.js";
5
+ import { xform } from "../combinators/xform.js";
6
+ import { lit } from "../prims/lit.js";
7
+ import { oneOf } from "../prims/one-of.js";
8
+ import { comp } from "../xform/comp.js";
9
+ import { join } from "../xform/join.js";
10
+ import { xfFloat, xfInt } from "../xform/number.js";
11
+ import { xfID } from "../xform/with-id.js";
12
+ import { DIGIT, DIGITS } from "./digits.js";
13
13
  /**
14
14
  * Matches single `+` or `-` char.
15
15
  */
@@ -1,2 +1,2 @@
1
- export declare const STRING: import("..").Parser<string>;
1
+ export declare const STRING: import("../api.js").Parser<string>;
2
2
  //# sourceMappingURL=string.d.ts.map
package/presets/string.js CHANGED
@@ -1,9 +1,9 @@
1
- import { alt } from "../combinators/alt";
2
- import { zeroOrMore } from "../combinators/repeat";
3
- import { seq } from "../combinators/seq";
4
- import { litD } from "../prims/lit";
5
- import { noneOf } from "../prims/none-of";
6
- import { join } from "../xform/join";
7
- import { ESC, UNICODE } from "./escape";
1
+ import { alt } from "../combinators/alt.js";
2
+ import { zeroOrMore } from "../combinators/repeat.js";
3
+ import { seq } from "../combinators/seq.js";
4
+ import { litD } from "../prims/lit.js";
5
+ import { noneOf } from "../prims/none-of.js";
6
+ import { join } from "../xform/join.js";
7
+ import { ESC, UNICODE } from "./escape.js";
8
8
  const quote = litD('"');
9
9
  export const STRING = join(seq([quote, zeroOrMore(alt([UNICODE, ESC, noneOf('"')])), quote], "string"));
@@ -1,33 +1,33 @@
1
1
  /**
2
2
  * Matches & discards single whitespace char: ` \t\n\r`.
3
3
  */
4
- export declare const WS: import("..").LitParser<string>;
4
+ export declare const WS: import("../api.js").LitParser<string>;
5
5
  /**
6
6
  * Matches & discards single space or tab char.
7
7
  */
8
- export declare const SPACE: import("..").LitParser<string>;
8
+ export declare const SPACE: import("../api.js").LitParser<string>;
9
9
  /**
10
10
  * Matches single `\n` or `\r` char.
11
11
  */
12
- export declare const NL: import("..").LitParser<string>;
12
+ export declare const NL: import("../api.js").LitParser<string>;
13
13
  /**
14
14
  * Matches & discards single `\n` or `\r` char.
15
15
  */
16
- export declare const DNL: import("..").LitParser<string>;
16
+ export declare const DNL: import("../api.js").LitParser<string>;
17
17
  /**
18
18
  * Zero or more {@link WS}. Result will be discarded.
19
19
  */
20
- export declare const WS0: import("..").Parser<any>;
20
+ export declare const WS0: import("../api.js").Parser<any>;
21
21
  /**
22
22
  * One or more {@link WS}. Result will be discarded.
23
23
  */
24
- export declare const WS1: import("..").Parser<any>;
24
+ export declare const WS1: import("../api.js").Parser<any>;
25
25
  /**
26
26
  * Zero or more {@link SPACE}. Result will be discarded.
27
27
  */
28
- export declare const SPACES0: import("..").Parser<any>;
28
+ export declare const SPACES0: import("../api.js").Parser<any>;
29
29
  /**
30
30
  * One or more {@link SPACE}. Result will be discarded.
31
31
  */
32
- export declare const SPACES: import("..").Parser<any>;
32
+ export declare const SPACES: import("../api.js").Parser<any>;
33
33
  //# sourceMappingURL=whitespace.d.ts.map
@@ -1,6 +1,6 @@
1
- import { WS as _WS } from "@thi.ng/strings";
2
- import { oneOrMoreD, zeroOrMoreD } from "../combinators/repeat";
3
- import { oneOf, oneOfD } from "../prims/one-of";
1
+ import { WS as _WS } from "@thi.ng/strings/groups";
2
+ import { oneOrMoreD, zeroOrMoreD } from "../combinators/repeat.js";
3
+ import { oneOf, oneOfD } from "../prims/one-of.js";
4
4
  /**
5
5
  * Matches & discards single whitespace char: ` \t\n\r`.
6
6
  */
package/prims/always.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const always: (id?: string) => import("..").LitParser<any>;
2
- export declare const alwaysD: () => import("..").LitParser<any>;
1
+ export declare const always: (id?: string) => import("../api.js").LitParser<any>;
2
+ export declare const alwaysD: () => import("../api.js").LitParser<any>;
3
3
  //# sourceMappingURL=always.d.ts.map
package/prims/always.js CHANGED
@@ -1,3 +1,3 @@
1
- import { satisfy, satisfyD } from "./satisfy";
1
+ import { satisfy, satisfyD } from "./satisfy.js";
2
2
  export const always = (id = "always") => satisfy(() => true, id);
3
3
  export const alwaysD = () => satisfyD(() => true);
package/prims/anchor.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Nullable, Predicate2 } from "@thi.ng/api";
2
- import type { Parser } from "../api";
2
+ import type { Parser } from "../api.js";
3
3
  export declare const anchor: <T>(fn: Predicate2<Nullable<T>>) => Parser<T>;
4
4
  export declare const inputStart: Parser<any>;
5
5
  export declare const inputEnd: Parser<any>;
package/prims/anchor.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ALPHA_NUM } from "@thi.ng/strings";
1
+ import { ALPHA_NUM } from "@thi.ng/strings/groups";
2
2
  export const anchor = (fn) => (ctx) => {
3
3
  const state = ctx.state;
4
4
  return fn(state.last, state.done ? null : ctx.reader.read(state));
package/prims/fail.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Parser } from "../api";
1
+ import type { Parser } from "../api.js";
2
2
  export declare const fail: (msg: string) => Parser<any>;
3
3
  //# sourceMappingURL=fail.d.ts.map
package/prims/fail.js CHANGED
@@ -1,2 +1,2 @@
1
- import { parseError } from "../error";
1
+ import { parseError } from "../error.js";
2
2
  export const fail = (msg) => (ctx) => parseError(ctx, msg);
package/prims/lit.d.ts CHANGED
@@ -10,11 +10,11 @@ export declare const litP: <T>(c: T) => (x: T) => boolean;
10
10
  * @param c
11
11
  * @param id
12
12
  */
13
- export declare const lit: <T>(c: T, id?: string) => import("..").LitParser<T>;
13
+ export declare const lit: <T>(c: T, id?: string) => import("../api.js").LitParser<T>;
14
14
  /**
15
15
  * Discarded literal. Same as {@link lit}, but result will be discarded.
16
16
  *
17
17
  * @param c
18
18
  */
19
- export declare const litD: <T>(c: T) => import("..").LitParser<T>;
19
+ export declare const litD: <T>(c: T) => import("../api.js").LitParser<T>;
20
20
  //# sourceMappingURL=lit.d.ts.map
package/prims/lit.js CHANGED
@@ -1,4 +1,4 @@
1
- import { satisfyD, satisfy } from "./satisfy";
1
+ import { satisfyD, satisfy } from "./satisfy.js";
2
2
  /**
3
3
  * HOF predicate for matching given single char literal.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import type { CharSet, LitParser } from "../api";
2
+ import type { CharSet, LitParser } from "../api.js";
3
3
  /**
4
4
  * HOF predicate for matching single char against given options. Returns
5
5
  * true if there's no match.
package/prims/none-of.js CHANGED
@@ -1,5 +1,6 @@
1
- import { isPlainObject, isSet } from "@thi.ng/checks";
2
- import { satisfy, satisfyD } from "./satisfy";
1
+ import { isPlainObject } from "@thi.ng/checks/is-plain-object";
2
+ import { isSet } from "@thi.ng/checks/is-set";
3
+ import { satisfy, satisfyD } from "./satisfy.js";
3
4
  /**
4
5
  * HOF predicate for matching single char against given options. Returns
5
6
  * true if there's no match.
package/prims/one-of.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import type { CharSet, LitParser } from "../api";
2
+ import type { CharSet, LitParser } from "../api.js";
3
3
  /**
4
4
  * HOF predicate for matching single char against given options.
5
5
  *
package/prims/one-of.js CHANGED
@@ -1,5 +1,6 @@
1
- import { isPlainObject, isSet } from "@thi.ng/checks";
2
- import { satisfy, satisfyD } from "./satisfy";
1
+ import { isPlainObject } from "@thi.ng/checks/is-plain-object";
2
+ import { isSet } from "@thi.ng/checks/is-set";
3
+ import { satisfy, satisfyD } from "./satisfy.js";
3
4
  /**
4
5
  * HOF predicate for matching single char against given options.
5
6
  *
package/prims/pass.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Parser, PassValue } from "../api";
1
+ import type { Parser, PassValue } from "../api.js";
2
2
  /**
3
3
  * Parser which consumes no input and always succeeds. Adds new AST node
4
4
  * with `result`.
package/prims/pass.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isFunction } from "@thi.ng/checks";
1
+ import { isFunction } from "@thi.ng/checks/is-function";
2
2
  /**
3
3
  * Parser which consumes no input and always succeeds. Adds new AST node
4
4
  * with `result`.
package/prims/range.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { NumOrString, Predicate } from "@thi.ng/api";
2
- import type { LitParser } from "../api";
2
+ import type { LitParser } from "../api.js";
3
3
  /**
4
4
  * HOF predicate for matching single char within given range.
5
5
  *
package/prims/range.js CHANGED
@@ -1,4 +1,4 @@
1
- import { satisfy, satisfyD } from "./satisfy";
1
+ import { satisfy, satisfyD } from "./satisfy.js";
2
2
  /**
3
3
  * HOF predicate for matching single char within given range.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import type { LitParser } from "../api";
2
+ import type { LitParser } from "../api.js";
3
3
  export declare const satisfy: <T>(pred: Predicate<T>, id?: string) => LitParser<T>;
4
4
  /**
5
5
  * Like {@link satisfy}, but avoids creating AST node and discards
package/prims/skip.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Predicate } from "@thi.ng/api";
2
- import type { Parser } from "../api";
2
+ import type { Parser } from "../api.js";
3
3
  /**
4
4
  * Consumes input, but ignores it as long as given `pred` predicate fn
5
5
  * returns true. The char for which `pred` fails will NOT be consumed
package/prims/skip.js CHANGED
@@ -19,7 +19,7 @@
19
19
  * @param pred
20
20
  */
21
21
  export const skipWhile = (pred) => (ctx) => {
22
- const state = Object.assign({}, ctx.state);
22
+ const state = { ...ctx.state };
23
23
  const reader = ctx.reader;
24
24
  while (!state.done) {
25
25
  if (!pred(reader.read(state)))
package/prims/string.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fn, Predicate } from "@thi.ng/api";
2
- import type { Parser } from "../api";
2
+ import type { Parser } from "../api.js";
3
3
  export declare const string: <T>(str: ArrayLike<T>, id?: string) => Parser<T>;
4
4
  export declare const stringD: <T>(str: ArrayLike<T>) => Parser<T>;
5
5
  export declare const stringOf: <T>(pred: Predicate<T>, id?: string, reduce?: Fn<T[], any>) => Parser<T>;
package/prims/string.js CHANGED
@@ -19,7 +19,7 @@ export const string = (str, id = "string") => (ctx) => {
19
19
  export const stringD = (str) => (ctx) => {
20
20
  if (ctx.done)
21
21
  return false;
22
- const state = Object.assign({}, ctx.state);
22
+ const state = { ...ctx.state };
23
23
  const reader = ctx.reader;
24
24
  for (let i = 0, n = str.length; i < n; i++) {
25
25
  if (state.done)
@@ -34,7 +34,7 @@ export const stringD = (str) => (ctx) => {
34
34
  return true;
35
35
  };
36
36
  export const stringOf = (pred, id = "string", reduce = (x) => x.join("")) => (ctx) => {
37
- const state = Object.assign({}, ctx.state);
37
+ const state = { ...ctx.state };
38
38
  const reader = ctx.reader;
39
39
  let acc = [];
40
40
  while (!state.done) {
@@ -1,4 +1,4 @@
1
- import type { ParseState, IReader } from "../api";
1
+ import type { ParseState, IReader } from "../api.js";
2
2
  declare class ArrayReader<T> implements IReader<T> {
3
3
  protected _src: ArrayLike<T>;
4
4
  constructor(_src: ArrayLike<T>);
@@ -1,4 +1,4 @@
1
- import type { ParseState, IReader } from "../api";
1
+ import type { ParseState, IReader } from "../api.js";
2
2
  declare class StringReader implements IReader<string> {
3
3
  protected _src: string;
4
4
  constructor(_src: string);
package/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ // thing:no-export
1
2
  const cache = [];
2
3
  /**
3
4
  * Memoized indentation.
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Collects results of all direct children into an array, then discards
4
4
  * children. Also see {@link collect}.
package/xform/collect.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Collects results of all direct children into an array, then discards
4
4
  * children. Also see {@link collect}.
package/xform/comp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ScopeTransform } from "../api";
1
+ import type { ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Takes any number of {@link ScopeTransform}s and composes them into
4
4
  * new xform w/ left to right order of execution.
package/xform/count.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Stores number of children as result, then discards children. Also see
4
4
  * {@link count}.
package/xform/count.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Stores number of children as result, then discards children. Also see
4
4
  * {@link count}.
@@ -1,4 +1,4 @@
1
- import type { Parser } from "../api";
1
+ import type { Parser } from "../api.js";
2
2
  /**
3
3
  * Discards AST node and any of its children.
4
4
  */
package/xform/discard.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Discards AST node and any of its children.
4
4
  */
package/xform/hoist.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Replace AST node with its first child node. Also see {@link hoist}.
4
4
  *
package/xform/hoist.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Replace AST node with its first child node. Also see {@link hoist}.
4
4
  *
package/xform/join.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Nullable } from "@thi.ng/api";
2
- import type { Parser, ParseScope } from "../api";
2
+ import type { Parser, ParseScope } from "../api.js";
3
3
  /**
4
4
  * Recursively joins non-null results of all children into a single
5
5
  * string, then discards children. Also see {@link join}.
package/xform/join.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Recursively joins non-null results of all children into a single
4
4
  * string, then discards children. Also see {@link join}.
package/xform/nest.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * HOF scope transform which applies given parser to result of given scope's
4
4
  * result, or if result is null, first joins children using {@link xfJoin}.
package/xform/nest.js CHANGED
@@ -1,6 +1,6 @@
1
- import { xform } from "../combinators/xform";
2
- import { defContext } from "../context";
3
- import { xfJoin } from "./join";
1
+ import { xform } from "../combinators/xform.js";
2
+ import { defContext } from "../context.js";
3
+ import { xfJoin } from "./join.js";
4
4
  /**
5
5
  * HOF scope transform which applies given parser to result of given scope's
6
6
  * result, or if result is null, first joins children using {@link xfJoin}.
@@ -19,7 +19,7 @@ import { xfJoin } from "./join";
19
19
  export const xfNest = (parser) => (scope, ctx) => {
20
20
  if (!scope)
21
21
  return;
22
- const src = scope.result || xfJoin(Object.assign({}, scope)).result;
22
+ const src = scope.result || xfJoin({ ...scope }).result;
23
23
  const inner = defContext(src, ctx.opts);
24
24
  const state = scope.state;
25
25
  if (state) {
package/xform/number.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ScopeTransform } from "../api";
1
+ import type { ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Higher order transform. First joins all children via {@link xfJoin},
4
4
  * then parses resulting string into an integer with given `radix`.
package/xform/number.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xfJoin } from "./join";
1
+ import { xfJoin } from "./join.js";
2
2
  /**
3
3
  * Higher order transform. First joins all children via {@link xfJoin},
4
4
  * then parses resulting string into an integer with given `radix`.
package/xform/print.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Fn } from "@thi.ng/api";
2
- import type { Parser, ScopeTransform } from "../api";
2
+ import type { Parser, ScopeTransform } from "../api.js";
3
3
  /**
4
4
  * Side effect only. Higher order scope transform. Traverses current AST
5
5
  * node and all children and prints each node's ID, result and reader
package/xform/print.js CHANGED
@@ -1,5 +1,5 @@
1
- import { xform } from "../combinators/xform";
2
- import { indent } from "../utils";
1
+ import { xform } from "../combinators/xform.js";
2
+ import { indent } from "../utils.js";
3
3
  /**
4
4
  * Side effect only. Higher order scope transform. Traverses current AST
5
5
  * node and all children and prints each node's ID, result and reader
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * HOF scope transform which replaces a node's result with given pre-configured
4
4
  * value and discards node's children. Also see {@link replace}.
package/xform/replace.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * HOF scope transform which replaces a node's result with given pre-configured
4
4
  * value and discards node's children. Also see {@link replace}.
package/xform/trim.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Parser, ScopeTransform } from "../api";
1
+ import type { Parser, ScopeTransform } from "../api.js";
2
2
  /**
3
3
  * Uses `String.trim()` to remove leading and trailing white space and
4
4
  * linebreak chars from node result.
package/xform/trim.js CHANGED
@@ -1,4 +1,4 @@
1
- import { xform } from "../combinators/xform";
1
+ import { xform } from "../combinators/xform.js";
2
2
  /**
3
3
  * Uses `String.trim()` to remove leading and trailing white space and
4
4
  * linebreak chars from node result.