functionalscript 0.0.483 → 0.0.484
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/package.json +1 -1
- package/text/utf16/module.f.cjs +13 -13
package/package.json
CHANGED
package/text/utf16/module.f.cjs
CHANGED
|
@@ -2,11 +2,11 @@ const list = require('../../types/list/module.f.cjs')
|
|
|
2
2
|
const operator = require('../../types/function/operator/module.f.cjs')
|
|
3
3
|
const { contains } = require('../../types/range/module.f.cjs')
|
|
4
4
|
const { fn } = require('../../types/function/module.f.cjs')
|
|
5
|
-
const { map, flat, stateScan, reduce, flatMap } = list
|
|
5
|
+
const { map, flat, stateScan, reduce, flatMap, empty } = list
|
|
6
6
|
|
|
7
|
-
/** @typedef {u16|
|
|
7
|
+
/** @typedef {u16|null} WordOrEof */
|
|
8
8
|
|
|
9
|
-
/** @typedef {
|
|
9
|
+
/** @typedef {number|null} Utf16State */
|
|
10
10
|
|
|
11
11
|
/** @typedef {number} u16 */
|
|
12
12
|
|
|
@@ -50,32 +50,32 @@ const utf16ByteToCodePointOp = state => word => {
|
|
|
50
50
|
if (!u16(word)) {
|
|
51
51
|
return [[0xffffffff], state]
|
|
52
52
|
}
|
|
53
|
-
if (state ===
|
|
54
|
-
if (isBmpCodePoint(word)) { return [[word],
|
|
53
|
+
if (state === null) {
|
|
54
|
+
if (isBmpCodePoint(word)) { return [[word], null] }
|
|
55
55
|
if (isHighSurrogate(word)) { return [[], word] }
|
|
56
|
-
return [[word | errorMask],
|
|
56
|
+
return [[word | errorMask], null]
|
|
57
57
|
}
|
|
58
58
|
if (isLowSurrogate(word)) {
|
|
59
59
|
const high = state - 0xd800
|
|
60
60
|
const low = word - 0xdc00
|
|
61
|
-
return [[(high << 10) + low + 0x10000],
|
|
61
|
+
return [[(high << 10) + low + 0x10000], null]
|
|
62
62
|
}
|
|
63
|
-
if (isBmpCodePoint(word)) { return [[state | errorMask, word],
|
|
63
|
+
if (isBmpCodePoint(word)) { return [[state | errorMask, word], null] }
|
|
64
64
|
if (isHighSurrogate(word)) { return [[state | errorMask], word] }
|
|
65
|
-
return [[state | errorMask, word | errorMask],
|
|
65
|
+
return [[state | errorMask, word | errorMask], null]
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** @type {(state: Utf16State) => readonly[list.List<i32>, Utf16State]} */
|
|
69
|
-
const utf16EofToCodePointOp = state => [state ===
|
|
69
|
+
const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null]
|
|
70
70
|
|
|
71
71
|
/** @type {operator.StateScan<WordOrEof, Utf16State, list.List<i32>>} */
|
|
72
|
-
const utf16ByteOrEofToCodePointOp = state => input => input ===
|
|
72
|
+
const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input)
|
|
73
73
|
|
|
74
74
|
/** @type {list.List<WordOrEof>} */
|
|
75
|
-
const eofList = [
|
|
75
|
+
const eofList = [null]
|
|
76
76
|
|
|
77
77
|
/** @type {(input: list.List<u16>) => list.List<i32>} */
|
|
78
|
-
const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(
|
|
78
|
+
const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])))
|
|
79
79
|
|
|
80
80
|
/** @type {(s: string) => list.List<u16>} */
|
|
81
81
|
const stringToList = s => {
|