functionalscript 0.0.385 → 0.0.388

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 CHANGED
@@ -1,60 +1,58 @@
1
1
  # VM
2
2
 
3
- ## Tagged Pointers
3
+ [Tagged Pointer](https://en.wikipedia.org/wiki/Tagged_pointer).
4
4
 
5
- https://en.wikipedia.org/wiki/Tagged_pointer
6
-
7
- ### Common (3 bit)
5
+ ## Common (3 bit)
8
6
 
9
7
  - `false`
10
8
  - `true`
11
9
  - `undefined`
12
10
  - `""`
13
- - `-infinity`
14
11
  - `+infinity`
12
+ - `-infinity`
15
13
  - `-0`
16
14
  - `NaN`
17
15
 
18
- ### 32 bit platform
19
-
20
- - `31` bigInt31 (-1_073_741_824..1_073_741_823)
21
- - `31`:
22
- - `30`: pointer + null, alignment - 4 bytes.
23
- - `30`:
24
- - `29`:
25
- - `28`: 4 x 7 bit string
26
- - `28`: 2 x 14 bit string
27
- - `29`:
28
- - `28`: int28 (-134_217_728..134_217_727)
29
- - `28`:
30
- - `27`: 3 x 9 bit string
31
- - `20`: a UTF-16 surrogate pair
32
- - `16`: 1 x 16 bit string
33
- - `3`: common
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
+ ## Value
27
+
28
+ Alignment: 8 bytes.
34
29
 
35
- ### 64 bit platform
30
+ Pointer: 2^64 / 2^3 = 2^61 bit
36
31
 
37
32
  - `63`: 9 x 7 bit string
38
33
  - `63`:
39
- - `62`:
40
- - `61`: pointer + null, alignment - 8 bytes
41
- - `61`: float61
42
- - `62`:
34
+ - `61`: pointer + null, alignment - 8 bytes
35
+ - `61`:
36
+ - `60`: 4 x 15 bit string
37
+ - `60`: 10 x 6 bit string
38
+ - `61`:
43
39
  - `60`: 6 x 10 bit string
44
40
  - `60`: 5 x 12 bit string
45
- - `60`: 4 x 15 bit string
41
+ - `61`
42
+ - `60`: float60
46
43
  - `60`:
47
44
  - `59`: bigInt59 (-576_460_752_303_423_488..576_460_752_303_423_487)
48
45
  - `59`:
49
46
  - `56`: 8 x 7-bit string
50
47
  - `56`: 7 x 8-bit string
48
+ - `53`: int53
49
+ - `53`: stringUInt53
51
50
  - `48`: 3 x 16 bit string
52
51
  - `32`: 2 x 16 bit string
53
- - `32`: int32
54
52
  - `16`: 1 x UTF16 string
55
53
  - `3`: common
56
54
 
57
- ### Float64
55
+ ## Float64
58
56
 
59
57
  https://en.wikipedia.org/wiki/Double-precision_floating-point_format
60
58
 
@@ -75,62 +73,91 @@ https://en.wikipedia.org/wiki/Double-precision_floating-point_format
75
73
  |111_1111_1111|F = 0: signed infinities|
76
74
  | |F != 0: NaN |
77
75
 
78
- ### Float61
76
+ ## Float60
79
77
 
80
78
  - 1 bit - sign
81
- - 8 bit - exponent
79
+ - 7 bit - exponent
82
80
  - 52 bit - fraction
83
81
 
84
- |E |Description|
85
- |---------|-----------|
86
- |0000_0000|E = 2^-127 |
87
- |... | |
88
- |0111_1111|E = 2^0 |
89
- |1000_0000|E = 2^1 |
90
- |... | |
91
- |1111_1111|E = 2^128 |
82
+ |E |Description|
83
+ |--------|-----------|
84
+ |000_0000|E = 2^-63 |
85
+ |... | |
86
+ |011_1111|E = 2^0 |
87
+ |100_0000|E = 2^1 |
88
+ |... | |
89
+ |111_1111|E = 2^64 |
90
+
91
+ Note: the type has no `+0`, `-0`, `+inf`, `-inf`, `NaN`.
92
92
 
93
93
  ## Object Structure
94
94
 
95
- - type&counter: 32 + float64: 64
96
- - type&counter: 32 + int32: 32
97
- - type&counter: 32 + object: len: 32 + payload
98
- - type&counter: 32 + array: len: 32 + payload
99
- - type&counter: 32 + function: 32 + 32
100
- - type&counter: 32 + string: len: 32 + payload
101
- - type&counter: 32 + bigint: len: 32 + payload
102
-
103
- minimal size: 64 bit = 8 byte. It means that a number of objects can't be more than 2^(32-3) on 32-bit platform and 2^(64-3) on 64-bit platform.
104
- counter:
105
- - 32 - 3 = 29 bit,
106
- - 64 - 3 = 61 bit.
107
-
108
- Max length of JS string/array/object can't be bigger that 2^53-1
109
-
110
- ## Type
111
-
112
- - 000 float64
113
- - 001 string
114
- - 010 object
115
- - 011 array
116
- - 100 function
117
- - 101 bigint
118
- - 110 int32
119
- - 111 ...
120
-
121
- ## Type & counter
122
-
123
- |field |x32 |x64 |
124
- |-------|------|------|
125
- |type |29..31|61..63|
126
- |counter|0..28 |0..62 |
127
-
128
- ## Using Pools for small objects
129
-
130
- |type |size on x32|size on x64|
131
- |------------|-----------|-----------|
132
- |float64 |4+8 = 12 |8+8 = 16 |
133
- |function |4+4 = 8 |8+8 = 16 |
134
- |int32 |4+4 = 8 |8+4 = 12 |
135
- |empty object|4+4 = 8 |8+8 = 16 |
136
- |empty array |4+4 = 8 |8+8 = 16 |
95
+ Value Size = 8
96
+ Counter size = max_memory_size / value_size.
97
+
98
+ ### Type
99
+
100
+ - `000`: double
101
+ - `001`: string
102
+ - `010`: array
103
+ - `011`: object
104
+ - `100`: bigInt
105
+ - `101`: function
106
+ - `110`:
107
+ - `111`:
108
+
109
+ ### Type & Counter
110
+
111
+ - AtomicUSize:
112
+ - `3`: type
113
+ - `...`: counter
114
+
115
+ ### String
116
+
117
+ ```rust
118
+ struct String {
119
+ length: u32,
120
+ array: [u16; self.length],
121
+ }
122
+ ```
123
+
124
+ ### Function
125
+
126
+ ```rust
127
+ struct Function<length: u32> {
128
+ func: pointer,
129
+ array: [value; length]
130
+ }
131
+ ```
132
+
133
+ ### BigInt
134
+
135
+ ```rust
136
+ struct BigInt {
137
+ length: u32,
138
+ array: [u64; self.length],
139
+ }
140
+ ```
141
+
142
+ ### Array
143
+
144
+ ```rust
145
+ struct Array {
146
+ length: u32,
147
+ array: [Value; self.length],
148
+ }
149
+ ```
150
+
151
+ ### Object
152
+
153
+ ```rust
154
+ struct Object {
155
+ length: u32,
156
+ array: [(Value, Value), self.length],
157
+ indexArray: [u32, (self.length * log2(self.length) + 31) / u32],
158
+ }
159
+ ```
160
+
161
+ 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
162
+
163
+ 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.385",
3
+ "version": "0.0.388",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -4,14 +4,14 @@
4
4
 
5
5
  Requirement: no loss for UTF8 => codepoint => UTF8
6
6
 
7
- |utf8 |codepoint |size |codepoint |
7
+ |utf8 |utf8 code |size |codepoint |
8
8
  |---------|---------------------------------------|---------|--------------------------------------------------|
9
9
  |[a] |0xxx_xxxx |7 bit |0_0000_0000_0000_0xxx_xxxx |
10
10
  |[b,a] |110x_xxxx 10xx_xxxx |11 bit |0_0000_0000_0xxx_xxxx_xxxx + 0_0000_0000_1000_0000|
11
11
  |[c,b,a] |1110_xxxx 10xx_xxxx 10xx_xxxx |16 bit |0_0000_xxxx_xxxx_xxxx_xxxx + 0_0000_1000_0000_0000|
12
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
13
 
14
- |utf8 error| |size |codepoint |
14
+ |utf8 error|utf8 code |size |codepoint |
15
15
  |----------|-----------------------------|------|-------------------|
16
16
  |[e] |1111_1xxx | 3 bit| |
17
17
  |[d,] |1111_0xxx | 3 bit| |
@@ -55,15 +55,15 @@ Requirement: no loss for UTF16 => codepoint => UTF16
55
55
  - first : 0xD800: 0b_1101_10xx_xxxx_xxxx : 10 bit
56
56
  - second: 0xDC00: 0b_1101_11xx_xxxx_xxxx : 10 bit
57
57
 
58
- |utf16 |codepoint |size |
59
- |---------|---------------------------------------|------|
60
- |[a] |xxxx_xxxx_xxxx_xxxx |16 bit|
61
- |[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|
62
62
 
63
- |utf16 error|codepoint |size |
64
- |-----------|-------------------|------|
65
- |[e] |1101_11xx_xxxx_xxxx|10 bit|
66
- |[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|
67
67
 
68
68
  Total error states: 11 bit
69
69
 
@@ -74,7 +74,7 @@ const utf16ListToCodePointList
74
74
  /** @type {(input: List<i32>) => List<u16>} */
75
75
  const codePointListToUtf16List
76
76
 
77
- /** @type {(input: string) => List<u16> */
77
+ /** @type {(input: string) => List<u16>} */
78
78
  const stringToUtf16List
79
79
 
80
80
  /** @type {(input: List<u16>) => string} */
@@ -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 = {}