functionalscript 0.0.384 → 0.0.387

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/doc/vm.md ADDED
@@ -0,0 +1,165 @@
1
+ # VM
2
+
3
+ [Tagged Pointer](https://en.wikipedia.org/wiki/Tagged_pointer).
4
+
5
+ ## Common (3 bit)
6
+
7
+ - `false`
8
+ - `true`
9
+ - `undefined`
10
+ - `""`
11
+ - `+infinity`
12
+ - `-infinity`
13
+ - `-0`
14
+ - `NaN`
15
+
16
+ ## 6-bit Id String
17
+
18
+ |symbol |code |# |sum|
19
+ |--------|--------------|--|---|
20
+ |`$` |`\x24` | 1| 1|
21
+ |`0`..`9`|`\x30`..`\x39`| A| B|
22
+ |`A`..`Z`|`\x41`..`\x5A`|1A| 25|
23
+ |`_` |`\x5F` | 1| 26|
24
+ |`a`..`z`|`\x61`..`\x7A`|1A| 40|
25
+
26
+ ## 64 bit platform
27
+
28
+ Alignment: 8 bytes.
29
+
30
+ Pointer: 2^64 / 2^3 = 2^61 bit
31
+
32
+ ### Value
33
+
34
+ - `63`: 9 x 7 bit string
35
+ - `63`:
36
+ - `61`: pointer + null, alignment - 8 bytes
37
+ - `61`:
38
+ - `60`: 4 x 15 bit string
39
+ - `60`: 10 x 6 bit string
40
+ - `61`:
41
+ - `60`: 6 x 10 bit string
42
+ - `60`: 5 x 12 bit string
43
+ - `61`
44
+ - `60`: float60
45
+ - `60`:
46
+ - `59`: bigInt59 (-576_460_752_303_423_488..576_460_752_303_423_487)
47
+ - `59`:
48
+ - `56`: 8 x 7-bit string
49
+ - `56`: 7 x 8-bit string
50
+ - `53`: int53
51
+ - `53`: stringUInt53
52
+ - `48`: 3 x 16 bit string
53
+ - `32`: 2 x 16 bit string
54
+ - `16`: 1 x UTF16 string
55
+ - `3`: common
56
+
57
+ ## Float64
58
+
59
+ https://en.wikipedia.org/wiki/Double-precision_floating-point_format
60
+
61
+ - 1 bit - sign (S)
62
+ - 11 bit - exponent (E)
63
+ - 52 bit - fraction (F)
64
+
65
+ |E |Description |
66
+ |-------------|------------------------|
67
+ |000_0000_0000|F = 0: signed zeros |
68
+ | |F != 0: subnormals |
69
+ |000_0000_0001|E = 2^-1022 |
70
+ |... | |
71
+ |011_1111_1111|E = 2^0 |
72
+ |100_0000_0000|E = 2^1 |
73
+ |... | |
74
+ |111_1111_1110|E = 2^1023 |
75
+ |111_1111_1111|F = 0: signed infinities|
76
+ | |F != 0: NaN |
77
+
78
+ ## Float60
79
+
80
+ - 1 bit - sign
81
+ - 7 bit - exponent
82
+ - 52 bit - fraction
83
+
84
+ |E |Description|
85
+ |--------|-----------|
86
+ |000_0000|E = 2^-63 |
87
+ |... | |
88
+ |011_1111|E = 2^0 |
89
+ |100_0000|E = 2^1 |
90
+ |... | |
91
+ |111_1111|E = 2^64 |
92
+
93
+ Note: the type has no `+0`, `-0`, `+inf`, `-inf`, `NaN`.
94
+
95
+ ## Object Structure
96
+
97
+ Value Size = 8
98
+ Counter size = max_memory_size / value_size.
99
+
100
+ ### Type
101
+
102
+ - `000`: double
103
+ - `001`: string
104
+ - `010`: array
105
+ - `011`: object
106
+ - `100`: bigInt
107
+ - `101`: function
108
+ - `110`:
109
+ - `111`:
110
+
111
+ ### Type & Counter
112
+
113
+ - AtomicUSize:
114
+ - `3`: type
115
+ - `...`: counter
116
+
117
+ ### String
118
+
119
+ ```rust
120
+ struct String {
121
+ length: u32,
122
+ array: [u16; self.length],
123
+ }
124
+ ```
125
+
126
+ ### Function
127
+
128
+ ```rust
129
+ struct Function<length: u32> {
130
+ func: pointer,
131
+ array: [value; length]
132
+ }
133
+ ```
134
+
135
+ ### BigInt
136
+
137
+ ```rust
138
+ struct BigInt {
139
+ length: u32,
140
+ array: [u64; self.length],
141
+ }
142
+ ```
143
+
144
+ ### Array
145
+
146
+ ```rust
147
+ struct Array {
148
+ length: u32,
149
+ array: [Value; self.length],
150
+ }
151
+ ```
152
+
153
+ ### Object
154
+
155
+ ```rust
156
+ struct Object {
157
+ length: u32,
158
+ array: [(Value, Value), self.length],
159
+ indexArray: [u32, (self.length * log2(self.length) + 31) / u32],
160
+ }
161
+ ```
162
+
163
+ Note: see https://262.ecma-international.org/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys and https://262.ecma-international.org/6.0/#sec-object-type
164
+
165
+ An integer index for Node.js, Deno and Bun means a value from `0` to `4294967294` including. 4_294_967_294 = 0xFFFF_FFFE. But an integer index in the ES6 standard is +0..2^53-1.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.384",
3
+ "version": "0.0.387",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -4,34 +4,14 @@
4
4
 
5
5
  Requirement: no loss for UTF8 => codepoint => UTF8
6
6
 
7
- |utf8 |codepoint |size |
8
- |---------|---------------------------------------|---------|
9
- |[a] |0xxx_xxxx |7 bit |
10
- |[b,a] |110x_xxxx 10xx_xxxx |11 bit |
11
- |[c,b,a] |1110_xxxx 10xx_xxxx 10xx_xxxx |16 bit |
12
- |[d,c,b,a]|1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx|21 bit |
13
-
14
- |utf8 error|codepoint |size |
15
- |----------|-----------------------------|------|
16
- |[e] |10xx_xxxx |6 bit |
17
- |[e] |1111_1xxx |3 bit |
18
- |[b,] |110x_xxxx |5 bit |
19
- |[c,] |1110_xxxx |4 bit |
20
- |[c,b,] |1110_xxxx 10xx_xxxx |10 bit|
21
- |[d,] |1111_0xxx |3 bit |
22
- |[d,c,] |1111_0xxx 10xx_xxxx |9 bit |
23
- |[d,c,b,] |1111_0xxx 10xx_xxxx 10xx_xxxx|15 bit|
24
-
25
- Total error states:
26
-
27
- - 2^6 + 2^3 + 2^5 + 2^4 + 2^10 + 2^3 + + 2^9 + 2^15
28
- - 2^4 + 2^6 + 2^5 + 2^4 + 2^10 + 2^9 + 2^15
29
- - 2^5 + 2^6 + 2^5 + 2^10 + 2^9 + 2^15
30
- - 2^6 + 2^6 + 2^10 + 2^9 + 2^15
31
- - 2^7 + 2^9 + 2^10 + 2^15
32
- - < 2^16
33
-
34
- |utf8 error|codepoint |size |map |
7
+ |utf8 |utf8 code |size |codepoint |
8
+ |---------|---------------------------------------|---------|--------------------------------------------------|
9
+ |[a] |0xxx_xxxx |7 bit |0_0000_0000_0000_0xxx_xxxx |
10
+ |[b,a] |110x_xxxx 10xx_xxxx |11 bit |0_0000_0000_0xxx_xxxx_xxxx + 0_0000_0000_1000_0000|
11
+ |[c,b,a] |1110_xxxx 10xx_xxxx 10xx_xxxx |16 bit |0_0000_xxxx_xxxx_xxxx_xxxx + 0_0000_1000_0000_0000|
12
+ |[d,c,b,a]|1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx|21 bit |x_xxxx_xxxx_xxxx_xxxx_xxxx + 1_0000_0000_0000_0000|
13
+
14
+ |utf8 error|utf8 code |size |codepoint |
35
15
  |----------|-----------------------------|------|-------------------|
36
16
  |[e] |1111_1xxx | 3 bit| |
37
17
  |[d,] |1111_0xxx | 3 bit| |
@@ -42,6 +22,18 @@ Total error states:
42
22
  |[c,b,] |1110_xxxx 10xx_xxxx |10 bit|0000_01xx xxxx_xxxx|
43
23
  |[d,c,b,] |1111_0xxx 10xx_xxxx 10xx_xxxx|15 bit|1xxx_xxxx xxxx_xxxx|
44
24
 
25
+ Total error states:
26
+
27
+ - 2^6 + 2^3 + 2^5 + 2^4 + 2^10 + 2^3 + + 2^9 + 2^15
28
+ - 2^4 + 2^6 + 2^5 + 2^4 + 2^10 + 2^9 + 2^15
29
+ - 2^5 + 2^6 + 2^5 + 2^10 + 2^9 + 2^15
30
+ - 2^6 + 2^6 + 2^10 + 2^9 + 2^15
31
+ - 2^7 + 2^9 + 2^10 + 2^15
32
+ - 0b1000_0110_1000_000
33
+ - 128 + 512 + 1024 + 32_768
34
+ - 34_432
35
+ - < 2^16
36
+
45
37
  ```js
46
38
  /** @type {(input: List<u8|undefined>) => List<i32>} */
47
39
  const utf8ToCodePoint
@@ -63,15 +55,15 @@ Requirement: no loss for UTF16 => codepoint => UTF16
63
55
  - first : 0xD800: 0b_1101_10xx_xxxx_xxxx : 10 bit
64
56
  - second: 0xDC00: 0b_1101_11xx_xxxx_xxxx : 10 bit
65
57
 
66
- |utf16 |codepoint |size |
67
- |---------|---------------------------------------|------|
68
- |[a] |xxxx_xxxx_xxxx_xxxx |16 bit|
69
- |[b,a] |1101_10xx_xxxx_xxxx 1101_11xx_xxxx_xxxx|20 bit|
58
+ |utf16 |utf16 code |size |codepoint |
59
+ |---------|---------------------------------------|------|------------------------------------------------|
60
+ |[a] |xxxx_xxxx_xxxx_xxxx |16 bit|0000_xxxx_xxxx_xxxx_xxxx |
61
+ |[b,a] |1101_10xx_xxxx_xxxx 1101_11xx_xxxx_xxxx|20 bit|xxxx_xxxx_xxxx_xxxx_xxxx + 1_0000_0000_0000_0000|
70
62
 
71
- |utf16 error|codepoint |size |
72
- |-----------|-------------------|------|
73
- |[e] |1101_11xx_xxxx_xxxx|10 bit|
74
- |[b,] |1101_10xx_xxxx_xxxx|10 bit|
63
+ |utf16 error|utf16 code |size |codepoint |
64
+ |-----------|-------------------|------|-------------------|
65
+ |[e] |1101_11xx_xxxx_xxxx|10 bit|1101_11xx_xxxx_xxxx|
66
+ |[b,] |1101_10xx_xxxx_xxxx|10 bit|1101_10xx_xxxx_xxxx|
75
67
 
76
68
  Total error states: 11 bit
77
69
 
@@ -82,7 +74,7 @@ const utf16ListToCodePointList
82
74
  /** @type {(input: List<i32>) => List<u16>} */
83
75
  const codePointListToUtf16List
84
76
 
85
- /** @type {(input: string) => List<u16> */
77
+ /** @type {(input: string) => List<u16>} */
86
78
  const stringToUtf16List
87
79
 
88
80
  /** @type {(input: List<u16>) => string} */
@@ -93,22 +85,22 @@ UTF-16 => CP => UTF-8 => CP = UTF-16
93
85
 
94
86
  ## Example
95
87
 
96
- - UTF-16:
97
- - 1101_11xx_xxxx_xxxx
88
+ - UTF-16:
98
89
  - 1101_11xx_xxxx_xxxx
99
- - CP:
100
- - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
90
+ - 1101_11xx_xxxx_xxxx
91
+ - CP:
92
+ - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
101
93
  - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
102
94
  - UTF-8:
103
- - 1111_0.101
104
- - 10.11_xxxx
95
+ - 1111_0.101
96
+ - 10.11_xxxx
97
+ - 10xx_xxxx
98
+ - 1111_0.101
99
+ - 10.11_xxxx
105
100
  - 10xx_xxxx
106
- - 1111_0.101
107
- - 10.11_xxxx
108
- - 10xx_xxxx
109
101
  - CP:
110
- - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
111
102
  - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
112
- - UTF-16:
113
- - 1101_11xx_xxxx_xxxx
103
+ - 1000_0000_0000_0000_1101_11xx_xxxx_xxxx
104
+ - UTF-16:
105
+ - 1101_11xx_xxxx_xxxx
114
106
  - 1101_11xx_xxxx_xxxx
@@ -11,9 +11,15 @@ const { ok, error } = result
11
11
 
12
12
  /** @typedef {number|undefined} ByteOrEof */
13
13
 
14
+ /** @typedef {u16|undefined} WordOrEof */
15
+
14
16
  /** @typedef {undefined|array.Array1<number>|array.Array2<number>|array.Array3<number>} Utf8State */
15
17
 
16
- /** @typedef {undefined|array.Array1<number>|array.Array2<number>|array.Array3<number>} Utf16State */
18
+ /** @typedef {undefined|number} Utf16State */
19
+
20
+ /** @typedef {number} u16 */
21
+
22
+ /** @typedef {number} i32 */
17
23
 
18
24
  /** @type {(a:number) => boolean} */
19
25
  const isBmpCodePoint = a => a >= 0x0000 && a <= 0xd7ff || a >= 0xe000 && a <= 0xffff
@@ -23,6 +29,8 @@ const isHighSurrogate = contains([0xd800, 0xdbff])
23
29
  /** @type {(a:number) => boolean} */
24
30
  const isLowSurrogate = contains([0xdc00, 0xdfff])
25
31
 
32
+ const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000
33
+
26
34
  /** @type {(input:number) => list.List<ByteResult>} */
27
35
  const codePointToUtf8 = input =>
28
36
  {
@@ -33,29 +41,29 @@ const codePointToUtf8 = input =>
33
41
  return [error(input)]
34
42
  }
35
43
 
36
- /** @type {(input:number) => list.List<ByteResult>} */
44
+ /** @type {(input:i32) => list.List<u16>} */
37
45
  const codePointToUtf16 = input =>
38
46
  {
39
- if (isBmpCodePoint(input)) { return [ok(input >> 8), ok(input & 0xff)] }
47
+ if (isBmpCodePoint(input)) { return [input] }
40
48
  if (input >= 0x010000 && input <= 0x10ffff) {
41
49
  const high = ((input - 0x10000) >> 10) + 0xd800
42
- const low = ((input - 0x10000) & 0x3ff) + 0xdc00
43
- return [ok(high >> 8), ok(high & 0xff), ok(low >> 8), ok(low & 0xff)]
50
+ const low = ((input - 0x10000) & 0b0011_1111_1111) + 0xdc00
51
+ return [high, low]
44
52
  }
45
- return [error(input)]
53
+ return [input & 0xffff]
46
54
  }
47
55
 
48
56
  /** @type {(input: list.List<number>) => list.List<ByteResult>} */
49
- const codePointListToUtf8 = list.flatMap(codePointToUtf8)
57
+ const codePointListToUtf8List = list.flatMap(codePointToUtf8)
50
58
 
51
- /** @type {(input: list.List<number>) => list.List<ByteResult>} */
52
- const codePointListToUtf16 = list.flatMap(codePointToUtf16)
59
+ /** @type {(input: list.List<i32>) => list.List<u16>} */
60
+ const codePointListToUtf16List = list.flatMap(codePointToUtf16)
53
61
 
54
62
  /** @type {operator.StateScan<number, Utf8State, list.List<CodePointResult>>} */
55
63
  const utf8ByteToCodePointOp = state => byte => {
56
64
  if (byte < 0x00 || byte > 0xff) {
57
65
  return [[error([byte])], state]
58
- }
66
+ }
59
67
  if (state == undefined) {
60
68
  if (byte < 0x80) { return [[ok(byte)], undefined] }
61
69
  if (byte >= 0xc2 && byte <= 0xf4) { return [[], [byte]] }
@@ -68,71 +76,63 @@ const utf8ByteToCodePointOp = state => byte => {
68
76
  case 1:
69
77
  if (state[0] < 0xe0) { return [[ok(((state[0] & 0x1f) << 6) + (byte & 0x3f))], undefined] }
70
78
  if (state[0] < 0xf8) { return [[], [state[0], byte]] }
71
- break
79
+ break
72
80
  case 2:
73
81
  if (state[0] < 0xf0) { return [[ok(((state[0] & 0x0f) << 12) + ((state[1] & 0x3f) << 6) + (byte & 0x3f))], undefined] }
74
82
  if (state[0] < 0xf8) { return [[], [state[0], state[1], byte]] }
75
83
  break
76
- case 3:
84
+ case 3:
77
85
  return [[ok(((state[0] & 0x07) << 18) + ((state[1] & 0x3f) << 12) + ((state[2] & 0x3f) << 6) + (byte & 0x3f))], undefined]
78
86
  }
79
- }
87
+ }
80
88
  return [[error(list.toArray(list.concat(state)([byte])))], undefined]
81
89
  }
82
90
 
83
91
  /** @type {(state: Utf8State) => readonly[list.List<CodePointResult>, Utf8State]} */
84
- const utf8EofToCodePointOp = state => [state == undefined ? undefined : [error(state)], undefined]
92
+ const utf8EofToCodePointOp = state => [state === undefined ? undefined : [error(state)], undefined]
85
93
 
86
94
  /** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<CodePointResult>>} */
87
95
  const utf8ByteOrEofToCodePointOp = state => input => input === undefined ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input)
88
96
 
89
97
  /** @type {(input: list.List<number>) => list.List<CodePointResult>} */
90
- const utf8ListToCodePoint = input => list.flat(list.stateScan(utf8ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<ByteOrEof>} */(input))([undefined])))
98
+ const utf8ListToCodePointList = input => list.flat(list.stateScan(utf8ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<ByteOrEof>} */(input))([undefined])))
91
99
 
92
- /** @type {operator.StateScan<number, Utf16State, list.List<CodePointResult>>} */
100
+ /** @type {operator.StateScan<u16, Utf16State, list.List<i32>>} */
93
101
  const utf16ByteToCodePointOp = state => byte => {
94
- if (byte < 0x00 || byte > 0xff) {
95
- return [[error([byte])], state]
102
+ if (byte < 0x00 || byte > 0xffff) {
103
+ return [[0xffffffff], state]
96
104
  }
97
- if (state == undefined) {
98
- return [[], [byte]]
105
+ if (state === undefined) {
106
+ if (isBmpCodePoint(byte)) { return [[byte], undefined] }
107
+ if (isHighSurrogate(byte)) { return [[], byte] }
108
+ return [[byte | errorMask], undefined]
99
109
  }
100
- switch(state.length)
101
- {
102
- case 1:
103
- const codeUnit = (state[0] << 8) + byte
104
- if (isBmpCodePoint(codeUnit)) { return [[ok(codeUnit)], undefined] }
105
- if (isHighSurrogate(codeUnit)) { return [[], [state[0], byte]] }
106
- break
107
- case 2:
108
- return [[], [state[0], state[1], byte]]
109
- case 3:
110
- if (isLowSurrogate((state[2] << 8) + byte)) {
111
- const high = (state[0] << 8) + state[1] - 0xd800
112
- const low = (state[2] << 8) + byte - 0xdc00
113
- return [[ok((high << 10) + low + 0x10000)], undefined]
114
- }
115
- break
110
+ if (isLowSurrogate(byte)) {
111
+ const high = state - 0xd800
112
+ const low = byte - 0xdc00
113
+ return [[(high << 10) + low + 0x10000], undefined]
116
114
  }
117
- return [[error(list.toArray(list.concat(state)([byte])))], undefined]
115
+ if (isBmpCodePoint(byte)) { return [[state | errorMask, byte], undefined] }
116
+ if (isHighSurrogate(byte)) { return [[state | errorMask], byte] }
117
+ return [[state | errorMask, byte | errorMask], undefined]
118
118
  }
119
119
 
120
- /** @type {(state: Utf8State) => readonly[list.List<CodePointResult>, Utf16State]} */
121
- const utf16EofToCodePointOp = state => [state == undefined ? undefined : [error(state)], undefined]
120
+ /** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
121
+ const utf16EofToCodePointOp = state => [state === undefined ? undefined : [state | errorMask], undefined]
122
122
 
123
- /** @type {operator.StateScan<ByteOrEof, Utf8State, list.List<CodePointResult>>} */
123
+ /** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
124
124
  const utf16ByteOrEofToCodePointOp = state => input => input === undefined ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
125
125
 
126
- /** @type {(input: list.List<number>) => list.List<CodePointResult>} */
127
- const utf16ListToCodePoint = input => list.flat(list.stateScan(utf16ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<ByteOrEof>} */(input))([undefined])))
126
+ /** @type {(input: list.List<u16>) => list.List<i32>} */
127
+ const utf16ListToCodePointList = input => list.flat(list.stateScan(utf16ByteOrEofToCodePointOp)(undefined)(list.concat(/** @type {list.List<WordOrEof>} */(input))([undefined])))
128
128
 
129
129
  module.exports = {
130
130
  /** @readonly */
131
- codePointListToUtf8,
131
+ codePointListToUtf8List,
132
132
  /** @readonly */
133
- codePointListToUtf16,
133
+ codePointListToUtf16List,
134
134
  /** @readonly */
135
- utf8ListToCodePoint,
135
+ utf8ListToCodePointList,
136
136
  /** @readonly */
137
- utf16ListToCodePoint
137
+ utf16ListToCodePointList
138
138
  }
@@ -7,193 +7,203 @@ const { list } = require('../../types/module.f.cjs')
7
7
  const stringify = a => json.stringify(sort)(a)
8
8
 
9
9
  {
10
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0,1,0x7F])))
10
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0,1,0x7F])))
11
11
  if (result !== '[["ok",0],["ok",1],["ok",127]]') { throw result }
12
12
  }
13
13
 
14
14
  {
15
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x80])))
15
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x80])))
16
16
  if (result !== '[["ok",194],["ok",128]]') { throw result }
17
17
  }
18
18
 
19
19
  {
20
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0xa9])))
20
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0xa9])))
21
21
  if (result !== '[["ok",194],["ok",169]]') { throw result }
22
22
  }
23
23
 
24
24
  {
25
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x7ff])))
25
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x7ff])))
26
26
  if (result !== '[["ok",223],["ok",191]]') { throw result }
27
27
  }
28
28
 
29
29
  {
30
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x800])))
30
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x800])))
31
31
  if (result !== '[["ok",224],["ok",160],["ok",128]]') { throw result }
32
32
  }
33
33
 
34
34
  {
35
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x801])))
35
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x801])))
36
36
  if (result !== '[["ok",224],["ok",160],["ok",129]]') { throw result }
37
37
  }
38
38
 
39
39
  {
40
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0xffff])))
40
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0xffff])))
41
41
  if (result !== '[["ok",239],["ok",191],["ok",191]]') { throw result }
42
42
  }
43
43
 
44
44
  {
45
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10000])))
45
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10000])))
46
46
  if (result !== '[["ok",240],["ok",144],["ok",128],["ok",128]]') { throw result }
47
47
  }
48
48
 
49
49
  {
50
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10001])))
50
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10001])))
51
51
  if (result !== '[["ok",240],["ok",144],["ok",128],["ok",129]]') { throw result }
52
52
  }
53
53
 
54
54
  {
55
- const result = stringify(list.toArray(encoding.codePointListToUtf8([0x10FFFF])))
55
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([0x10FFFF])))
56
56
  if (result !== '[["ok",244],["ok",143],["ok",191],["ok",191]]') { throw result }
57
57
  }
58
58
 
59
59
  {
60
- const result = stringify(list.toArray(encoding.codePointListToUtf8([-1,0x110000])))
60
+ const result = stringify(list.toArray(encoding.codePointListToUtf8List([-1,0x110000])))
61
61
  if (result !== '[["error",-1],["error",1114112]]') { throw result }
62
62
  }
63
63
 
64
64
  {
65
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0])))
66
- if (result !== '[["ok",0],["ok",0]]') { throw result }
65
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0])))
66
+ if (result !== '[0]') { throw result }
67
67
  }
68
68
 
69
69
  {
70
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x24])))
71
- if (result !== '[["ok",0],["ok",36]]') { throw result }
70
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x24])))
71
+ if (result !== '[36]') { throw result }
72
72
  }
73
73
 
74
74
  {
75
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x20AC])))
76
- if (result !== '[["ok",32],["ok",172]]') { throw result }
75
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x20AC])))
76
+ if (result !== '[8364]') { throw result }
77
77
  }
78
78
 
79
79
  {
80
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0xd7ff])))
81
- if (result !== '[["ok",215],["ok",255]]') { throw result }
80
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xd7ff])))
81
+ if (result !== '[55295]') { throw result }
82
82
  }
83
83
 
84
84
  {
85
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0xe000])))
86
- if (result !== '[["ok",224],["ok",0]]') { throw result }
85
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xe000])))
86
+ if (result !== '[57344]') { throw result }
87
87
  }
88
88
 
89
89
  {
90
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0xffff])))
91
- if (result !== '[["ok",255],["ok",255]]') { throw result }
90
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0xffff])))
91
+ if (result !== '[65535]') { throw result }
92
92
  }
93
93
 
94
94
  {
95
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10000])))
96
- if (result !== '[["ok",216],["ok",0],["ok",220],["ok",0]]') { throw result }
95
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10000])))
96
+ if (result !== '[55296,56320]') { throw result }
97
97
  }
98
98
 
99
99
  {
100
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10437])))
101
- if (result !== '[["ok",216],["ok",1],["ok",220],["ok",55]]') { throw result }
100
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10437])))
101
+ if (result !== '[55297,56375]') { throw result }
102
102
  }
103
103
 
104
104
  {
105
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x24B62])))
106
- if (result !== '[["ok",216],["ok",82],["ok",223],["ok",98]]') { throw result }
105
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x24B62])))
106
+ if (result !== '[55378,57186]') { throw result }
107
107
  }
108
108
 
109
109
  {
110
- const result = stringify(list.toArray(encoding.codePointListToUtf16([0x10ffff])))
111
- if (result !== '[["ok",219],["ok",255],["ok",223],["ok",255]]') { throw result }
110
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([0x10ffff])))
111
+ if (result !== '[56319,57343]') { throw result }
112
112
  }
113
113
 
114
114
  {
115
- const result = stringify(list.toArray(encoding.codePointListToUtf16([-1, 0xd800, 0xdfff, 0x110000])))
116
- if (result !== '[["error",-1],["error",55296],["error",57343],["error",1114112]]') { throw result }
115
+ const result = stringify(list.toArray(encoding.codePointListToUtf16List([-1, 0xd800, 0xdfff, 0x110000])))
116
+ if (result !== '[65535,55296,57343,0]') { throw result }
117
117
  }
118
118
 
119
- {
120
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([-1, 256])))
119
+ {
120
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([-1, 256])))
121
121
  if (result !== '[["error",[-1]],["error",[256]]]') { throw result }
122
122
  }
123
123
 
124
- {
125
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([128, 193, 245, 255])))
124
+ {
125
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([128, 193, 245, 255])))
126
126
  if (result !== '[["error",[128]],["error",[193]],["error",[245]],["error",[255]]]') { throw result }
127
127
  }
128
128
 
129
- {
130
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([0, 1, 127])))
129
+ {
130
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([0, 1, 127])))
131
131
  if (result !== '[["ok",0],["ok",1],["ok",127]]') { throw result }
132
132
  }
133
133
 
134
134
  {
135
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([194, 128, 194, 169, 223, 191])))
135
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, 128, 194, 169, 223, 191])))
136
136
  if (result !== '[["ok",128],["ok",169],["ok",2047]]') { throw result }
137
137
  }
138
138
 
139
- {
140
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([194, 127, 194, 192, 194])))
139
+ {
140
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, 127, 194, 192, 194])))
141
141
  if (result !== '[["error",[194,127]],["error",[194,192]],["error",[194]]]') { throw result }
142
142
  }
143
143
 
144
144
  {
145
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([224, 160, 128, 224, 160, 129, 239, 191, 191])))
145
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([224, 160, 128, 224, 160, 129, 239, 191, 191])))
146
146
  if (result !== '[["ok",2048],["ok",2049],["ok",65535]]') { throw result }
147
147
  }
148
148
 
149
- {
150
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([224, 160, 127, 224, 160, 192, 224, 160])))
149
+ {
150
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([224, 160, 127, 224, 160, 192, 224, 160])))
151
151
  if (result !== '[["error",[224,160,127]],["error",[224,160,192]],["error",[224,160]]]') { throw result }
152
152
  }
153
153
 
154
154
  {
155
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([240, 144, 128, 128, 240, 144, 128, 129, 244, 143, 191, 191])))
155
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([240, 144, 128, 128, 240, 144, 128, 129, 244, 143, 191, 191])))
156
156
  if (result !== '[["ok",65536],["ok",65537],["ok",1114111]]') { throw result }
157
157
  }
158
158
 
159
- {
160
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([240, 144, 128, 127, 240, 144, 128, 192, 240, 144, 128])))
159
+ {
160
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([240, 144, 128, 127, 240, 144, 128, 192, 240, 144, 128])))
161
161
  if (result !== '[["error",[240,144,128,127]],["error",[240,144,128,192]],["error",[240,144,128]]]') { throw result }
162
162
  }
163
163
 
164
164
  {
165
- const result = stringify(list.toArray(encoding.utf8ListToCodePoint([194, -1, 128])))
165
+ const result = stringify(list.toArray(encoding.utf8ListToCodePointList([194, -1, 128])))
166
166
  if (result !== '[["error",[-1]],["ok",128]]') { throw result }
167
167
  }
168
168
 
169
- {
170
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([-1, 256,])))
171
- if (result !== '[["error",[-1]],["error",[256]]]') { throw result }
169
+ {
170
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([-1, 65536])))
171
+ if (result !== '[4294967295,4294967295]') { throw result }
172
+ }
173
+
174
+ {
175
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([0, 36, 8364, 55295, 57344, 65535])))
176
+ if (result !== '[0,36,8364,55295,57344,65535]') { throw result }
177
+ }
178
+
179
+ {
180
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320, 57343])))
181
+ if (result !== '[-2147427328,-2147426305]') { throw result }
172
182
  }
173
183
 
174
184
  {
175
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([0, 0, 0, 36, 32, 172, 215, 255, 224, 0, 255, 255])))
176
- if (result !== '[["ok",0],["ok",36],["ok",8364],["ok",55295],["ok",57344],["ok",65535]]') { throw result }
185
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])))
186
+ if (result !== '[65536,66615,150370,1114111]') { throw result }
177
187
  }
178
188
 
179
189
  {
180
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([220, 0, 223, 255])))
181
- if (result !== '[["error",[220,0]],["error",[223,255]]]') { throw result }
190
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 55296])))
191
+ if (result !== '[-2147428352,-2147428352]') { throw result }
182
192
  }
183
193
 
184
194
  {
185
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([216, 0, 220, 0, 216, 1, 220, 55, 216, 82, 223, 98, 219, 255, 223, 255])))
186
- if (result !== '[["ok",65536],["ok",66615],["ok",150370],["ok",1114111]]') { throw result }
195
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([55296, 0])))
196
+ if (result !== '[-2147428352,0]') { throw result }
187
197
  }
188
198
 
189
199
  {
190
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([216, 0, 216, 0])))
191
- if (result !== '[["error",[216,0,216,0]]]') { throw result }
200
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320])))
201
+ if (result !== '[-2147427328]') { throw result }
192
202
  }
193
203
 
194
204
  {
195
- const result = stringify(list.toArray(encoding.utf16ListToCodePoint([216, 0, 0, 0])))
196
- if (result !== '[["error",[216,0,0,0]]]') { throw result }
205
+ const result = stringify(list.toArray(encoding.utf16ListToCodePointList([56320, 0])))
206
+ if (result !== '[-2147427328,0]') { throw result }
197
207
  }
198
208
 
199
209
  module.exports = {}