functionalscript 0.0.566 → 0.0.567

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.
@@ -87,6 +87,6 @@ jobs:
87
87
  name: package-lock.json
88
88
  - uses: actions/setup-dotnet@v3
89
89
  with:
90
- dotnet-version: 8
90
+ dotnet-version: 9
91
91
  - run: npm ci
92
92
  - run: npm run comtest
@@ -16,7 +16,7 @@ jobs:
16
16
  fetch-depth: 0
17
17
  - uses: actions/setup-node@v2
18
18
  with:
19
- node-version: 19
19
+ node-version: 22
20
20
  registry-url: https://registry.npmjs.org/
21
21
  # - run: npm ci
22
22
  - run: npm run version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.566",
3
+ "version": "0.0.567",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
32
32
  "devDependencies": {
33
- "@types/node": "^22.9.0",
33
+ "@types/node": "^22.9.1",
34
34
  "typescript": "^5.6.3"
35
35
  }
36
36
  }
@@ -34,15 +34,28 @@ const fromCodePointList = flatMap(codePointToUtf8)
34
34
 
35
35
  /** @type {(state: Utf8NonEmptyState) => i32}*/
36
36
  const utf8StateToError = state => {
37
+ let x
37
38
  switch (state.length) {
38
- case 1:
39
- return state[0] | errorMask
40
- case 2:
41
- if (state[0] < 0b1111_0000) return (((state[0] & 0b0000_1111) << 6) + (state[1] & 0b0011_1111) + 0b0000_0100_0000_0000) | errorMask
42
- return (((state[0] & 0b0000_0111) << 6) + (state[1] & 0b0011_1111) + 0b0000_0010_0000_0000) | errorMask
43
- case 3:
44
- return (((state[0] & 0b0000_0111) << 12) + ((state[1] & 0b0011_1111) << 6) + (state[2] & 0b0011_1111) + 0b1000_0000_0000_0000) | errorMask
39
+ case 1: {
40
+ [x] = state
41
+ break
42
+ }
43
+ case 2: {
44
+ const [s0, s1] = state
45
+ x = s0 < 0b1111_0000
46
+ ? ((s0 & 0b0000_1111) << 6) + (s1 & 0b0011_1111) + 0b0000_0100_0000_0000
47
+ : ((s0 & 0b0000_0111) << 6) + (s1 & 0b0011_1111) + 0b0000_0010_0000_0000
48
+ break
49
+ }
50
+ case 3: {
51
+ const [s0, s1, s2] = state
52
+ x = ((s0 & 0b0000_0111) << 12) + ((s1 & 0b0011_1111) << 6) + (s2 & 0b0011_1111) + 0b1000_0000_0000_0000
53
+ break
54
+ }
55
+ default:
56
+ throw 'invalid state'
45
57
  }
58
+ return x | errorMask
46
59
  }
47
60
 
48
61
  /** @type {operator.StateScan<number, Utf8State, list.List<i32>>} */
@@ -57,16 +70,22 @@ const utf8ByteToCodePointOp = state => byte => {
57
70
  }
58
71
  if (byte >= 0b1000_0000 && byte < 0b1100_0000) {
59
72
  switch (state.length) {
60
- case 1:
61
- if (state[0] < 0b1110_0000) { return [[((state[0] & 0b0001_1111) << 6) + (byte & 0b0011_1111)], null] }
62
- if (state[0] < 0b1111_1000) { return [[], [state[0], byte]] }
73
+ case 1: {
74
+ const [s0] = state
75
+ if (s0 < 0b1110_0000) { return [[((s0 & 0b0001_1111) << 6) + (byte & 0b0011_1111)], null] }
76
+ if (s0 < 0b1111_1000) { return [[], [s0, byte]] }
63
77
  break
64
- case 2:
65
- if (state[0] < 0b1111_0000) { return [[((state[0] & 0b0000_1111) << 12) + ((state[1] & 0b0011_1111) << 6) + (byte & 0b0011_1111)], null] }
66
- if (state[0] < 0b1111_1000) { return [[], [state[0], state[1], byte]] }
78
+ }
79
+ case 2: {
80
+ const [s0, s1] = state
81
+ if (s0 < 0b1111_0000) { return [[((s0 & 0b0000_1111) << 12) + ((s1 & 0b0011_1111) << 6) + (byte & 0b0011_1111)], null] }
82
+ if (s0 < 0b1111_1000) { return [[], [s0, s1, byte]] }
67
83
  break
68
- case 3:
69
- return [[((state[0] & 0b0000_0111) << 18) + ((state[1] & 0b0011_1111) << 12) + ((state[2] & 0b0011_1111) << 6) + (byte & 0b0011_1111)], null]
84
+ }
85
+ case 3: {
86
+ const [s0, s1, s2] = state
87
+ return [[((s0 & 0b0000_0111) << 18) + ((s1 & 0b0011_1111) << 12) + ((s2 & 0b0011_1111) << 6) + (byte & 0b0011_1111)], null]
88
+ }
70
89
  }
71
90
  }
72
91
  const error = utf8StateToError(state)
@@ -76,10 +95,8 @@ const utf8ByteToCodePointOp = state => byte => {
76
95
  }
77
96
 
78
97
  /** @type {(state: Utf8State) => readonly[list.List<i32>, Utf8State]} */
79
- const utf8EofToCodePointOp = state => {
80
- if (state === null) { return [null, null] }
81
- return [[utf8StateToError(state)], null]
82
- }
98
+ const utf8EofToCodePointOp = state =>
99
+ [state === null ? null : [utf8StateToError(state)], null]
83
100
 
84
101
  /** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<i32>>} */
85
102
  const utf8ByteOrEofToCodePointOp = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
@@ -7,7 +7,7 @@ const { list } = require('../module.f.cjs')
7
7
  const operator = require("../function/operator/module.f.cjs")
8
8
 
9
9
  /** @type {(a: readonly json.Unknown[]) => string} */
10
- const stringify = a => json.stringify(sort)(a)
10
+ const stringify = json.stringify(sort)
11
11
 
12
12
  /** @type {_.Operators<sortedSet.SortedSet<string>>} */
13
13
  const op = { union: sortedSet.union(unsafeCmp), equal: list.equal(operator.strictEqual) }