functionalscript 0.1.609 → 0.2.0

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 (175) hide show
  1. package/com/cpp/module.f.d.mts +4 -8
  2. package/com/cpp/module.f.mjs +20 -25
  3. package/com/cpp/testlib.f.mjs +3 -4
  4. package/com/cs/module.f.d.mts +4 -8
  5. package/com/cs/module.f.mjs +18 -23
  6. package/com/cs/testlib.f.mjs +3 -5
  7. package/com/rust/module.f.d.mts +3 -7
  8. package/com/rust/module.f.mjs +25 -30
  9. package/com/rust/testlib.f.mjs +3 -5
  10. package/com/test/build.f.d.mts +2 -2
  11. package/com/test/build.f.mjs +2 -2
  12. package/com/test/build.mjs +4 -4
  13. package/com/types/module.f.d.mts +5 -10
  14. package/com/types/module.f.mjs +5 -12
  15. package/commonjs/build/module.f.d.mts +13 -17
  16. package/commonjs/build/module.f.mjs +23 -28
  17. package/commonjs/build/test.f.mjs +4 -4
  18. package/commonjs/module/function/module.f.d.mts +0 -2
  19. package/commonjs/module/function/module.f.mjs +0 -2
  20. package/commonjs/module/module.f.d.mts +16 -21
  21. package/commonjs/module/module.f.mjs +2 -9
  22. package/commonjs/module.d.mts +1 -5
  23. package/commonjs/module.f.d.mts +0 -2
  24. package/commonjs/module.f.mjs +0 -2
  25. package/commonjs/module.mjs +2 -7
  26. package/commonjs/package/dependencies/module.f.d.mts +3 -7
  27. package/commonjs/package/dependencies/module.f.mjs +5 -10
  28. package/commonjs/package/dependencies/test.f.mjs +1 -1
  29. package/commonjs/package/module.f.d.mts +12 -18
  30. package/commonjs/package/module.f.mjs +6 -13
  31. package/commonjs/package/test.f.mjs +1 -1
  32. package/commonjs/path/module.f.d.mts +25 -32
  33. package/commonjs/path/module.f.mjs +12 -23
  34. package/commonjs/path/test.f.mjs +11 -11
  35. package/commonjs/test.mjs +1 -1
  36. package/dev/module.f.d.mts +1 -4
  37. package/dev/module.f.mjs +1 -4
  38. package/dev/test/module.f.d.mts +2 -3
  39. package/dev/test/module.f.mjs +4 -6
  40. package/djs/module.f.d.mts +13 -18
  41. package/djs/module.f.mjs +12 -19
  42. package/djs/parser/module.f.d.mts +11 -15
  43. package/djs/parser/module.f.mjs +18 -24
  44. package/djs/parser/test.f.mjs +9 -9
  45. package/djs/test.f.mjs +4 -4
  46. package/djs/tokenizer/module.f.d.mts +6 -10
  47. package/djs/tokenizer/module.f.mjs +18 -23
  48. package/djs/tokenizer/test.f.mjs +6 -6
  49. package/fsc/module.f.d.mts +4 -9
  50. package/fsc/module.f.mjs +17 -24
  51. package/fsc/test.f.mjs +3 -3
  52. package/fsm/module.f.d.mts +13 -20
  53. package/fsm/module.f.mjs +27 -38
  54. package/fsm/test.f.mjs +8 -8
  55. package/html/module.f.d.mts +7 -12
  56. package/html/module.f.mjs +14 -23
  57. package/html/test.f.mjs +4 -4
  58. package/js/tokenizer/module.f.d.mts +10 -15
  59. package/js/tokenizer/module.f.mjs +55 -62
  60. package/js/tokenizer/test.f.mjs +6 -6
  61. package/json/module.f.d.mts +18 -26
  62. package/json/module.f.mjs +18 -31
  63. package/json/parser/module.f.d.mts +9 -13
  64. package/json/parser/module.f.mjs +9 -14
  65. package/json/parser/test.f.mjs +7 -7
  66. package/json/serializer/module.f.d.mts +11 -20
  67. package/json/serializer/module.f.mjs +14 -29
  68. package/json/serializer/test.f.mjs +2 -2
  69. package/json/test.f.mjs +3 -3
  70. package/json/tokenizer/module.f.d.mts +6 -10
  71. package/json/tokenizer/module.f.mjs +14 -19
  72. package/json/tokenizer/test.f.mjs +6 -6
  73. package/jsr.json +1 -1
  74. package/nodejs/version/main.mjs +1 -1
  75. package/nodejs/version/module.f.d.mts +4 -9
  76. package/nodejs/version/module.f.mjs +2 -7
  77. package/nodejs/version/test.f.mjs +3 -3
  78. package/package.json +1 -1
  79. package/prime_field/module.f.d.mts +20 -23
  80. package/prime_field/module.f.mjs +9 -12
  81. package/prime_field/test.f.mjs +1 -1
  82. package/secp/module.f.d.mts +27 -28
  83. package/secp/module.f.mjs +38 -39
  84. package/secp/test.f.mjs +4 -4
  85. package/sha2/module.f.d.mts +8 -16
  86. package/sha2/module.f.mjs +7 -20
  87. package/sha2/test.f.mjs +4 -4
  88. package/text/ascii/module.f.d.mts +69 -72
  89. package/text/ascii/module.f.mjs +5 -10
  90. package/text/ascii/test.f.mjs +3 -3
  91. package/text/module.f.d.mts +9 -14
  92. package/text/module.f.mjs +7 -14
  93. package/text/sgr/module.f.d.mts +7 -9
  94. package/text/sgr/module.f.mjs +2 -4
  95. package/text/test.f.mjs +3 -3
  96. package/text/utf16/module.f.d.mts +8 -15
  97. package/text/utf16/module.f.mjs +17 -28
  98. package/text/utf16/test.f.mjs +5 -5
  99. package/text/utf8/module.f.d.mts +4 -9
  100. package/text/utf8/module.f.mjs +9 -16
  101. package/text/utf8/test.f.mjs +4 -4
  102. package/types/array/module.f.d.mts +14 -24
  103. package/types/array/module.f.mjs +8 -25
  104. package/types/array/test.f.mjs +3 -3
  105. package/types/bigfloat/module.f.d.mts +4 -9
  106. package/types/bigfloat/module.f.mjs +3 -10
  107. package/types/bigfloat/test.f.mjs +1 -1
  108. package/types/bigint/module.f.d.mts +16 -64
  109. package/types/bigint/module.f.mjs +11 -30
  110. package/types/bigint/test.f.mjs +1 -1
  111. package/types/btree/find/module.f.d.mts +20 -26
  112. package/types/btree/find/module.f.mjs +8 -17
  113. package/types/btree/find/test.f.mjs +7 -7
  114. package/types/btree/module.f.d.mts +4 -8
  115. package/types/btree/module.f.mjs +6 -11
  116. package/types/btree/remove/module.f.d.mts +7 -12
  117. package/types/btree/remove/module.f.mjs +10 -17
  118. package/types/btree/remove/test.f.mjs +5 -5
  119. package/types/btree/set/module.f.d.mts +3 -7
  120. package/types/btree/set/module.f.mjs +4 -9
  121. package/types/btree/set/test.f.mjs +4 -4
  122. package/types/btree/test.f.mjs +9 -9
  123. package/types/btree/types/module.f.d.mts +0 -2
  124. package/types/btree/types/module.f.mjs +0 -2
  125. package/types/byte_set/module.f.d.mts +16 -29
  126. package/types/byte_set/module.f.mjs +14 -39
  127. package/types/byte_set/test.f.mjs +5 -5
  128. package/types/function/compare/module.f.d.mts +9 -15
  129. package/types/function/compare/module.f.mjs +3 -12
  130. package/types/function/compare/test.f.mjs +1 -1
  131. package/types/function/module.f.d.mts +20 -27
  132. package/types/function/module.f.mjs +4 -15
  133. package/types/function/operator/module.f.d.mts +28 -43
  134. package/types/function/operator/module.f.mjs +14 -41
  135. package/types/function/test.f.mjs +1 -1
  136. package/types/list/module.f.d.mts +56 -91
  137. package/types/list/module.f.mjs +45 -114
  138. package/types/list/test.f.mjs +10 -10
  139. package/types/map/module.f.d.mts +15 -24
  140. package/types/map/module.f.mjs +15 -30
  141. package/types/map/test.f.mjs +2 -2
  142. package/types/nibble_set/module.f.d.mts +10 -20
  143. package/types/nibble_set/module.f.mjs +7 -24
  144. package/types/nibble_set/test.f.mjs +2 -2
  145. package/types/nullable/module.f.d.mts +3 -8
  146. package/types/nullable/module.f.mjs +2 -9
  147. package/types/nullable/test.f.mjs +1 -1
  148. package/types/number/module.f.d.mts +7 -13
  149. package/types/number/module.f.mjs +8 -19
  150. package/types/number/test.f.mjs +1 -1
  151. package/types/object/module.f.d.mts +11 -18
  152. package/types/object/module.f.mjs +9 -20
  153. package/types/object/test.f.mjs +1 -1
  154. package/types/range/module.f.d.mts +3 -8
  155. package/types/range/module.f.mjs +2 -9
  156. package/types/range/test.f.mjs +1 -1
  157. package/types/range_map/module.f.d.mts +9 -15
  158. package/types/range_map/module.f.mjs +9 -18
  159. package/types/range_map/test.f.mjs +32 -32
  160. package/types/result/module.d.mts +3 -3
  161. package/types/result/module.f.d.mts +6 -12
  162. package/types/result/module.f.mjs +3 -12
  163. package/types/result/module.mjs +2 -2
  164. package/types/sorted_list/module.f.d.mts +22 -28
  165. package/types/sorted_list/module.f.mjs +10 -19
  166. package/types/sorted_list/test.f.mjs +7 -7
  167. package/types/sorted_set/module.f.d.mts +6 -12
  168. package/types/sorted_set/module.f.mjs +7 -16
  169. package/types/sorted_set/test.f.mjs +7 -7
  170. package/types/string/module.f.d.mts +8 -14
  171. package/types/string/module.f.mjs +10 -21
  172. package/types/string/test.f.mjs +2 -2
  173. package/types/string_set/module.f.d.mts +8 -16
  174. package/types/string_set/module.f.mjs +12 -27
  175. package/types/string_set/test.f.mjs +1 -1
@@ -1,18 +1,18 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import operator, * as Operator from '../../types/function/operator/module.f.mjs'
3
- import range_map, * as RangeMap from '../../types/range_map/module.f.mjs'
2
+ import * as operator from '../../types/function/operator/module.f.mjs'
3
+ import * as range_map from '../../types/range_map/module.f.mjs'
4
4
  const { merge, fromRange, get } = range_map
5
- import list, * as List from '../../types/list/module.f.mjs'
6
- import map, * as Map from '../../types/map/module.f.mjs'
5
+ import * as list from '../../types/list/module.f.mjs'
6
+ import * as map from '../../types/map/module.f.mjs'
7
7
  const { at } = map
8
- import _range, * as Range from '../../types/range/module.f.mjs'
8
+ import * as _range from '../../types/range/module.f.mjs'
9
9
  const { one } = _range
10
10
  const { empty, stateScan, flat, toArray, reduce: listReduce, scan } = list
11
11
  import * as bigfloatT from '../../types/bigfloat/module.f.mjs'
12
12
  const { fromCharCode } = String
13
- import ascii from '../../text/ascii/module.f.mjs'
13
+ import * as ascii from '../../text/ascii/module.f.mjs'
14
+ const { range } = ascii
14
15
  const {
15
- range,
16
16
  //
17
17
  backspace,
18
18
  ht,
@@ -68,7 +68,7 @@ const {
68
68
  leftCurlyBracket,
69
69
  rightCurlyBracket,
70
70
  dollarSign
71
- } = ascii
71
+ } = ascii.ascii
72
72
 
73
73
  /**
74
74
  * @typedef {{
@@ -157,9 +157,9 @@ const {
157
157
 
158
158
  const rangeOneNine = range('19')
159
159
 
160
- const rangeSetNewLine = [
160
+ const rangeSetNewLine = [
161
161
  one(lf),
162
- one(cr)
162
+ one(cr)
163
163
  ]
164
164
 
165
165
  const rangeSetWhiteSpace = [
@@ -309,14 +309,14 @@ const rangeId = [digitRange, ...rangeIdStart]
309
309
 
310
310
  /** @typedef {number|null} CharCodeOrEof */
311
311
 
312
- /** @typedef {(input: number) => readonly[List.List<JsToken>, TokenizerState]} ToToken */
312
+ /** @typedef {(input: number) => readonly[list.List<JsToken>, TokenizerState]} ToToken */
313
313
 
314
314
  /**
315
315
  * @template T
316
316
  * @typedef {(state: T) => ToToken} CreateToToken<T>
317
317
  */
318
318
 
319
- /** @typedef {List.List<Range.Range>} RangeSet */
319
+ /** @typedef {list.List<_range.Range>} RangeSet */
320
320
 
321
321
  /**
322
322
  * @template T
@@ -325,7 +325,7 @@ const rangeId = [digitRange, ...rangeIdStart]
325
325
 
326
326
  /**
327
327
  * @template T
328
- * @typedef {RangeMap.RangeMapArray<CreateToToken<T>>} RangeMapToToken<T>
328
+ * @typedef {range_map.RangeMapArray<CreateToToken<T>>} RangeMapToToken<T>
329
329
  */
330
330
 
331
331
  /** @type {(old: string) => (input: number) => string} */
@@ -338,34 +338,34 @@ const union = def => a => b => {
338
338
  throw [a, b]
339
339
  }
340
340
 
341
- /** @type {<T>(def: CreateToToken<T>) => RangeMap.RangeMerge<CreateToToken<T>>} */
341
+ /** @type {<T>(def: CreateToToken<T>) => range_map.RangeMerge<CreateToToken<T>>} */
342
342
  const rangeMapMerge = def => merge({
343
343
  union: union(def),
344
344
  equal: operator.strictEqual,
345
345
  })
346
346
 
347
- /** @type {<T>(r: Range.Range) => (f: CreateToToken<T>) => RangeFunc<T>} */
347
+ /** @type {<T>(r: _range.Range) => (f: CreateToToken<T>) => RangeFunc<T>} */
348
348
  const rangeFunc = r => f => def => fromRange(def)(r)(f)
349
349
 
350
- /** @type {<T>(def: CreateToToken<T>) => (Operator.Scan<RangeFunc<T>, RangeMapToToken<T>>)} */
350
+ /** @type {<T>(def: CreateToToken<T>) => (operator.Scan<RangeFunc<T>, RangeMapToToken<T>>)} */
351
351
  const scanRangeOp = def => f => [f(def), scanRangeOp(def)]
352
352
 
353
- /** @type {<T>(def: CreateToToken<T>) => (a: List.List<RangeFunc<T>>) => RangeMapToToken<T>} */
353
+ /** @type {<T>(def: CreateToToken<T>) => (a: list.List<RangeFunc<T>>) => RangeMapToToken<T>} */
354
354
  const reduceRangeMap = def => a => {
355
355
  const rm = scan(scanRangeOp(def))(a)
356
356
  return toArray(listReduce(rangeMapMerge(def))(empty)(rm))
357
357
  }
358
358
 
359
- /** @type {<T>(def: CreateToToken<T>) => (f: CreateToToken<T>) => (Operator.Scan<Range.Range, RangeMapToToken<T>>)} */
359
+ /** @type {<T>(def: CreateToToken<T>) => (f: CreateToToken<T>) => (operator.Scan<_range.Range, RangeMapToToken<T>>)} */
360
360
  const scanRangeSetOp = def => f => r => [fromRange(def)(r)(f), scanRangeSetOp(def)(f)]
361
361
 
362
- /** @type {<T>(rs: List.List<Range.Range>) => (f: CreateToToken<T>) => RangeFunc<T>} */
362
+ /** @type {<T>(rs: list.List<_range.Range>) => (f: CreateToToken<T>) => RangeFunc<T>} */
363
363
  const rangeSetFunc = rs => f => def => {
364
364
  const rm = scan(scanRangeSetOp(def)(f))(rs)
365
365
  return toArray(listReduce(rangeMapMerge(def))(empty)(rm))
366
366
  }
367
367
 
368
- /** @type {<T>(def: CreateToToken<T>) => (a: List.List<RangeFunc<T>>) => CreateToToken<T>} */
368
+ /** @type {<T>(def: CreateToToken<T>) => (a: list.List<RangeFunc<T>>) => CreateToToken<T>} */
369
369
  const create = def => a => {
370
370
  /** @typedef {typeof def extends CreateToToken<infer T> ? T : never} T */
371
371
  const i = reduceRangeMap(def)(a)
@@ -402,7 +402,7 @@ const bufferToNumberToken = ({numberKind, value, b}) =>
402
402
 
403
403
  /**
404
404
  * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords
405
- * @type {List.List<Map.Entry<JsToken>>}
405
+ * @type {list.List<map.Entry<JsToken>>}
406
406
  */
407
407
  const keywordEntries = [
408
408
  ['arguments', { kind: 'arguments'}],
@@ -458,11 +458,11 @@ const keywordEntries = [
458
458
  const keywordMap = map.fromEntries(keywordEntries)
459
459
 
460
460
  /** @type {(token: JsToken) => Boolean} */
461
- const isKeywordToken = token => at(token.kind)(keywordMap) !== null
461
+ export const isKeywordToken = token => at(token.kind)(keywordMap) !== null
462
462
 
463
463
  /**
464
464
  * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators
465
- * @type {List.List<Map.Entry<JsToken>>}
465
+ * @type {list.List<map.Entry<JsToken>>}
466
466
  */
467
467
  const operatorEntries = [
468
468
  ['!', { kind: '!'}],
@@ -530,7 +530,7 @@ const getOperatorToken = op => at(op)(operatorMap) ?? { kind: 'error', message:
530
530
  /** @type {(op: string) => Boolean} */
531
531
  const hasOperatorToken = op => at(op)(operatorMap) !== null
532
532
 
533
- /** @type {(state: InitialState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
533
+ /** @type {(state: InitialState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
534
534
  const initialStateOp = create(state => () => [[{ kind: 'error', message: 'unexpected character' }], state])([
535
535
  rangeFunc(rangeOneNine)(() => input => [empty, { kind: 'number', value: fromCharCode(input), b: startNumber(input), numberKind: 'int' }]),
536
536
  rangeSetFunc(rangeIdStart)(() => input => [empty, { kind: 'id', value: fromCharCode(input) }]),
@@ -541,14 +541,14 @@ const initialStateOp = create(state => () => [[{ kind: 'error', message: 'unexpe
541
541
  rangeSetFunc(rangeOpStart)(() => input => [empty, { kind: 'op', value: fromCharCode(input) }])
542
542
  ])
543
543
 
544
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
544
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
545
545
  const invalidNumberToToken = () => input =>
546
546
  {
547
547
  const next = tokenizeOp({ kind: 'initial' })(input)
548
548
  return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]]
549
549
  }
550
550
 
551
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
551
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
552
552
  const fullStopToToken = state => input => {
553
553
  switch (state.numberKind) {
554
554
  case '0':
@@ -557,7 +557,7 @@ const fullStopToToken = state => input => {
557
557
  }
558
558
  }
559
559
 
560
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
560
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
561
561
  const digit0ToToken = state => input => {
562
562
  switch (state.numberKind) {
563
563
  case '0': return tokenizeOp({ kind: 'invalidNumber' })(input)
@@ -571,7 +571,7 @@ const digit0ToToken = state => input => {
571
571
  }
572
572
  }
573
573
 
574
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
574
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
575
575
  const digit19ToToken = state => input => {
576
576
  switch (state.numberKind) {
577
577
  case '0': return tokenizeOp({ kind: 'invalidNumber' })(input)
@@ -585,7 +585,7 @@ const digit19ToToken = state => input => {
585
585
  }
586
586
  }
587
587
 
588
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
588
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
589
589
  const expToToken = state => input => {
590
590
  switch (state.numberKind) {
591
591
  case '0':
@@ -595,7 +595,7 @@ const expToToken = state => input => {
595
595
  }
596
596
  }
597
597
 
598
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
598
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
599
599
  const hyphenMinusToToken = state => input => {
600
600
  switch (state.numberKind) {
601
601
  case 'e': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: { ... state.b, es: -1}, numberKind: 'e-' }]
@@ -603,7 +603,7 @@ const hyphenMinusToToken = state => input => {
603
603
  }
604
604
  }
605
605
 
606
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
606
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
607
607
  const plusSignToToken = state => input => {
608
608
  switch (state.numberKind) {
609
609
  case 'e': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: state.b, numberKind: 'e+' }]
@@ -611,7 +611,7 @@ const plusSignToToken = state => input => {
611
611
  }
612
612
  }
613
613
 
614
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
614
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
615
615
  const terminalToToken = state => input => {
616
616
  switch (state.numberKind) {
617
617
  case '.':
@@ -630,7 +630,7 @@ const terminalToToken = state => input => {
630
630
  }
631
631
  }
632
632
 
633
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
633
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
634
634
  const bigintToToken = state => input => {
635
635
  switch (state.numberKind) {
636
636
  case '0':
@@ -646,7 +646,7 @@ const bigintToToken = state => input => {
646
646
  }
647
647
  }
648
648
 
649
- /** @type {(state: ParseNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
649
+ /** @type {(state: ParseNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
650
650
  const parseNumberStateOp = create(invalidNumberToToken)([
651
651
  rangeFunc(one(fullStop))(fullStopToToken),
652
652
  rangeFunc(one(digit0))(digit0ToToken),
@@ -658,7 +658,7 @@ const parseNumberStateOp = create(invalidNumberToToken)([
658
658
  rangeFunc(one(latinSmallLetterN))(bigintToToken),
659
659
  ])
660
660
 
661
- /** @type {(state: InvalidNumberState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
661
+ /** @type {(state: InvalidNumberState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
662
662
  const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber' }])([
663
663
  rangeSetFunc(rangeSetTerminalForNumber)(() => input => {
664
664
  const next = tokenizeOp({ kind: 'initial' })(input)
@@ -666,26 +666,26 @@ const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber'
666
666
  })
667
667
  ])
668
668
 
669
- /** @type {(state: ParseMinusState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
669
+ /** @type {(state: ParseMinusState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
670
670
  const parseMinusStateOp = create(() => input => tokenizeOp({ kind: 'op', value: '-' })(input))([
671
671
  rangeFunc(one(fullStop))(() => input => tokenizeOp({ kind: 'invalidNumber' })(input)),
672
672
  rangeFunc(one(digit0))(() => () => [empty, { kind: 'number', value: '-0', b: startNegativeNumber, numberKind: '0' }]),
673
673
  rangeFunc(rangeOneNine)(() => input => [empty, { kind: 'number', value: appendChar('-')(input), b: addIntDigit(input)(startNegativeNumber), numberKind: 'int' }]),
674
674
  ])
675
675
 
676
- /** @type {(state: ParseStringState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
676
+ /** @type {(state: ParseStringState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
677
677
  const parseStringStateOp = create(state => input => [empty, { kind: 'string', value: appendChar(state.value)(input) }])([
678
678
  rangeFunc(one(quotationMark))(state => () => [[{ kind: 'string', value: state.value }], { kind: 'initial' }]),
679
679
  rangeFunc(one(reverseSolidus))(state => () => [empty, { kind: 'escapeChar', value: state.value }])
680
680
  ])
681
681
 
682
- /** @type {(state: ParseEscapeCharState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
682
+ /** @type {(state: ParseEscapeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
683
683
  const parseEscapeDefault = state => input => {
684
684
  const next = tokenizeOp({ kind: 'string', value: state.value })(input)
685
685
  return [{ first: { kind: 'error', message: 'unescaped character' }, tail: next[0] }, next[1]]
686
686
  }
687
687
 
688
- /** @type {(state: ParseEscapeCharState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
688
+ /** @type {(state: ParseEscapeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
689
689
  const parseEscapeCharStateOp = create(parseEscapeDefault)([
690
690
  rangeSetFunc([one(quotationMark), one(reverseSolidus), one(solidus)])(state => input => [empty, { kind: 'string', value: appendChar(state.value)(input) }]),
691
691
  rangeFunc(one(latinSmallLetterB))(state => () => [empty, { kind: 'string', value: appendChar(state.value)(backspace) }]),
@@ -696,13 +696,13 @@ const parseEscapeCharStateOp = create(parseEscapeDefault)([
696
696
  rangeFunc(one(latinSmallLetterU))(state => () => [empty, { kind: 'unicodeChar', value: state.value, unicode: 0, hexIndex: 0 }]),
697
697
  ])
698
698
 
699
- /** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
699
+ /** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
700
700
  const parseUnicodeCharDefault = state => input => {
701
701
  const next = tokenizeOp({ kind: 'string', value: state.value })(input)
702
702
  return [{ first: { kind: 'error', message: 'invalid hex value' }, tail: next[0] }, next[1]]
703
703
  }
704
704
 
705
- /** @type {(offser: number) => (state: ParseUnicodeCharState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
705
+ /** @type {(offser: number) => (state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
706
706
  const parseUnicodeCharHex = offset => state => input => {
707
707
  const hexValue = input - offset
708
708
  const newUnicode = state.unicode | (hexValue << (3 - state.hexIndex) * 4)
@@ -711,7 +711,7 @@ const parseUnicodeCharHex = offset => state => input => {
711
711
  { kind: 'unicodeChar', value: state.value, unicode: newUnicode, hexIndex: state.hexIndex + 1 }]
712
712
  }
713
713
 
714
- /** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
714
+ /** @type {(state: ParseUnicodeCharState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
715
715
  const parseUnicodeCharStateOp = create(parseUnicodeCharDefault)([
716
716
  rangeFunc(digitRange)(parseUnicodeCharHex(digit0)),
717
717
  rangeFunc(rangeSmallAF)(parseUnicodeCharHex(latinSmallLetterA - 10)),
@@ -721,19 +721,19 @@ const parseUnicodeCharStateOp = create(parseUnicodeCharDefault)([
721
721
  /** @type {(s: string) => JsToken} */
722
722
  const idToToken = s => at(s)(keywordMap) ?? { kind: 'id', value: s }
723
723
 
724
- /** @type {(state: ParseIdState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
724
+ /** @type {(state: ParseIdState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
725
725
  const parseIdDefault = state => input => {
726
726
  const keyWordToken = idToToken(state.value)
727
727
  const next = tokenizeOp({ kind: 'initial' })(input)
728
728
  return [{ first: keyWordToken, tail: next[0] }, next[1]]
729
729
  }
730
730
 
731
- /** @type {(state: ParseIdState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
731
+ /** @type {(state: ParseIdState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
732
732
  const parseIdStateOp = create(parseIdDefault)([
733
733
  rangeSetFunc(rangeId)(state => input => [empty, { kind: 'id', value: appendChar(state.value)(input) }])
734
734
  ])
735
735
 
736
- /** @type {(state: ParseOperatorState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
736
+ /** @type {(state: ParseOperatorState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
737
737
  const parseOperatorStateOp = state => input => {
738
738
  const nextStateValue = appendChar(state.value)(input)
739
739
  if (hasOperatorToken(nextStateValue))
@@ -742,34 +742,34 @@ const parseOperatorStateOp = state => input => {
742
742
  return [{ first: getOperatorToken(state.value), tail: next[0] }, next[1]]
743
743
  }
744
744
 
745
- /** @type {(state: ParseWhitespaceState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
745
+ /** @type {(state: ParseWhitespaceState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
746
746
  const parseWhitespaceDefault = state => input => {
747
747
  const next = tokenizeOp({ kind: 'initial' })(input)
748
748
  return [{ first: { kind: 'ws' }, tail: next[0] }, next[1]]
749
749
  }
750
750
 
751
- /** @type {(state: ParseWhitespaceState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
751
+ /** @type {(state: ParseWhitespaceState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
752
752
  const parseWhitespaceStateOp = create(parseWhitespaceDefault)([
753
753
  rangeSetFunc(rangeSetWhiteSpace)(state => () => [empty, state]),
754
754
  rangeSetFunc(rangeSetNewLine)(state => () => [empty, { kind: 'nl' }])
755
755
  ])
756
756
 
757
- /** @type {(state: ParseNewLineState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
757
+ /** @type {(state: ParseNewLineState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
758
758
  const parseNewLineDefault = state => input => {
759
759
  const next = tokenizeOp({ kind: 'initial' })(input)
760
760
  return [{ first: { kind: 'nl' }, tail: next[0] }, next[1]]
761
761
  }
762
762
 
763
- /** @type {(state: ParseNewLineState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
763
+ /** @type {(state: ParseNewLineState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
764
764
  const parseNewLineStateOp = create(parseNewLineDefault)([
765
765
  rangeSetFunc(rangeSetWhiteSpace)(state => () => [empty, state]),
766
766
  rangeSetFunc(rangeSetNewLine)(state => () => [empty, state])
767
767
  ])
768
768
 
769
- /** @type {(state: EofState) => (input: number) => readonly[List.List<JsToken>, TokenizerState]} */
769
+ /** @type {(state: EofState) => (input: number) => readonly[list.List<JsToken>, TokenizerState]} */
770
770
  const eofStateOp = create(state => () => [[{ kind: 'error', message: 'eof' }], state])([])
771
771
 
772
- /** @type {Operator.StateScan<number, TokenizerState, List.List<JsToken>>} */
772
+ /** @type {operator.StateScan<number, TokenizerState, list.List<JsToken>>} */
773
773
  const tokenizeCharCodeOp = state => {
774
774
  switch (state.kind) {
775
775
  case 'initial': return initialStateOp(state)
@@ -787,7 +787,7 @@ const tokenizeCharCodeOp = state => {
787
787
  }
788
788
  }
789
789
 
790
- /** @type {(state: TokenizerState) => readonly[List.List<JsToken>, TokenizerState]} */
790
+ /** @type {(state: TokenizerState) => readonly[list.List<JsToken>, TokenizerState]} */
791
791
  const tokenizeEofOp = state => {
792
792
  switch (state.kind) {
793
793
  case 'initial': return [empty, { kind: 'eof' }]
@@ -812,19 +812,12 @@ const tokenizeEofOp = state => {
812
812
  }
813
813
  }
814
814
 
815
- /** @type {Operator.StateScan<CharCodeOrEof, TokenizerState, List.List<JsToken>>} */
815
+ /** @type {operator.StateScan<CharCodeOrEof, TokenizerState, list.List<JsToken>>} */
816
816
  const tokenizeOp = state => input => input === null ? tokenizeEofOp(state) : tokenizeCharCodeOp(state)(input)
817
817
 
818
818
  const scanTokenize = stateScan(tokenizeOp)
819
819
 
820
820
  const initial = scanTokenize({ kind: 'initial' })
821
821
 
822
- /** @type {(input: List.List<number>) => List.List<JsToken>} */
823
- const tokenize = input => flat(initial(flat([/** @type {List.List<CharCodeOrEof>} */(input), [null]])))
824
-
825
- export default {
826
- /** @readonly */
827
- tokenize,
828
- /** @readonly */
829
- isKeywordToken
830
- }
822
+ /** @type {(input: list.List<number>) => list.List<JsToken>} */
823
+ export const tokenize = input => flat(initial(flat([/** @type {list.List<CharCodeOrEof>} */(input), [null]])))
@@ -1,12 +1,12 @@
1
- import tokenizer, * as Tokenizer from './module.f.mjs'
2
- import list from '../../types/list/module.f.mjs'
1
+ import * as tokenizer from './module.f.mjs'
2
+ import * as list from '../../types/list/module.f.mjs'
3
3
  const { toArray } = list
4
- import djs from '../../djs/module.f.mjs'
5
- import o from '../../types/object/module.f.mjs'
4
+ import * as djs from '../../djs/module.f.mjs'
5
+ import * as o from '../../types/object/module.f.mjs'
6
6
  const { sort } = o
7
- import encoding from '../../text/utf16/module.f.mjs'
7
+ import * as encoding from '../../text/utf16/module.f.mjs'
8
8
 
9
- /** @type {(s: string) => readonly Tokenizer.JsToken[]} */
9
+ /** @type {(s: string) => readonly tokenizer.JsToken[]} */
10
10
  const tokenizeString = s => toArray(tokenizer.tokenize(encoding.stringToList(s)))
11
11
 
12
12
  const stringify = djs.stringify(sort)
@@ -1,17 +1,3 @@
1
- declare namespace _default {
2
- export { setProperty };
3
- export { stringify };
4
- export { serialize };
5
- export { parse };
6
- export { isObject };
7
- }
8
- export default _default;
9
- export type Object = { readonly [k in string]: Unknown; };
10
- export type Array = readonly Unknown[];
11
- export type Unknown = Object | boolean | string | number | null | Array;
12
- export type Entry = O.Entry<Unknown>;
13
- export type Entries = (List.List<Entry>);
14
- export type MapEntries = (entries: Entries) => Entries;
15
1
  /**
16
2
  * @typedef {{
17
3
  * readonly [k in string]: Unknown
@@ -19,23 +5,29 @@ export type MapEntries = (entries: Entries) => Entries;
19
5
  */
20
6
  /** @typedef {readonly Unknown[]} Array */
21
7
  /** @typedef {Object|boolean|string|number|null|Array} Unknown */
22
- /** @type {(value: Unknown) => (path: List.List<string>) => (src: Unknown) => Unknown} */
23
- declare const setProperty: (value: Unknown) => (path: List.List<string>) => (src: Unknown) => Unknown;
8
+ /** @type {(value: Unknown) => (path: list.List<string>) => (src: Unknown) => Unknown} */
9
+ export const setProperty: (value: Unknown) => (path: list.List<string>) => (src: Unknown) => Unknown;
10
+ /** @typedef {object.Entry<Unknown>} Entry*/
11
+ /** @typedef {(list.List<Entry>)} Entries */
12
+ /** @typedef {(entries: Entries) => Entries} MapEntries */
13
+ /** @type {(mapEntries: MapEntries) => (value: Unknown) => list.List<string>} */
14
+ export const serialize: (mapEntries: MapEntries) => (value: Unknown) => list.List<string>;
24
15
  /**
25
16
  * The standard `JSON.stringify` rules determined by
26
17
  * https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys
27
18
  *
28
19
  * @type {(mapEntries: MapEntries) => (value: Unknown) => string}
29
20
  */
30
- declare const stringify: (mapEntries: MapEntries) => (value: Unknown) => string;
31
- /** @typedef {O.Entry<Unknown>} Entry*/
32
- /** @typedef {(List.List<Entry>)} Entries */
33
- /** @typedef {(entries: Entries) => Entries} MapEntries */
34
- /** @type {(mapEntries: MapEntries) => (value: Unknown) => List.List<string>} */
35
- declare const serialize: (mapEntries: MapEntries) => (value: Unknown) => List.List<string>;
21
+ export const stringify: (mapEntries: MapEntries) => (value: Unknown) => string;
36
22
  /** @type {(value: string) => Unknown} */
37
- declare const parse: (value: string) => Unknown;
23
+ export const parse: (value: string) => Unknown;
38
24
  /** @type {(value: Unknown) => value is Object} */
39
- declare const isObject: (value: Unknown) => value is Object;
40
- import * as O from '../types/object/module.f.mjs';
41
- import * as List from '../types/list/module.f.mjs';
25
+ export const isObject: (value: Unknown) => value is Object;
26
+ export type Object = { readonly [k in string]: Unknown; };
27
+ export type Array = readonly Unknown[];
28
+ export type Unknown = Object | boolean | string | number | null | Array;
29
+ export type Entry = object.Entry<Unknown>;
30
+ export type Entries = (list.List<Entry>);
31
+ export type MapEntries = (entries: Entries) => Entries;
32
+ import * as list from '../types/list/module.f.mjs';
33
+ import * as object from '../types/object/module.f.mjs';
package/json/module.f.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  // @ts-self-types="./module.f.d.mts"
2
- import list, * as List from '../types/list/module.f.mjs'
2
+ import * as list from '../types/list/module.f.mjs'
3
3
  const { next, flat, map } = list
4
- import string from '../types/string/module.f.mjs'
4
+ import * as string from '../types/string/module.f.mjs'
5
5
  const { concat } = string
6
- import object, * as O from '../types/object/module.f.mjs'
6
+ import * as object from '../types/object/module.f.mjs'
7
7
  const { at } = object
8
- import f from '../types/function/module.f.mjs'
8
+ import * as f from '../types/function/module.f.mjs'
9
9
  const { compose, fn } = f
10
10
  const { entries } = Object
11
- import s from './serializer/module.f.mjs'
11
+ import * as s from './serializer/module.f.mjs'
12
12
  const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = s
13
13
 
14
14
  /**
@@ -21,9 +21,9 @@ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize,
21
21
 
22
22
  /** @typedef {Object|boolean|string|number|null|Array} Unknown */
23
23
 
24
- /** @type {(value: Unknown) => (path: List.List<string>) => (src: Unknown) => Unknown} */
25
- const setProperty = value => {
26
- /** @type {(path: List.List<string>) => (src: Unknown) => Unknown} */
24
+ /** @type {(value: Unknown) => (path: list.List<string>) => (src: Unknown) => Unknown} */
25
+ export const setProperty = value => {
26
+ /** @type {(path: list.List<string>) => (src: Unknown) => Unknown} */
27
27
  const f = path => src => {
28
28
  const result = next(path)
29
29
  if (result === null) { return value }
@@ -36,28 +36,28 @@ const setProperty = value => {
36
36
 
37
37
  const colon = [':']
38
38
 
39
- /** @typedef {O.Entry<Unknown>} Entry*/
39
+ /** @typedef {object.Entry<Unknown>} Entry*/
40
40
 
41
- /** @typedef {(List.List<Entry>)} Entries */
41
+ /** @typedef {(list.List<Entry>)} Entries */
42
42
 
43
43
  /** @typedef {(entries: Entries) => Entries} MapEntries */
44
44
 
45
- /** @type {(mapEntries: MapEntries) => (value: Unknown) => List.List<string>} */
46
- const serialize = sort => {
47
- /** @type {(kv: readonly[string, Unknown]) => List.List<string>} */
45
+ /** @type {(mapEntries: MapEntries) => (value: Unknown) => list.List<string>} */
46
+ export const serialize = sort => {
47
+ /** @type {(kv: readonly[string, Unknown]) => list.List<string>} */
48
48
  const propertySerialize = ([k, v]) => flat([
49
49
  stringSerialize(k),
50
50
  colon,
51
51
  f(v)
52
52
  ])
53
53
  const mapPropertySerialize = map(propertySerialize)
54
- /** @type {(object: Object) => List.List<string>} */
54
+ /** @type {(object: Object) => list.List<string>} */
55
55
  const objectSerialize = fn(entries)
56
56
  .then(sort)
57
57
  .then(mapPropertySerialize)
58
58
  .then(objectWrap)
59
59
  .result
60
- /** @type {(value: Unknown) => List.List<string>} */
60
+ /** @type {(value: Unknown) => list.List<string>} */
61
61
  const f = value => {
62
62
  switch (typeof value) {
63
63
  case 'boolean': { return boolSerialize(value) }
@@ -80,23 +80,10 @@ const serialize = sort => {
80
80
  *
81
81
  * @type {(mapEntries: MapEntries) => (value: Unknown) => string}
82
82
  */
83
- const stringify = sort => compose(serialize(sort))(concat)
83
+ export const stringify = sort => compose(serialize(sort))(concat)
84
84
 
85
85
  /** @type {(value: string) => Unknown} */
86
- const parse = JSON.parse
86
+ export const parse = JSON.parse
87
87
 
88
88
  /** @type {(value: Unknown) => value is Object} */
89
- const isObject = value => typeof value === 'object' && value !== null && !(value instanceof Array)
90
-
91
- export default {
92
- /** @readonly */
93
- setProperty,
94
- /** @readonly */
95
- stringify,
96
- /** @readonly */
97
- serialize,
98
- /** @readonly */
99
- parse,
100
- /** @readonly */
101
- isObject,
102
- }
89
+ export const isObject = value => typeof value === 'object' && value !== null && !(value instanceof Array)
@@ -1,18 +1,16 @@
1
- declare namespace _default {
2
- export { parse };
3
- }
4
- export default _default;
1
+ /** @type {(tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>} */
2
+ export const parse: (tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>;
5
3
  export type JsonObject = {
6
4
  readonly kind: "object";
7
- readonly values: Map.Map<Json.Unknown>;
5
+ readonly values: map.Map<Json.Unknown>;
8
6
  readonly key: string;
9
7
  };
10
8
  export type JsonArray = {
11
9
  readonly kind: "array";
12
- readonly values: List.List<Json.Unknown>;
10
+ readonly values: list.List<Json.Unknown>;
13
11
  };
14
12
  export type JsonStackElement = JsonObject | JsonArray;
15
- export type JsonStack = List.List<JsonStackElement>;
13
+ export type JsonStack = list.List<JsonStackElement>;
16
14
  export type StateParse = {
17
15
  readonly status: "" | "[" | "[v" | "[," | "{" | "{k" | "{:" | "{v" | "{,";
18
16
  readonly top: JsonStackElement | null;
@@ -27,10 +25,8 @@ export type StateError = {
27
25
  readonly message: string;
28
26
  };
29
27
  export type JsonState = StateParse | StateResult | StateError;
30
- /** @type {(tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>} */
31
- declare const parse: (tokenList: List.List<Tokenizer.JsonToken>) => Result.Result<Json.Unknown, string>;
32
- import * as Map from '../../types/map/module.f.mjs';
33
- import * as Json from '../module.f.mjs';
34
- import * as List from '../../types/list/module.f.mjs';
28
+ import * as list from '../../types/list/module.f.mjs';
35
29
  import * as Tokenizer from '../tokenizer/module.f.mjs';
36
- import * as Result from '../../types/result/module.f.mjs';
30
+ import * as result from '../../types/result/module.f.mjs';
31
+ import * as Json from '../module.f.mjs';
32
+ import * as map from '../../types/map/module.f.mjs';