functionalscript 0.0.361 → 0.0.364
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/.github/workflows/bun.yml +2 -2
- package/.github/workflows/deno.yml +1 -1
- package/com/cpp/com.hpp +47 -0
- package/com/cpp/main.f.cjs +10 -0
- package/com/cpp/test/build.cjs +11 -0
- package/com/cpp/test/main.cpp +5 -0
- package/com/cpp/test.f.cjs +3 -0
- package/com/cs/{main.f.js → main.f.cjs} +40 -36
- package/com/cs/test/{build.js → build.cjs} +2 -2
- package/com/cs/{test.f.js → test.f.cjs} +17 -14
- package/com/{main.f.js → main.f.cjs} +1 -1
- package/com/types/{main.f.js → main.f.cjs} +3 -9
- package/commonjs/build/{main.f.js → main.f.cjs} +7 -7
- package/commonjs/build/{test.f.js → test.f.cjs} +6 -6
- package/commonjs/{main.f.js → main.f.cjs} +8 -8
- package/commonjs/module/function/{main.f.js → main.f.cjs} +1 -1
- package/commonjs/module/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/dependencies/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/dependencies/{test.f.js → test.f.cjs} +1 -1
- package/commonjs/package/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/{test.f.js → test.f.cjs} +2 -2
- package/commonjs/path/{main.f.js → main.f.cjs} +4 -4
- package/commonjs/path/{test.f.js → test.f.cjs} +7 -7
- package/dev/{main.f.js → main.f.cjs} +0 -0
- package/doc/README.md +9 -6
- package/html/{main.f.js → main.f.cjs} +4 -4
- package/html/{test.f.js → test.f.cjs} +1 -1
- package/io/commonjs/{main.js → main.cjs} +3 -3
- package/io/commonjs/{test.js → test.cjs} +2 -2
- package/io/nodejs/version/{main.js → main.cjs} +0 -0
- package/io/result/{main.js → main.cjs} +1 -1
- package/json/{main.f.js → main.f.cjs} +5 -5
- package/json/{test.f.js → test.f.cjs} +3 -3
- package/json/tokenizer/{main.f.js → main.f.cjs} +3 -3
- package/json/tokenizer/{test.f.js → test.f.cjs} +5 -5
- package/main.f.cjs +14 -0
- package/package.json +4 -4
- package/sha2/{main.f.js → main.f.cjs} +1 -1
- package/sha2/{test.f.js → test.f.cjs} +4 -4
- package/{test.f.js → test.f.cjs} +20 -20
- package/text/encoding/{main.f.js → main.f.cjs} +4 -4
- package/text/encoding/{test.f.js → test.f.cjs} +4 -4
- package/text/{main.f.js → main.f.cjs} +6 -1
- package/text/{test.f.js → test.f.cjs} +2 -2
- package/types/array/{main.f.js → main.f.cjs} +1 -1
- package/types/array/{test.f.js → test.f.cjs} +3 -3
- package/types/btree/find/{main.f.js → main.f.cjs} +4 -4
- package/types/btree/find/{test.f.js → test.f.cjs} +7 -7
- package/types/btree/{main.f.js → main.f.cjs} +6 -6
- package/types/btree/remove/{main.f.js → main.f.cjs} +6 -6
- package/types/btree/remove/{test.f.js → test.f.cjs} +6 -6
- package/types/btree/set/{main.f.js → main.f.cjs} +4 -4
- package/types/btree/set/{test.f.js → test.f.cjs} +5 -5
- package/types/btree/{test.f.js → test.f.cjs} +11 -11
- package/types/btree/types/{main.f.js → main.f.cjs} +0 -0
- package/types/function/compare/{main.f.js → main.f.cjs} +1 -1
- package/types/function/compare/{test.f.js → test.f.cjs} +1 -1
- package/types/function/{main.f.js → main.f.cjs} +2 -2
- package/types/function/operator/{main.f.js → main.f.cjs} +0 -0
- package/types/list/{main.f.js → main.f.cjs} +22 -25
- package/types/list/{test.f.js → test.f.cjs} +6 -6
- package/types/main.f.cjs +20 -0
- package/types/map/{main.f.js → main.f.cjs} +9 -9
- package/types/map/{test.f.js → test.f.cjs} +3 -3
- package/types/object/{main.f.js → main.f.cjs} +2 -2
- package/types/object/{test.f.js → test.f.cjs} +1 -1
- package/types/option/{main.f.js → main.f.cjs} +0 -0
- package/types/range/{main.f.js → main.f.cjs} +0 -0
- package/types/range/{test.f.js → test.f.cjs} +1 -1
- package/types/result/{main.f.js → main.f.cjs} +0 -0
- package/types/stringset/{main.f.js → main.f.cjs} +5 -5
- package/types/stringset/{test.f.js → test.f.cjs} +1 -1
- package/main.f.js +0 -14
- package/types/main.f.js +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const operator = require('../../types/function/operator/main.f.
|
|
2
|
-
const list = require('../../types/list/main.f.
|
|
3
|
-
const range = require('../../types/range/main.f.
|
|
1
|
+
const operator = require('../../types/function/operator/main.f.cjs')
|
|
2
|
+
const list = require('../../types/list/main.f.cjs')
|
|
3
|
+
const range = require('../../types/range/main.f.cjs')
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const tokenizer = require('./main.f.
|
|
2
|
-
const list = require('../../types/list/main.f.
|
|
3
|
-
const json = require('../main.f.
|
|
4
|
-
const { sort } = require('../../types/object/main.f.
|
|
1
|
+
const tokenizer = require('./main.f.cjs')
|
|
2
|
+
const list = require('../../types/list/main.f.cjs')
|
|
3
|
+
const json = require('../main.f.cjs')
|
|
4
|
+
const { sort } = require('../../types/object/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/** @type {(s: string) => readonly tokenizer.JsonToken[]} */
|
|
7
|
-
const tokenizeString = s => list.toArray(tokenizer.tokenize(list.
|
|
7
|
+
const tokenizeString = s => list.toArray(tokenizer.tokenize(list.toCharCodeList(s)))
|
|
8
8
|
|
|
9
9
|
const stringify = json.stringify(sort)
|
|
10
10
|
|
package/main.f.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/** @readonly */
|
|
3
|
+
commonjs: require('./commonjs/main.f.cjs'),
|
|
4
|
+
/** @readonly */
|
|
5
|
+
dev: require('./dev/main.f.cjs'),
|
|
6
|
+
/** @readonly */
|
|
7
|
+
html: require('./html/main.f.cjs'),
|
|
8
|
+
/** @readonly */
|
|
9
|
+
json: require('./json/main.f.cjs'),
|
|
10
|
+
/** @readonly */
|
|
11
|
+
sha2: require('./sha2/main.f.cjs'),
|
|
12
|
+
/** @readonly */
|
|
13
|
+
types: require('./types/main.f.cjs'),
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.364",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
|
-
"main": "main.f.
|
|
5
|
+
"main": "main.f.cjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"test": "tsc && npm run test-only",
|
|
9
|
-
"version": "node ./io/nodejs/version/main.
|
|
10
|
-
"test-only": "node --trace-uncaught ./test.f.
|
|
9
|
+
"version": "node ./io/nodejs/version/main.cjs",
|
|
10
|
+
"test-only": "node --trace-uncaught ./test.f.cjs"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const json = require('../json/main.f.
|
|
3
|
-
const { sort } = require('../types/object/main.f.
|
|
4
|
-
const list = require('../types/list/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const json = require('../json/main.f.cjs')
|
|
3
|
+
const { sort } = require('../types/object/main.f.cjs')
|
|
4
|
+
const list = require('../types/list/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/** @type {(a: number) => number} */
|
|
7
7
|
const toU32 = x => (x + 0x1_0000_0000) % 0x1_0000_0000
|
package/{test.f.js → test.f.cjs}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const i = require('./main.f.
|
|
1
|
+
const i = require('./main.f.cjs')
|
|
2
2
|
|
|
3
|
-
require('./types/list/test.f.
|
|
4
|
-
require('./types/array/test.f.
|
|
5
|
-
require('./types/btree/test.f.
|
|
6
|
-
require('./sha2/test.f.
|
|
7
|
-
require('./json/test.f.
|
|
8
|
-
require('./json/tokenizer/test.f.
|
|
9
|
-
require('./types/object/test.f.
|
|
10
|
-
require('./io/commonjs/test.
|
|
11
|
-
require('./commonjs/package/dependencies/test.f.
|
|
12
|
-
require('./commonjs/package/test.f.
|
|
13
|
-
require('./commonjs/path/test.f.
|
|
14
|
-
require('./types/function/compare/test.f.
|
|
15
|
-
require('./types/stringset/test.f.
|
|
16
|
-
require('./commonjs/build/test.f.
|
|
17
|
-
require('./types/range/test.f.
|
|
18
|
-
require('./html/test.f.
|
|
19
|
-
require('./text/test.f.
|
|
20
|
-
require('./text/encoding/test.f.
|
|
21
|
-
require('./com/cs/test.f.
|
|
3
|
+
require('./types/list/test.f.cjs')
|
|
4
|
+
require('./types/array/test.f.cjs')
|
|
5
|
+
require('./types/btree/test.f.cjs')
|
|
6
|
+
require('./sha2/test.f.cjs')
|
|
7
|
+
require('./json/test.f.cjs')
|
|
8
|
+
require('./json/tokenizer/test.f.cjs')
|
|
9
|
+
require('./types/object/test.f.cjs')
|
|
10
|
+
require('./io/commonjs/test.cjs')
|
|
11
|
+
require('./commonjs/package/dependencies/test.f.cjs')
|
|
12
|
+
require('./commonjs/package/test.f.cjs')
|
|
13
|
+
require('./commonjs/path/test.f.cjs')
|
|
14
|
+
require('./types/function/compare/test.f.cjs')
|
|
15
|
+
require('./types/stringset/test.f.cjs')
|
|
16
|
+
require('./commonjs/build/test.f.cjs')
|
|
17
|
+
require('./types/range/test.f.cjs')
|
|
18
|
+
require('./html/test.f.cjs')
|
|
19
|
+
require('./text/test.f.cjs')
|
|
20
|
+
require('./text/encoding/test.f.cjs')
|
|
21
|
+
require('./com/cs/test.f.cjs')
|
|
22
22
|
|
|
23
23
|
/** @type {() => never} */
|
|
24
24
|
const assert = () => { throw 'assert' }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const result = require('../../types/result/main.f.
|
|
2
|
-
const list = require('../../types/list/main.f.
|
|
1
|
+
const result = require('../../types/result/main.f.cjs')
|
|
2
|
+
const list = require('../../types/list/main.f.cjs')
|
|
3
3
|
const { ok, error } = result
|
|
4
4
|
|
|
5
5
|
/** @typedef {result.Result<number,number>} Utf8Result */
|
|
@@ -20,9 +20,9 @@ const codePointToUtf16 = input =>
|
|
|
20
20
|
if (input >= 0x0000 && input <= 0xd7ff || input >= 0xe000 && input <= 0xffff) { return [ok(input >> 8), ok(input & 0xff)] }
|
|
21
21
|
if (input >= 0x010000 && input <= 0x10ffff) {
|
|
22
22
|
const high = ((input - 0x10000) >> 10) + 0xd800
|
|
23
|
-
const low = ((input - 0x10000) & 0x3ff) + 0xdc00
|
|
23
|
+
const low = ((input - 0x10000) & 0x3ff) + 0xdc00
|
|
24
24
|
return [ok(high >> 8), ok(high & 0xff), ok(low >> 8), ok(low & 0xff)]
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
return [error(input)]
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const encoding = require('./main.f.
|
|
2
|
-
const json = require('../../json/main.f')
|
|
3
|
-
const { sort } = require('../../types/object/main.f.
|
|
4
|
-
const { list } = require('../../types/main.f.
|
|
1
|
+
const encoding = require('./main.f.cjs')
|
|
2
|
+
const json = require('../../json/main.f.cjs')
|
|
3
|
+
const { sort } = require('../../types/object/main.f.cjs')
|
|
4
|
+
const { list } = require('../../types/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
7
7
|
const stringify = a => json.stringify(sort)(a)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const list = require('../types/list/main.f.
|
|
1
|
+
const list = require('../types/list/main.f.cjs')
|
|
2
2
|
|
|
3
3
|
/** @typedef {ItemThunk|ItemArray} Block */
|
|
4
4
|
|
|
@@ -21,7 +21,12 @@ const flat = indent => {
|
|
|
21
21
|
return f('')
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** @type {(type: string) => (name: string) => (body: Block) => Block} */
|
|
25
|
+
const curly = type => name => body => [`${type} ${name}`, '{', body, '}']
|
|
26
|
+
|
|
24
27
|
module.exports = {
|
|
25
28
|
/** @readonly */
|
|
26
29
|
flat,
|
|
30
|
+
/** @readonly */
|
|
31
|
+
curly,
|
|
27
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const json = require('../../json/main.f.
|
|
3
|
-
const { sort } = require('../object/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const json = require('../../json/main.f.cjs')
|
|
3
|
+
const { sort } = require('../object/main.f.cjs')
|
|
4
4
|
|
|
5
5
|
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
6
6
|
const stringify = a => json.stringify(sort)(a)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const _ = require('../types/main.f.
|
|
2
|
-
const list = require('../../list/main.f.
|
|
3
|
-
const cmp = require('../../function/compare/main.f.
|
|
4
|
-
const array = require('../../array/main.f.
|
|
1
|
+
const _ = require('../types/main.f.cjs')
|
|
2
|
+
const list = require('../../list/main.f.cjs')
|
|
3
|
+
const cmp = require('../../function/compare/main.f.cjs')
|
|
4
|
+
const array = require('../../array/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @template T
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const list = require('../../list/main.f.
|
|
3
|
-
const json = require('../../../json/main.f.
|
|
4
|
-
const { sort } = require('../../object/main.f.
|
|
5
|
-
const btree = require('../types/main.f.
|
|
6
|
-
const { stringCmp } = require('../../function/compare/main.f.
|
|
7
|
-
const s = require('../set/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const list = require('../../list/main.f.cjs')
|
|
3
|
+
const json = require('../../../json/main.f.cjs')
|
|
4
|
+
const { sort } = require('../../object/main.f.cjs')
|
|
5
|
+
const btree = require('../types/main.f.cjs')
|
|
6
|
+
const { stringCmp } = require('../../function/compare/main.f.cjs')
|
|
7
|
+
const s = require('../set/main.f.cjs')
|
|
8
8
|
|
|
9
9
|
const jsonStr = json.stringify(sort)
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const list = require('../list/main.f.
|
|
2
|
-
const option = require('../option/main.f.
|
|
3
|
-
const _ = require('./types/main.f.
|
|
1
|
+
const list = require('../list/main.f.cjs')
|
|
2
|
+
const option = require('../option/main.f.cjs')
|
|
3
|
+
const _ = require('./types/main.f.cjs')
|
|
4
4
|
|
|
5
5
|
/** @type {<T>(node: _.Node<T>) => list.Thunk<T>} */
|
|
6
6
|
const nodeValues = node => () => {
|
|
@@ -30,11 +30,11 @@ const values = option.map(nodeValues)
|
|
|
30
30
|
|
|
31
31
|
module.exports = {
|
|
32
32
|
/** @readonly */
|
|
33
|
-
find: require('./find/main.f.
|
|
33
|
+
find: require('./find/main.f.cjs'),
|
|
34
34
|
/** @readonly */
|
|
35
|
-
remove: require('./remove/main.f.
|
|
35
|
+
remove: require('./remove/main.f.cjs'),
|
|
36
36
|
/** @readonly */
|
|
37
|
-
set: require('./set/main.f.
|
|
37
|
+
set: require('./set/main.f.cjs'),
|
|
38
38
|
/** @readonly */
|
|
39
39
|
values,
|
|
40
40
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const _ = require('../types/main.f.
|
|
2
|
-
const cmp = require('../../function/compare/main.f.
|
|
3
|
-
const find = require('../find/main.f.
|
|
4
|
-
const list = require('../../list/main.f.
|
|
5
|
-
const array = require('../../array/main.f.
|
|
6
|
-
const option = require('../../option/main.f.
|
|
1
|
+
const _ = require('../types/main.f.cjs')
|
|
2
|
+
const cmp = require('../../function/compare/main.f.cjs')
|
|
3
|
+
const find = require('../find/main.f.cjs')
|
|
4
|
+
const list = require('../../list/main.f.cjs')
|
|
5
|
+
const array = require('../../array/main.f.cjs')
|
|
6
|
+
const option = require('../../option/main.f.cjs')
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @template T
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const btree = require('../types/main.f.
|
|
3
|
-
const s = require('../set/main.f.
|
|
4
|
-
const { stringCmp } = require('../../function/compare/main.f.
|
|
5
|
-
const json = require('../../../json/main.f.
|
|
6
|
-
const { sort } = require('../../object/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const btree = require('../types/main.f.cjs')
|
|
3
|
+
const s = require('../set/main.f.cjs')
|
|
4
|
+
const { stringCmp } = require('../../function/compare/main.f.cjs')
|
|
5
|
+
const json = require('../../../json/main.f.cjs')
|
|
6
|
+
const { sort } = require('../../object/main.f.cjs')
|
|
7
7
|
|
|
8
8
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
9
9
|
const set = node => value => s.set(stringCmp(value))(value)(node)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const _ = require('../types/main.f.
|
|
2
|
-
const find = require('../find/main.f.
|
|
3
|
-
const cmp = require('../../function/compare/main.f.
|
|
4
|
-
const list = require('../../list/main.f.
|
|
1
|
+
const _ = require('../types/main.f.cjs')
|
|
2
|
+
const find = require('../find/main.f.cjs')
|
|
3
|
+
const cmp = require('../../function/compare/main.f.cjs')
|
|
4
|
+
const list = require('../../list/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @template T
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const btree = require('../types/main.f.
|
|
3
|
-
const { stringCmp } = require('../../function/compare/main.f.
|
|
4
|
-
const json = require('../../../json/main.f.
|
|
5
|
-
const { sort } = require('../../object/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const btree = require('../types/main.f.cjs')
|
|
3
|
+
const { stringCmp } = require('../../function/compare/main.f.cjs')
|
|
4
|
+
const json = require('../../../json/main.f.cjs')
|
|
5
|
+
const { sort } = require('../../object/main.f.cjs')
|
|
6
6
|
|
|
7
7
|
/** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
|
|
8
8
|
const set = node => value => _.set(stringCmp(value))(value)(node)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const btree = require('./types/main.f.
|
|
2
|
-
const { values } = require('./main.f.
|
|
3
|
-
const json = require('../../json/main.f.
|
|
4
|
-
const { sort } = require('../object/main.f.
|
|
5
|
-
const { stringCmp } = require('../function/compare/main.f.
|
|
6
|
-
const list = require('../list/main.f.
|
|
7
|
-
const s = require('./set/main.f.
|
|
8
|
-
const f = require('./find/main.f.
|
|
1
|
+
const btree = require('./types/main.f.cjs')
|
|
2
|
+
const { values } = require('./main.f.cjs')
|
|
3
|
+
const json = require('../../json/main.f.cjs')
|
|
4
|
+
const { sort } = require('../object/main.f.cjs')
|
|
5
|
+
const { stringCmp } = require('../function/compare/main.f.cjs')
|
|
6
|
+
const list = require('../list/main.f.cjs')
|
|
7
|
+
const s = require('./set/main.f.cjs')
|
|
8
|
+
const f = require('./find/main.f.cjs')
|
|
9
9
|
|
|
10
|
-
require('./find/test.f.
|
|
11
|
-
require('./set/test.f.
|
|
12
|
-
require('./remove/test.f.
|
|
10
|
+
require('./find/test.f.cjs')
|
|
11
|
+
require('./set/test.f.cjs')
|
|
12
|
+
require('./remove/test.f.cjs')
|
|
13
13
|
|
|
14
14
|
const jsonStr = json.stringify(sort)
|
|
15
15
|
|
|
File without changes
|
|
@@ -19,9 +19,9 @@ const flip = f => b => a => f(a)(b)
|
|
|
19
19
|
|
|
20
20
|
module.exports = {
|
|
21
21
|
/** @readonly */
|
|
22
|
-
compare: require('./compare/main.f.
|
|
22
|
+
compare: require('./compare/main.f.cjs'),
|
|
23
23
|
/** @readonly */
|
|
24
|
-
operator: require('./operator/main.f.
|
|
24
|
+
operator: require('./operator/main.f.cjs'),
|
|
25
25
|
/** @readonly */
|
|
26
26
|
identity,
|
|
27
27
|
/** @readonly */
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const { compose, identity } = require('../function/main.f.
|
|
2
|
-
const operator = require('../function/operator/main.f.
|
|
1
|
+
const { compose, identity } = require('../function/main.f.cjs')
|
|
2
|
+
const operator = require('../function/operator/main.f.cjs')
|
|
3
3
|
const { logicalNot, strictEqual, stateScanToScan, reduceToScan, foldToScan } = operator
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -105,7 +105,7 @@ const toArray = list => {
|
|
|
105
105
|
return u instanceof Array ? u : Array.from(iterable(u))
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/** @type {<I, O>(step: (n: NonEmpty<I>) => List<O>) => (input: List<I>) =>
|
|
108
|
+
/** @type {<I, O>(step: (n: NonEmpty<I>) => List<O>) => (input: List<I>) => Thunk<O>} */
|
|
109
109
|
const apply = f => input => () => {
|
|
110
110
|
const n = next(input)
|
|
111
111
|
if (n === undefined) { return undefined }
|
|
@@ -115,16 +115,16 @@ const apply = f => input => () => {
|
|
|
115
115
|
/** @type {<T>(n: NonEmpty<List<T>>) => List<T>} */
|
|
116
116
|
const flatStep = n => concat(n.first)(flat(n.tail))
|
|
117
117
|
|
|
118
|
-
/** @type {<T>(list: List<List<T>>) =>
|
|
118
|
+
/** @type {<T>(list: List<List<T>>) => Thunk<T>} */
|
|
119
119
|
const flat = apply(flatStep)
|
|
120
120
|
|
|
121
121
|
/** @type {<I, O>(f: (value: I) => O) => (n: NonEmpty<I>) => List<O>} */
|
|
122
122
|
const mapStep = f => n => ({ first: f(n.first), tail: map(f)(n.tail) })
|
|
123
123
|
|
|
124
|
-
/** @type {<I, O>(f: (value: I) => O) => (input: List<I>) =>
|
|
124
|
+
/** @type {<I, O>(f: (value: I) => O) => (input: List<I>) => Thunk<O>} */
|
|
125
125
|
const map = f => apply(mapStep(f))
|
|
126
126
|
|
|
127
|
-
/** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) =>
|
|
127
|
+
/** @type {<I, O>(f: (value: I) => List<O>) => (input: List<I>) => Thunk<O>} */
|
|
128
128
|
const flatMap = f => compose(map(f))(flat)
|
|
129
129
|
|
|
130
130
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
@@ -133,7 +133,7 @@ const filterStep = f => n => {
|
|
|
133
133
|
return f(n.first) ? { first: n.first, tail } : tail
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) =>
|
|
136
|
+
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
137
137
|
const filter = f => apply(filterStep(f))
|
|
138
138
|
|
|
139
139
|
/** @type {<I, O>(f: (value: I) => O|undefined) => (n: NonEmpty<I>) => List<O>} */
|
|
@@ -142,31 +142,31 @@ const filterMapStep = f => n => {
|
|
|
142
142
|
return first === undefined ? tail : { first, tail }
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/** @type {<I, O>(f: (value: I) => O|undefined) => (input: List<I>) =>
|
|
145
|
+
/** @type {<I, O>(f: (value: I) => O|undefined) => (input: List<I>) => Thunk<O>} */
|
|
146
146
|
const filterMap = f => apply(filterMapStep(f))
|
|
147
147
|
|
|
148
148
|
/** @type {<T>(f: (value: T) => boolean) => (n: NonEmpty<T>) => List<T>} */
|
|
149
149
|
const takeWhileStep = f => n => f(n.first) ? { first: n.first, tail: takeWhile(f)(n.tail) } : undefined
|
|
150
150
|
|
|
151
|
-
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) =>
|
|
151
|
+
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
152
152
|
const takeWhile = f => apply(takeWhileStep(f))
|
|
153
153
|
|
|
154
154
|
/** @type {(n: number) => <T>(result: NonEmpty<T>) => List<T>} */
|
|
155
155
|
const takeStep = n => ne => 0 < n ? { first: ne.first, tail: take(n - 1)(ne.tail) } : undefined
|
|
156
156
|
|
|
157
|
-
/** @type {(n: number) => <T>(input: List<T>) =>
|
|
157
|
+
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
158
158
|
const take = n => apply(takeStep(n))
|
|
159
159
|
|
|
160
160
|
/** @type {<T>(f: (value: T) => boolean) => (ne: NonEmpty<T>) => List<T>} */
|
|
161
161
|
const dropWhileStep = f => ne => f(ne.first) ? dropWhile(f)(ne.tail) : ne
|
|
162
162
|
|
|
163
|
-
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) =>
|
|
163
|
+
/** @type {<T>(f: (value: T) => boolean) => (input: List<T>) => Thunk<T>} */
|
|
164
164
|
const dropWhile = f => apply(dropWhileStep(f))
|
|
165
165
|
|
|
166
166
|
/** @type {(n: number) => <T>(ne: NonEmpty<T>) => List<T>} */
|
|
167
167
|
const dropStep = n => ne => 0 < n ? drop(n - 1)(ne.tail) : ne
|
|
168
168
|
|
|
169
|
-
/** @type {(n: number) => <T>(input: List<T>) =>
|
|
169
|
+
/** @type {(n: number) => <T>(input: List<T>) => Thunk<T>} */
|
|
170
170
|
const drop = n => apply(dropStep(n))
|
|
171
171
|
|
|
172
172
|
/** @type {<D>(def: D) => <T>(input: List<T>) => D|T} */
|
|
@@ -214,7 +214,7 @@ const countdown = count => () => {
|
|
|
214
214
|
return { first, tail: countdown(first) }
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
/** @type {<T>(v: T) => (c: number) =>
|
|
217
|
+
/** @type {<T>(v: T) => (c: number) => Thunk<T>} */
|
|
218
218
|
const repeat = v => n => map(() => v)(countdown(n))
|
|
219
219
|
|
|
220
220
|
/** @type {<T>(list: List<T>) => List<T>} */
|
|
@@ -229,13 +229,13 @@ const scanStep = op => ne => {
|
|
|
229
229
|
return { first, tail: scan(newOp)(ne.tail) }
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) =>
|
|
232
|
+
/** @type {<I, O>(op: operator.Scan<I, O>) => (input: List<I>) => Thunk<O>} */
|
|
233
233
|
const scan = op => apply(scanStep(op))
|
|
234
234
|
|
|
235
|
-
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) =>
|
|
235
|
+
/** @type {<I, S, O>(op: operator.StateScan<I, S, O>) => (init: S) => (input: List<I>) => Thunk<O>} */
|
|
236
236
|
const stateScan = op => init => scan(stateScanToScan(op)(init))
|
|
237
237
|
|
|
238
|
-
/** @type {<I,O>(op: operator.Reduce<I, O>) => (init: O) => (input: List<I>) =>
|
|
238
|
+
/** @type {<I,O>(op: operator.Reduce<I, O>) => (init: O) => (input: List<I>) => Thunk<O>} */
|
|
239
239
|
const reduceScan = op => init => scan(reduceToScan(op)(init))
|
|
240
240
|
|
|
241
241
|
/** @type {<I,O>(op: operator.Reduce<I, O>) => (init: O) => (input: List<I>) => O} */
|
|
@@ -264,7 +264,7 @@ const length = reduce(operator.counter)(0)
|
|
|
264
264
|
/** @type {(index: number) => <T>(value: T) => readonly[Entry<T>, number]} */
|
|
265
265
|
const entryOperator = index => value => [[index, value], index + 1]
|
|
266
266
|
|
|
267
|
-
/** @type {<T>(input: List<T>) =>
|
|
267
|
+
/** @type {<T>(input: List<T>) => Thunk<Entry<T>>} */
|
|
268
268
|
const entries = input => {
|
|
269
269
|
/** @typedef {typeof input extends List<infer T> ? T : never} T */
|
|
270
270
|
return stateScan(/** @type {operator.StateScan<T, Number, Entry<T>>} */(entryOperator))(0)(input)
|
|
@@ -276,16 +276,13 @@ const reverseOperator = first => tail => ({ first, tail })
|
|
|
276
276
|
/** @type {<T>(input: List<T>) => List<T>} */
|
|
277
277
|
const reverse = reduce(reverseOperator)(undefined)
|
|
278
278
|
|
|
279
|
-
/** @type {<A>(a: A) => <B>(b: B) => readonly[A, B]} */
|
|
280
|
-
const tuple2 = a => b => [a, b]
|
|
281
|
-
|
|
282
279
|
/** @type {<A>(a: List<A>) => <B>(b: List<B>) => List<readonly[A, B]>} */
|
|
283
280
|
const zip = a => b => () => {
|
|
284
281
|
const aResult = next(a)
|
|
285
282
|
if (aResult === undefined) { return undefined }
|
|
286
283
|
const bResult = next(b)
|
|
287
284
|
if (bResult === undefined) { return undefined }
|
|
288
|
-
return { first:
|
|
285
|
+
return { first: [aResult.first, bResult.first], tail: zip(aResult.tail)(bResult.tail) }
|
|
289
286
|
}
|
|
290
287
|
|
|
291
288
|
/** @type {<T>(e: operator.Equal<T>) => (a: List<T>) => (b: List<T>) => List<boolean>} */
|
|
@@ -300,7 +297,7 @@ const equalZip = e => a => b => () => {
|
|
|
300
297
|
const equal = e => a => b => every(equalZip(e)(a)(b))
|
|
301
298
|
|
|
302
299
|
/** @type {(s: string) => List<number>} */
|
|
303
|
-
const
|
|
300
|
+
const toCharCodeList = s => {
|
|
304
301
|
/** @type {(i: number) => Result<number>} */
|
|
305
302
|
const at = i => {
|
|
306
303
|
const first = s.charCodeAt(i)
|
|
@@ -309,7 +306,7 @@ const toCharCodes = s => {
|
|
|
309
306
|
return at(0)
|
|
310
307
|
}
|
|
311
308
|
|
|
312
|
-
const
|
|
309
|
+
const fromCharCodeList = compose(map(String.fromCharCode))(fold(operator.concat)(''))
|
|
313
310
|
|
|
314
311
|
module.exports = {
|
|
315
312
|
/** @readonly */
|
|
@@ -389,7 +386,7 @@ module.exports = {
|
|
|
389
386
|
/** @readonly */
|
|
390
387
|
equal,
|
|
391
388
|
/** @readonly */
|
|
392
|
-
|
|
389
|
+
toCharCodeList,
|
|
393
390
|
/** @readonly */
|
|
394
|
-
|
|
391
|
+
fromCharCodeList,
|
|
395
392
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const _ = require('./main.f.
|
|
2
|
-
const json = require('../../json/main.f.
|
|
3
|
-
const { sort } = require('../object/main.f.
|
|
4
|
-
const { addition, strictEqual, foldToScan } = require('../function/operator/main.f.
|
|
1
|
+
const _ = require('./main.f.cjs')
|
|
2
|
+
const json = require('../../json/main.f.cjs')
|
|
3
|
+
const { sort } = require('../object/main.f.cjs')
|
|
4
|
+
const { addition, strictEqual, foldToScan } = require('../function/operator/main.f.cjs')
|
|
5
5
|
|
|
6
6
|
/** @type {(sequence: _.List<json.Unknown>) => string} */
|
|
7
7
|
const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
@@ -235,8 +235,8 @@ const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
{
|
|
238
|
-
const r = _.
|
|
239
|
-
const x = _.
|
|
238
|
+
const r = _.toCharCodeList("Hello world!")
|
|
239
|
+
const x = _.fromCharCodeList(r)
|
|
240
240
|
if (x !== "Hello world!") { throw x }
|
|
241
241
|
}
|
|
242
242
|
|
package/types/main.f.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/** @readonly */
|
|
3
|
+
array: require('./array/main.f.cjs'),
|
|
4
|
+
/** @readonly */
|
|
5
|
+
btree: require('./btree/main.f.cjs'),
|
|
6
|
+
/** @readonly */
|
|
7
|
+
function: require('./function/main.f.cjs'),
|
|
8
|
+
/** @readonly */
|
|
9
|
+
list: require('./list/main.f.cjs'),
|
|
10
|
+
/** @readonly */
|
|
11
|
+
map: require('./map/main.f.cjs'),
|
|
12
|
+
/** @readonly */
|
|
13
|
+
object: require('./object/main.f.cjs'),
|
|
14
|
+
/** @readonly */
|
|
15
|
+
range: require('./range/main.f.cjs'),
|
|
16
|
+
/** @readonly */
|
|
17
|
+
result: require('./result/main.f.cjs'),
|
|
18
|
+
/** @readonly */
|
|
19
|
+
stringSet: require('./stringset/main.f.cjs'),
|
|
20
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const btTypes = require('../btree/types/main.f.
|
|
2
|
-
const btree = require('../btree/main.f.
|
|
3
|
-
const { values } = require("../btree/main.f.
|
|
4
|
-
const find = require('../btree/find/main.f.
|
|
5
|
-
const s = require('../btree/set/main.f.
|
|
6
|
-
const compare = require('../function/compare/main.f.
|
|
7
|
-
const { stringCmp } = require('../function/compare/main.f.
|
|
8
|
-
const list = require('../list/main.f.
|
|
9
|
-
const btRemove = require('../btree/remove/main.f.
|
|
1
|
+
const btTypes = require('../btree/types/main.f.cjs')
|
|
2
|
+
const btree = require('../btree/main.f.cjs')
|
|
3
|
+
const { values } = require("../btree/main.f.cjs")
|
|
4
|
+
const find = require('../btree/find/main.f.cjs')
|
|
5
|
+
const s = require('../btree/set/main.f.cjs')
|
|
6
|
+
const compare = require('../function/compare/main.f.cjs')
|
|
7
|
+
const { stringCmp } = require('../function/compare/main.f.cjs')
|
|
8
|
+
const list = require('../list/main.f.cjs')
|
|
9
|
+
const btRemove = require('../btree/remove/main.f.cjs')
|
|
10
10
|
|
|
11
11
|
/** @typedef {compare.Sign} Sign */
|
|
12
12
|
|