functionalscript 0.0.567 → 0.0.569
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/com/test/build.cjs +1 -1
- package/issues/README.md +30 -0
- package/package.json +3 -4
- package/text/test.f.cjs +1 -1
- package/text/utf16/test.f.cjs +1 -1
- package/text/utf8/test.f.cjs +1 -1
- package/types/byte_set/module.f.cjs +1 -2
- package/types/range_map/module.f.cjs +26 -26
- package/types/range_map/test.f.cjs +1 -1
- package/module.f.cjs +0 -22
- package/types/module.f.cjs +0 -28
package/com/test/build.cjs
CHANGED
|
@@ -6,7 +6,7 @@ const { cpp, cs, rust } = build
|
|
|
6
6
|
const { join } = require('../../types/string/module.f.cjs')
|
|
7
7
|
const { log, error } = console
|
|
8
8
|
const { bold, reset } = require('../../text/sgr/module.f.cjs')
|
|
9
|
-
const
|
|
9
|
+
const list = require('../../types/list/module.f.cjs')
|
|
10
10
|
|
|
11
11
|
const nodeJs = {
|
|
12
12
|
dirname: __dirname,
|
package/issues/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Issues
|
|
2
|
+
|
|
3
|
+
## Allow Debugging During Test Run
|
|
4
|
+
|
|
5
|
+
Currently, we read files as strings and then parse them as functions. See [dev/test.mjs](dev/test.mjs). In this case, debugger doesn't know about source code and can't debug the functions. The main reason for loading modules as functions was that Deno v1 didn't support `.cjs` files. However, Deno v2 support them.
|
|
6
|
+
|
|
7
|
+
We can fix the issue by changing our test runner. The test runner will scan all directories and find all `test.f.cjs` files and then load them using `require`.
|
|
8
|
+
|
|
9
|
+
**Note:** we will drop support for Deno v1.
|
|
10
|
+
|
|
11
|
+
## Creating `./_module.f.cjs`
|
|
12
|
+
|
|
13
|
+
We can write a script which will generate `./_module.f.cjs` before packaging. Note: the script should be added into [prepack](https://docs.npmjs.com/cli/v8/using-npm/scripts#pre--post-scripts). The module should never be used by other internal modules. It's only for internal consumptions. The structure will be like this
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
module.exports = {
|
|
17
|
+
types: {
|
|
18
|
+
list: require('./types/list/module.f.cjs'),
|
|
19
|
+
// ...
|
|
20
|
+
},
|
|
21
|
+
// ...
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Then, users can use it like this:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const { types: { list } } = require('functionalscript)
|
|
29
|
+
//...
|
|
30
|
+
```
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.569",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
|
-
"main": "module.f.cjs",
|
|
6
5
|
"scripts": {
|
|
7
6
|
"tsc": "tsc",
|
|
8
7
|
"test": "tsc && npm run test-only",
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
},
|
|
31
30
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^22.9.
|
|
34
|
-
"typescript": "^5.
|
|
32
|
+
"@types/node": "^22.9.3",
|
|
33
|
+
"typescript": "^5.7.2"
|
|
35
34
|
}
|
|
36
35
|
}
|
package/text/test.f.cjs
CHANGED
package/text/utf16/test.f.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const encoding = require('./module.f.cjs')
|
|
2
2
|
const json = require('../../json/module.f.cjs')
|
|
3
3
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
4
|
-
const
|
|
4
|
+
const list = require('../../types/list/module.f.cjs')
|
|
5
5
|
|
|
6
6
|
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
7
7
|
const stringify = a => json.stringify(sort)(a)
|
package/text/utf8/test.f.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const encoding = require('./module.f.cjs')
|
|
2
2
|
const json = require('../../json/module.f.cjs')
|
|
3
3
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
4
|
-
const
|
|
4
|
+
const list = require('../../types/list/module.f.cjs')
|
|
5
5
|
|
|
6
6
|
const stringify = json.stringify(sort)
|
|
7
7
|
|
|
@@ -52,8 +52,7 @@ const counter = reverse(countdown(256))
|
|
|
52
52
|
const toRangeMapOp = n => s => i => {
|
|
53
53
|
const current = has(i + 1)(n)
|
|
54
54
|
const prev = has(i)(n)
|
|
55
|
-
|
|
56
|
-
return [[prev ? [s] : [], i]]
|
|
55
|
+
return current === prev ? null : [[prev ? [s] : [], i]]
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/** @type {(n: ByteSet) => (s: string) => rangeMap.RangeMap<sortedSet.SortedSet<string>>} */
|
|
@@ -27,7 +27,7 @@ const _range = require('../range/module.f.cjs')
|
|
|
27
27
|
* @typedef {{
|
|
28
28
|
* readonly union: operator.Reduce<T>
|
|
29
29
|
* readonly equal: operator.Equal<T>
|
|
30
|
-
|
|
30
|
+
* }} Operators
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -41,41 +41,41 @@ const _range = require('../range/module.f.cjs')
|
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
43
|
/** @type {<T>(union: operator.Reduce<T>) => (equal: operator.Equal<T>) => sortedList.ReduceOp<Entry<T>, RangeState<T>>} */
|
|
44
|
-
const reduceOp = union => equal => state => ([aItem, aMax]) => ([bItem, bMax])
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
const reduceOp = union => equal => state => ([aItem, aMax]) => ([bItem, bMax]) => {
|
|
45
|
+
const sign = cmp(aMax)(bMax)
|
|
46
|
+
const min = sign === 1 ? bMax : aMax
|
|
47
|
+
const u = union(aItem)(bItem)
|
|
48
|
+
const newState = state !== null && equal(state[0])(u) ? null : state
|
|
49
|
+
return [newState, sign, [u, min]]
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** @type {<T>(equal: operator.Equal<T>) => sortedList.TailReduce<Entry<T>, RangeState<T>>} */
|
|
53
53
|
const tailReduce = equal => state => tail => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
if (state === null) { return tail }
|
|
55
|
+
const tailResult = next(tail)
|
|
56
|
+
if (tailResult === null) { return [state] }
|
|
57
|
+
if (equal(state[0])(tailResult.first[0])) { return tailResult }
|
|
58
|
+
return { first: state, tail: tailResult }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
const merge = ({union, equal}) => genericMerge({reduceOp: reduceOp(union)(equal), tailReduce: tailReduce(equal)})(null)
|
|
61
|
+
/** @type {<T>(op: Operators<T>) => RangeMerge<T>} */
|
|
62
|
+
const merge = ({ union, equal }) => genericMerge({ reduceOp: reduceOp(union)(equal), tailReduce: tailReduce(equal) })(null)
|
|
63
63
|
|
|
64
64
|
/** @type {<T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T} */
|
|
65
65
|
const get = def => value => rm => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
const len = rm.length
|
|
67
|
+
let b = 0
|
|
68
|
+
let e = len - 1
|
|
69
|
+
while (true) {
|
|
70
|
+
if (b >= len) { return def }
|
|
71
|
+
if (e - b < 0) { return rm[b][0] }
|
|
72
|
+
const mid = b + (e - b >> 1)
|
|
73
|
+
if (value <= rm[mid][1]) {
|
|
74
|
+
e = mid - 1
|
|
75
|
+
} else {
|
|
76
|
+
b = mid + 1
|
|
77
|
+
}
|
|
77
78
|
}
|
|
78
|
-
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** @type {<T>(def: T) => (r: _range.Range) => (value: T) => RangeMapArray<T>} */
|
|
@@ -3,7 +3,7 @@ const { unsafeCmp } = require('../function/compare/module.f.cjs')
|
|
|
3
3
|
const json = require('../../json/module.f.cjs')
|
|
4
4
|
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
5
|
const sortedSet = require('../sorted_set/module.f.cjs')
|
|
6
|
-
const
|
|
6
|
+
const list = require('../list/module.f.cjs')
|
|
7
7
|
const operator = require("../function/operator/module.f.cjs")
|
|
8
8
|
|
|
9
9
|
/** @type {(a: readonly json.Unknown[]) => string} */
|
package/module.f.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
/** @readonly */
|
|
3
|
-
com: require('./com/module.f.cjs'),
|
|
4
|
-
/** @readonly */
|
|
5
|
-
commonjs: require('./commonjs/module.f.cjs'),
|
|
6
|
-
/** @readonly */
|
|
7
|
-
dev: require('./dev/module.f.cjs'),
|
|
8
|
-
/** @readonly */
|
|
9
|
-
fsm: require('./fsm/module.f.cjs'),
|
|
10
|
-
/** @readonly */
|
|
11
|
-
html: require('./html/module.f.cjs'),
|
|
12
|
-
/** @readonly */
|
|
13
|
-
json: require('./json/module.f.cjs'),
|
|
14
|
-
/** @readonly */
|
|
15
|
-
nodejs: require('./nodejs/module.f.cjs'),
|
|
16
|
-
/** @readonly */
|
|
17
|
-
sha2: require('./sha2/module.f.cjs'),
|
|
18
|
-
/** @readonly */
|
|
19
|
-
text: require('./text/module.f.cjs'),
|
|
20
|
-
/** @readonly */
|
|
21
|
-
types: require('./types/module.f.cjs'),
|
|
22
|
-
}
|
package/types/module.f.cjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
/** @readonly */
|
|
3
|
-
array: require('./array/module.f.cjs'),
|
|
4
|
-
/** @readonly */
|
|
5
|
-
btree: require('./btree/module.f.cjs'),
|
|
6
|
-
/** @readonly */
|
|
7
|
-
function: require('./function/module.f.cjs'),
|
|
8
|
-
/** @readonly */
|
|
9
|
-
list: require('./list/module.f.cjs'),
|
|
10
|
-
/** @readonly */
|
|
11
|
-
map: require('./map/module.f.cjs'),
|
|
12
|
-
/** @readonly */
|
|
13
|
-
nibbleSet: require('./nibble_set/module.f.cjs'),
|
|
14
|
-
/** @readonly */
|
|
15
|
-
object: require('./object/module.f.cjs'),
|
|
16
|
-
/** @readonly */
|
|
17
|
-
range: require('./range/module.f.cjs'),
|
|
18
|
-
/** @readonly */
|
|
19
|
-
result: require('./result/module.f.cjs'),
|
|
20
|
-
/** @readonly */
|
|
21
|
-
stringSet: require('./string_set/module.f.cjs'),
|
|
22
|
-
/** @readonly */
|
|
23
|
-
bigint: require('./bigint/module.f.cjs'),
|
|
24
|
-
/** @readonly */
|
|
25
|
-
number: require('./number/module.f.cjs'),
|
|
26
|
-
/** @readonly */
|
|
27
|
-
string: require('./string/module.f.cjs'),
|
|
28
|
-
}
|