functionalscript 0.0.336 → 0.0.337
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/json/tokenizer/index.js +5 -3
- package/json/tokenizer/test.js +2 -15
- package/package.json +1 -1
package/json/tokenizer/index.js
CHANGED
|
@@ -390,10 +390,12 @@ const tokenizeEofOp = state => {
|
|
|
390
390
|
/** @type {operator.StateScan<CharCodeOrEof, TokenizerState, list.List<JsonToken>>} */
|
|
391
391
|
const tokenizeOp = state => input => input === undefined ? tokenizeEofOp(state) : tokenizeCharCodeOp(state)(input)
|
|
392
392
|
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
const initial = list.stateScan(tokenizeOp)({ kind: 'initial' })
|
|
394
|
+
|
|
395
|
+
/** @type {(input: list.List<number>) => list.List<JsonToken>} */
|
|
396
|
+
const tokenize = input => list.flat(initial(list.concat(/** @type {list.List<CharCodeOrEof>} */(input))([undefined])))
|
|
395
397
|
|
|
396
398
|
module.exports = {
|
|
397
399
|
/** @readonly */
|
|
398
|
-
tokenize
|
|
400
|
+
tokenize
|
|
399
401
|
}
|
package/json/tokenizer/test.js
CHANGED
|
@@ -3,23 +3,10 @@ const list = require('../../types/list/index.js')
|
|
|
3
3
|
const json = require('../index.js')
|
|
4
4
|
const { sort } = require('../../types/object/index.js')
|
|
5
5
|
|
|
6
|
-
/** @type {(s: string) => list.List<tokenizer.CharCodeOrEof>} */
|
|
7
|
-
const toCharacters = s =>
|
|
8
|
-
{
|
|
9
|
-
/** @type {list.List<tokenizer.CharCodeOrEof>} */
|
|
10
|
-
const charCodes = list.toCharCodes(s)
|
|
11
|
-
return list.concat(charCodes)([undefined])
|
|
12
|
-
}
|
|
13
|
-
|
|
14
6
|
/** @type {(s: string) => readonly tokenizer.JsonToken[]} */
|
|
15
|
-
const tokenizeString = s =>
|
|
16
|
-
{
|
|
17
|
-
const characters = toCharacters(s)
|
|
18
|
-
return list.toArray(tokenizer.tokenize(characters))
|
|
19
|
-
}
|
|
7
|
+
const tokenizeString = s => list.toArray(tokenizer.tokenize(list.toCharCodes(s)))
|
|
20
8
|
|
|
21
|
-
|
|
22
|
-
const stringify = a => json.stringify(sort)(a)
|
|
9
|
+
const stringify = json.stringify(sort)
|
|
23
10
|
|
|
24
11
|
{
|
|
25
12
|
const result = tokenizeString('')
|