functionalscript 0.0.457 → 0.0.458
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/fsm/module.f.cjs +0 -5
- package/fsm/test.f.cjs +1 -10
- package/package.json +1 -1
- package/types/byte_set/module.f.cjs +20 -0
- package/types/byte_set/test.f.cjs +27 -1
package/fsm/module.f.cjs
CHANGED
|
@@ -14,15 +14,10 @@ const byteSet = require('../types/byte_set/module.f.cjs')
|
|
|
14
14
|
* }} Dfa
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/** @type {(faId: string) => string} */
|
|
18
|
-
const escape = faId => faId.replaceAll('\\', '\\\\').replaceAll('|', '\\|')
|
|
19
|
-
|
|
20
17
|
/** @type {(grammar: Grammar) => Dfa} */
|
|
21
18
|
const dfa = grammar => todo()
|
|
22
19
|
|
|
23
20
|
module.exports = {
|
|
24
|
-
/** @readonly */
|
|
25
|
-
escape,
|
|
26
21
|
/** @readonly */
|
|
27
22
|
dfa,
|
|
28
23
|
}
|
package/fsm/test.f.cjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
() => {
|
|
6
|
-
const result = _.escape('abc')
|
|
7
|
-
if (result !== 'abc') { throw result }
|
|
8
|
-
},
|
|
9
|
-
() => {
|
|
10
|
-
const result = _.escape('\\a|b|c\\')
|
|
11
|
-
if (result !== '\\\\a\\|b\\|c\\\\') { throw result }
|
|
12
|
-
}
|
|
13
|
-
]
|
|
4
|
+
|
|
14
5
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const { fn } = require('../function/module.f.cjs')
|
|
2
|
+
const rangeMap = require('../range_map/module.f.cjs')
|
|
3
|
+
const sortedSet = require('../sorted_set/module.f.cjs')
|
|
4
|
+
const list = require('../list/module.f.cjs')
|
|
5
|
+
const { reverse, countdown, flat, map } = list
|
|
2
6
|
|
|
3
7
|
/** @typedef {bigint} ByteSet */
|
|
4
8
|
/** @typedef {number} Byte */
|
|
@@ -42,6 +46,20 @@ const setRange = fn(range).then(union).result
|
|
|
42
46
|
/** @type {(n: Byte) => (s: ByteSet) => ByteSet} */
|
|
43
47
|
const unset = n => s => difference(s)(one(n))
|
|
44
48
|
|
|
49
|
+
const counter = reverse(countdown(256))
|
|
50
|
+
|
|
51
|
+
/** @type {(n: ByteSet) => (s: string) => (i: number) => rangeMap.RangeMap<sortedSet.SortedSet<string>>} */
|
|
52
|
+
const toRangeMapOp = n => s => i =>
|
|
53
|
+
{
|
|
54
|
+
const current = has(i + 1)(n)
|
|
55
|
+
const prev = has(i)(n)
|
|
56
|
+
if (current === prev) { return undefined }
|
|
57
|
+
return [[prev ? [s] : [], i]]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @type {(n: ByteSet) => (s: string) => rangeMap.RangeMap<sortedSet.SortedSet<string>>} */
|
|
61
|
+
const toRangeMap = n => s => flat(map(toRangeMapOp(n)(s))(counter))
|
|
62
|
+
|
|
45
63
|
module.exports = {
|
|
46
64
|
/** @readonly */
|
|
47
65
|
empty,
|
|
@@ -61,4 +79,6 @@ module.exports = {
|
|
|
61
79
|
range,
|
|
62
80
|
/** @readonly */
|
|
63
81
|
complement,
|
|
82
|
+
/** @readonly */
|
|
83
|
+
toRangeMap,
|
|
64
84
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const { every, countdown, map } = require('../list/module.f.cjs')
|
|
3
|
+
const json = require('../../json/module.f.cjs')
|
|
4
|
+
const { sort } = require('../object/module.f.cjs')
|
|
5
|
+
const { toArray } = require('../list/module.f.cjs')
|
|
6
|
+
|
|
7
|
+
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
8
|
+
const stringify = a => json.stringify(sort)(a)
|
|
3
9
|
|
|
4
10
|
module.exports = {
|
|
5
11
|
has: [
|
|
@@ -52,5 +58,25 @@ module.exports = {
|
|
|
52
58
|
const r = _.complement(_.universe)
|
|
53
59
|
if (r !== _.empty) { throw r }
|
|
54
60
|
},
|
|
55
|
-
}
|
|
61
|
+
},
|
|
62
|
+
toRangeMap: [
|
|
63
|
+
() => {
|
|
64
|
+
const result = stringify(toArray(_.toRangeMap(_.empty)('a')))
|
|
65
|
+
if (result !== '[]') { throw result }
|
|
66
|
+
},
|
|
67
|
+
() => {
|
|
68
|
+
const s = _.set(0)(_.empty)
|
|
69
|
+
const result = stringify(toArray(_.toRangeMap(s)('a')))
|
|
70
|
+
if (result !== '[[["a"],0]]') { throw result }
|
|
71
|
+
},
|
|
72
|
+
() => {
|
|
73
|
+
const s = _.setRange([1,2])(_.empty)
|
|
74
|
+
const result = stringify(toArray(_.toRangeMap(s)('a')))
|
|
75
|
+
if (result !== '[[[],0],[["a"],2]]') { throw result }
|
|
76
|
+
},
|
|
77
|
+
() => {
|
|
78
|
+
const result = stringify(toArray(_.toRangeMap(_.universe)('a')))
|
|
79
|
+
if (result !== '[[["a"],255]]') { throw result }
|
|
80
|
+
},
|
|
81
|
+
]
|
|
56
82
|
}
|