functionalscript 0.0.399 → 0.0.400
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 +2 -2
- package/types/bigint/module.f.cjs +3 -0
- package/types/btree/find/test.f.cjs +3 -3
- package/types/btree/remove/test.f.cjs +3 -3
- package/types/btree/set/test.f.cjs +2 -2
- package/types/btree/test.f.cjs +4 -4
- package/types/function/compare/module.f.cjs +2 -10
- package/types/function/compare/test.f.cjs +3 -8
- package/types/map/module.f.cjs +2 -2
- package/types/number/module.f.cjs +7 -0
- package/types/number/test.f.cjs +6 -1
- package/types/string/module.f.cjs +7 -0
- package/types/string/test.f.cjs +6 -1
- package/types/string_set/module.f.cjs +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.400",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^18.7.
|
|
32
|
+
"@types/node": "^18.7.8",
|
|
33
33
|
"typescript": "^4.7.4"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -3,19 +3,19 @@ const list = require('../../list/module.f.cjs')
|
|
|
3
3
|
const json = require('../../../json/module.f.cjs')
|
|
4
4
|
const { sort } = require('../../object/module.f.cjs')
|
|
5
5
|
const btree = require('../types/module.f.cjs')
|
|
6
|
-
const {
|
|
6
|
+
const { cmp } = require('../../string/module.f.cjs')
|
|
7
7
|
const s = require('../set/module.f.cjs')
|
|
8
8
|
|
|
9
9
|
const jsonStr = json.stringify(sort)
|
|
10
10
|
|
|
11
11
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
12
|
-
const set = node => value => s.set(
|
|
12
|
+
const set = node => value => s.set(cmp(value))(() => value)(node)
|
|
13
13
|
|
|
14
14
|
/** @type {(r: _.Result<json.Unknown>) => string} */
|
|
15
15
|
const str = r => jsonStr(list.toArray(list.map(x => x[0])(r)))
|
|
16
16
|
|
|
17
17
|
/** @type {(i: string) => (m: btree.Node<string>) => string} */
|
|
18
|
-
const find = i => m => str(_.find(
|
|
18
|
+
const find = i => m => str(_.find(cmp(i))(m))
|
|
19
19
|
|
|
20
20
|
{
|
|
21
21
|
/** @type {btree.Node<string>} */
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const btree = require('../types/module.f.cjs')
|
|
3
3
|
const s = require('../set/module.f.cjs')
|
|
4
|
-
const {
|
|
4
|
+
const { cmp } = require('../../string/module.f.cjs')
|
|
5
5
|
const json = require('../../../json/module.f.cjs')
|
|
6
6
|
const { sort } = require('../../object/module.f.cjs')
|
|
7
7
|
|
|
8
8
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
9
|
-
const set = node => value => s.set(
|
|
9
|
+
const set = node => value => s.set(cmp(value))(() => value)(node)
|
|
10
10
|
|
|
11
11
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string> | undefined} */
|
|
12
|
-
const remove = node => value => _.nodeRemove(
|
|
12
|
+
const remove = node => value => _.nodeRemove(cmp(value))(node)
|
|
13
13
|
|
|
14
14
|
const jsonStr = json.stringify(sort)
|
|
15
15
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const btree = require('../types/module.f.cjs')
|
|
3
|
-
const {
|
|
3
|
+
const { cmp } = require('../../string/module.f.cjs')
|
|
4
4
|
const json = require('../../../json/module.f.cjs')
|
|
5
5
|
const { sort } = require('../../object/module.f.cjs')
|
|
6
6
|
|
|
7
7
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
8
|
-
const set = node => value => _.set(
|
|
8
|
+
const set = node => value => _.set(cmp(value))(() => value)(node)
|
|
9
9
|
|
|
10
10
|
const jsonStr = json.stringify(sort)
|
|
11
11
|
|
package/types/btree/test.f.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const btree = require('./types/module.f.cjs')
|
|
|
2
2
|
const { values } = require('./module.f.cjs')
|
|
3
3
|
const json = require('../../json/module.f.cjs')
|
|
4
4
|
const { sort } = require('../object/module.f.cjs')
|
|
5
|
-
const {
|
|
5
|
+
const { cmp } = require('../string/module.f.cjs')
|
|
6
6
|
const list = require('../list/module.f.cjs')
|
|
7
7
|
const s = require('./set/module.f.cjs')
|
|
8
8
|
const f = require('./find/module.f.cjs')
|
|
@@ -17,7 +17,7 @@ const jsonStr = json.stringify(sort)
|
|
|
17
17
|
const stringify = sequence => jsonStr(list.toArray(sequence))
|
|
18
18
|
|
|
19
19
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
20
|
-
const set = node => value => s.set(
|
|
20
|
+
const set = node => value => s.set(cmp(value))(() => value)(node)
|
|
21
21
|
|
|
22
22
|
{
|
|
23
23
|
/** @type {btree.Node<string>} */
|
|
@@ -45,7 +45,7 @@ const set = node => value => s.set(stringCmp(value))(() => value)(node)
|
|
|
45
45
|
let _map = ['a']
|
|
46
46
|
_map = set(_map)('b')
|
|
47
47
|
_map = set(_map)('c')
|
|
48
|
-
const result = f.value(f.find(
|
|
48
|
+
const result = f.value(f.find(cmp('b'))(_map).first)
|
|
49
49
|
if (result !== 'b') { throw result }
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -54,7 +54,7 @@ const set = node => value => s.set(stringCmp(value))(() => value)(node)
|
|
|
54
54
|
let _map = ['a']
|
|
55
55
|
_map = set(_map)('b')
|
|
56
56
|
_map = set(_map)('c')
|
|
57
|
-
const result = f.value(f.find(
|
|
57
|
+
const result = f.value(f.find(cmp('e'))(_map).first)
|
|
58
58
|
if (result !== undefined) { throw result }
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -27,19 +27,11 @@ const index5 = cmp => ([v0, v1]) => {
|
|
|
27
27
|
/** @type {<T>(a: T) => (b: T) => Sign} */
|
|
28
28
|
const unsafeCmp = a => b => a < b ? -1 : a === b ? 0 : 1
|
|
29
29
|
|
|
30
|
-
/** @type {(a: string) => (b: string) => Sign} */
|
|
31
|
-
const stringCmp = unsafeCmp
|
|
32
|
-
|
|
33
|
-
/** @type {(a: number) => (b: number) => Sign} */
|
|
34
|
-
const numberCmp = unsafeCmp
|
|
35
|
-
|
|
36
30
|
module.exports = {
|
|
31
|
+
/** @readonly */
|
|
32
|
+
unsafeCmp,
|
|
37
33
|
/** @readonly */
|
|
38
34
|
index3,
|
|
39
35
|
/** @readonly */
|
|
40
36
|
index5,
|
|
41
|
-
/** @readonly */
|
|
42
|
-
stringCmp,
|
|
43
|
-
/** @readonly */
|
|
44
|
-
numberCmp,
|
|
45
37
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { unsafeCmp } = require('./module.f.cjs')
|
|
2
2
|
|
|
3
3
|
{
|
|
4
|
-
const result =
|
|
5
|
-
if (result !==
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
const result = _.stringCmp('3')('4')
|
|
10
|
-
if (result !== -1) { throw result }
|
|
4
|
+
const result = unsafeCmp(true)(false)
|
|
5
|
+
if (result !== 1) { throw result }
|
|
11
6
|
}
|
|
12
7
|
|
|
13
8
|
module.exports = {}
|
package/types/map/module.f.cjs
CHANGED
|
@@ -4,7 +4,7 @@ const btreeFind = require('../btree/find/module.f.cjs')
|
|
|
4
4
|
const { value, find } = btreeFind
|
|
5
5
|
const btreeSet = require('../btree/set/module.f.cjs').set
|
|
6
6
|
const compare = require('../function/compare/module.f.cjs')
|
|
7
|
-
const {
|
|
7
|
+
const { cmp } = require('../string/module.f.cjs')
|
|
8
8
|
const list = require('../list/module.f.cjs')
|
|
9
9
|
const { reduce } = list
|
|
10
10
|
const { remove: btreeRemove } = require('../btree/remove/module.f.cjs')
|
|
@@ -28,7 +28,7 @@ const operator = require('../function/operator/module.f.cjs')
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/** @type {(a: string) => <T>(b: Entry<T>) => Sign} */
|
|
31
|
-
const keyCmp = a => ([b]) =>
|
|
31
|
+
const keyCmp = a => ([b]) => cmp(a)(b)
|
|
32
32
|
|
|
33
33
|
/** @type {(name: string) => <T>(map: Map<T>) => T|undefined} */
|
|
34
34
|
const at = name => map => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { fold } = require('../list/module.f.cjs')
|
|
2
2
|
const { addition, min: minOp, max: maxOp } = require('../function/operator/module.f.cjs')
|
|
3
|
+
const compare = require('../function/compare/module.f.cjs')
|
|
4
|
+
const { unsafeCmp } = compare
|
|
3
5
|
|
|
4
6
|
const sum = fold(addition)(0)
|
|
5
7
|
|
|
@@ -7,6 +9,9 @@ const min = fold(minOp)(undefined)
|
|
|
7
9
|
|
|
8
10
|
const max = fold(maxOp)(undefined)
|
|
9
11
|
|
|
12
|
+
/** @type {(a: number) => (b: number) => compare.Sign} */
|
|
13
|
+
const cmp = unsafeCmp
|
|
14
|
+
|
|
10
15
|
module.exports = {
|
|
11
16
|
/** @readonly */
|
|
12
17
|
sum,
|
|
@@ -14,4 +19,6 @@ module.exports = {
|
|
|
14
19
|
min,
|
|
15
20
|
/** @readonly */
|
|
16
21
|
max,
|
|
22
|
+
/** @readonly */
|
|
23
|
+
cmp,
|
|
17
24
|
}
|
package/types/number/test.f.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { sum, min, max } = require('./module.f.cjs')
|
|
1
|
+
const { sum, min, max, cmp } = require('./module.f.cjs')
|
|
2
2
|
|
|
3
3
|
{
|
|
4
4
|
const result = sum([2, 3, 4, 5])
|
|
@@ -20,4 +20,9 @@ const { sum, min, max } = require('./module.f.cjs')
|
|
|
20
20
|
if (result !== 12) { throw result }
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
{
|
|
24
|
+
const result = cmp(4)(5)
|
|
25
|
+
if (result !== -1) { throw result }
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
module.exports = {}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const list = require('../list/module.f.cjs')
|
|
2
2
|
const { fold: listFold, repeat: listRepeat } = list
|
|
3
3
|
const { compose } = require('../function/module.f.cjs')
|
|
4
|
+
const compare = require('../function/compare/module.f.cjs')
|
|
5
|
+
const { unsafeCmp } = compare
|
|
4
6
|
const op = require('../function/operator/module.f.cjs')
|
|
5
7
|
const { join: joinOp, concat: concatOp } = op
|
|
6
8
|
|
|
@@ -14,6 +16,9 @@ const concat = fold(concatOp)
|
|
|
14
16
|
/** @type {(n: string) => (v: number) => string} */
|
|
15
17
|
const repeat = v => compose(listRepeat(v))(concat)
|
|
16
18
|
|
|
19
|
+
/** @type {(a: string) => (b: string) => compare.Sign} */
|
|
20
|
+
const cmp = unsafeCmp
|
|
21
|
+
|
|
17
22
|
module.exports = {
|
|
18
23
|
/** @readonly */
|
|
19
24
|
join,
|
|
@@ -21,4 +26,6 @@ module.exports = {
|
|
|
21
26
|
concat,
|
|
22
27
|
/** @readonly */
|
|
23
28
|
repeat,
|
|
29
|
+
/** @readonly */
|
|
30
|
+
cmp,
|
|
24
31
|
}
|
package/types/string/test.f.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { join, concat, repeat } = require('./module.f.cjs')
|
|
1
|
+
const { join, concat, repeat, cmp } = require('./module.f.cjs')
|
|
2
2
|
const { repeat: repeatList } = require('../list/module.f.cjs')
|
|
3
3
|
|
|
4
4
|
{
|
|
@@ -36,4 +36,9 @@ const { repeat: repeatList } = require('../list/module.f.cjs')
|
|
|
36
36
|
if (s != 'xxxxx') { throw s }
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
{
|
|
40
|
+
const result = cmp('3')('4')
|
|
41
|
+
if (result !== -1) { throw result }
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
module.exports = {}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
/** @type {(s: StringSet) => list.List<string>} */
|
|
8
8
|
values,
|
|
9
9
|
} = btree
|
|
10
|
-
const {
|
|
10
|
+
const { cmp } = require("../string/module.f.cjs")
|
|
11
11
|
const list = require('../list/module.f.cjs')
|
|
12
12
|
const { reduce } = list
|
|
13
13
|
const { compose } = require('../function/module.f.cjs')
|
|
@@ -15,15 +15,15 @@ const { compose } = require('../function/module.f.cjs')
|
|
|
15
15
|
/** @typedef {btTypes.Tree<string>} StringSet */
|
|
16
16
|
|
|
17
17
|
/** @type {(value: string) => (set: StringSet) => boolean} */
|
|
18
|
-
const contains = value => s => s !== undefined && isFound(find(
|
|
18
|
+
const contains = value => s => s !== undefined && isFound(find(cmp(value))(s).first)
|
|
19
19
|
|
|
20
20
|
/** @type {(value: string) => (s: StringSet) => StringSet} */
|
|
21
|
-
const set = value => btreeSet(
|
|
21
|
+
const set = value => btreeSet(cmp(value))(() => value)
|
|
22
22
|
|
|
23
23
|
const fromValues = reduce(set)(undefined)
|
|
24
24
|
|
|
25
25
|
/** @type {(value: string) => (s: StringSet) => StringSet} */
|
|
26
|
-
const remove = compose(
|
|
26
|
+
const remove = compose(cmp)(btreeRemove)
|
|
27
27
|
|
|
28
28
|
module.exports = {
|
|
29
29
|
/** @readonly */
|