functionalscript 0.0.392 → 0.0.395
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/cpp/module.f.cjs +2 -1
- package/com/cpp/test/build.cjs +2 -2
- package/com/cpp/test.f.cjs +3 -3
- package/com/cs/module.f.cjs +3 -2
- package/com/cs/test.f.cjs +2 -3
- package/commonjs/path/module.f.cjs +2 -1
- package/html/module.f.cjs +4 -3
- package/json/module.f.cjs +3 -2
- package/package.json +1 -1
- package/test.f.cjs +3 -0
- package/text/test.f.cjs +2 -2
- package/types/bigint/module.f.cjs +10 -0
- package/types/bigint/test.f.cjs +8 -0
- package/types/function/operator/module.f.cjs +11 -11
- package/types/list/module.f.cjs +8 -31
- package/types/list/test.f.cjs +0 -45
- package/types/module.f.cjs +7 -1
- package/types/number/module.f.cjs +17 -0
- package/types/number/test.f.cjs +23 -0
- package/types/string/module.f.cjs +24 -0
- package/types/string/test.f.cjs +39 -0
package/com/cpp/module.f.cjs
CHANGED
|
@@ -3,7 +3,8 @@ const { paramList } = types
|
|
|
3
3
|
const text = require('../../text/module.f.cjs')
|
|
4
4
|
const obj = require('../../types/object/module.f.cjs')
|
|
5
5
|
const list = require('../../types/list/module.f.cjs')
|
|
6
|
-
const { map,
|
|
6
|
+
const { map, flatMap } = list
|
|
7
|
+
const { join } = require('../../types/string/module.f.cjs')
|
|
7
8
|
const { entries } = Object
|
|
8
9
|
|
|
9
10
|
/** @type {(name: string) => (body: text.Block) => text.Block} */
|
package/com/cpp/test/build.cjs
CHANGED
|
@@ -2,12 +2,12 @@ const fs = require('node:fs')
|
|
|
2
2
|
const cp = require('node:child_process')
|
|
3
3
|
const os = require('node:os');
|
|
4
4
|
const cpp = require('../test.f.cjs').result
|
|
5
|
-
const list = require('../../../types/
|
|
5
|
+
const { string: { join }, list: { flat } } = require('../../../types/module.f.cjs')
|
|
6
6
|
|
|
7
7
|
fs.writeFileSync('_result.hpp', cpp)
|
|
8
8
|
try {
|
|
9
9
|
const flags = os.platform() === 'win32' ? [] : ['-std=c++11', '-lc++']
|
|
10
|
-
const line =
|
|
10
|
+
const line = join(' ')(flat([['clang'], flags, ['main.cpp']]))
|
|
11
11
|
console.log(cp.execSync(line).toString())
|
|
12
12
|
} catch (e) {
|
|
13
13
|
// @ts-ignore
|
package/com/cpp/test.f.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const library = require('../types/test.f.cjs')
|
|
3
3
|
const text = require('../../text/module.f.cjs')
|
|
4
|
-
const
|
|
4
|
+
const { join } = require('../../types/module.f.cjs').string
|
|
5
5
|
|
|
6
6
|
const f = () =>
|
|
7
7
|
{
|
|
8
|
-
const r =
|
|
9
|
-
const e =
|
|
8
|
+
const r = join('\n')(text.flat(' ')(_.cpp('My')(library)))
|
|
9
|
+
const e =
|
|
10
10
|
'#pragma once\n' +
|
|
11
11
|
'\n' +
|
|
12
12
|
'namespace My\n' +
|
package/com/cs/module.f.cjs
CHANGED
|
@@ -3,7 +3,8 @@ const { result, paramList } = types
|
|
|
3
3
|
const text = require('../../text/module.f.cjs')
|
|
4
4
|
const { curly } = text
|
|
5
5
|
const list = require('../../types/list/module.f.cjs')
|
|
6
|
-
const { flat, map, some,
|
|
6
|
+
const { flat, map, some, flatMap } = list
|
|
7
|
+
const { join } = require('../../types/string/module.f.cjs')
|
|
7
8
|
const obj = require('../../types/object/module.f.cjs')
|
|
8
9
|
const { entries } = Object
|
|
9
10
|
|
|
@@ -36,7 +37,7 @@ const baseTypeMap = {
|
|
|
36
37
|
u32: 'uint',
|
|
37
38
|
u64: 'ulong',
|
|
38
39
|
u8: 'byte',
|
|
39
|
-
usize: 'UIntPtr',
|
|
40
|
+
usize: 'UIntPtr',
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/** @type {(t: types.BaseType) => string} */
|
package/com/cs/test.f.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const types = require('../types/module.f.cjs')
|
|
2
1
|
const _ = require('./module.f.cjs')
|
|
3
|
-
const list = require('../../types/list/module.f.cjs')
|
|
4
2
|
const text = require('../../text/module.f.cjs')
|
|
5
3
|
const library = require('../types/test.f.cjs')
|
|
4
|
+
const { join } = require('../../types/string/module.f.cjs')
|
|
6
5
|
|
|
7
6
|
const f = () =>
|
|
8
7
|
{
|
|
9
|
-
const cs =
|
|
8
|
+
const cs = join('\n')(text.flat(' ')(_.cs('My')(library)))
|
|
10
9
|
const e =
|
|
11
10
|
'using System;\n' +
|
|
12
11
|
'using System.Runtime.InteropServices;\n' +
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const list = require("../../types/list/module.f.cjs")
|
|
2
|
-
const { next, reduce, reverse, first, flat, toArray, filterMap, isEmpty, concat
|
|
2
|
+
const { next, reduce, reverse, first, flat, toArray, filterMap, isEmpty, concat } = list
|
|
3
|
+
const { join } = require('../../types/string/module.f.cjs')
|
|
3
4
|
const package_ = require("../package/module.f.cjs")
|
|
4
5
|
const module_ = require("../module/module.f.cjs")
|
|
5
6
|
|
package/html/module.f.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const list = require('../types/list/module.f.cjs')
|
|
2
|
-
const { map, flatMap, flat, concat
|
|
2
|
+
const { map, flatMap, flat, concat: listConcat } = list
|
|
3
|
+
const { concat: stringConcat } = require('../types/string/module.f.cjs')
|
|
3
4
|
const object = require('../types/object/module.f.cjs')
|
|
4
5
|
const { compose } = require('../types/function/module.f.cjs')
|
|
5
6
|
const encoding = require('../text/encoding/module.f.cjs');
|
|
@@ -112,9 +113,9 @@ const element = e => {
|
|
|
112
113
|
return flat(f())
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const html = compose(element)(
|
|
116
|
+
const html = compose(element)(listConcat(['<!DOCTYPE html>']))
|
|
116
117
|
|
|
117
|
-
const htmlToString = compose(html)(
|
|
118
|
+
const htmlToString = compose(html)(stringConcat)
|
|
118
119
|
|
|
119
120
|
module.exports = {
|
|
120
121
|
/** @readonly */
|
package/json/module.f.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const list = require('../types/list/module.f.cjs')
|
|
2
|
-
const { next, flat, fold, map
|
|
2
|
+
const { next, flat, fold, map } = list
|
|
3
|
+
const { concat } = require('../types/string/module.f.cjs')
|
|
3
4
|
const object = require('../types/object/module.f.cjs')
|
|
4
5
|
const { at } = object
|
|
5
6
|
const operator = require('../types/function/operator/module.f.cjs')
|
|
@@ -108,7 +109,7 @@ const serialize = sort => {
|
|
|
108
109
|
*
|
|
109
110
|
* @type {(mapEntries: MapEntries) => (value: Unknown) => string}
|
|
110
111
|
*/
|
|
111
|
-
const stringify = sort => compose(serialize(sort))(
|
|
112
|
+
const stringify = sort => compose(serialize(sort))(concat)
|
|
112
113
|
|
|
113
114
|
/** @type {(value: string) => Unknown} */
|
|
114
115
|
const parse = JSON.parse
|
package/package.json
CHANGED
package/test.f.cjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const i = require('./module.f.cjs')
|
|
2
2
|
|
|
3
3
|
require('./types/list/test.f.cjs')
|
|
4
|
+
require('./types/number/test.f.cjs')
|
|
5
|
+
require('./types/bigint/module.f.cjs')
|
|
4
6
|
require('./types/array/test.f.cjs')
|
|
5
7
|
require('./types/btree/test.f.cjs')
|
|
6
8
|
require('./sha2/test.f.cjs')
|
|
7
9
|
require('./json/test.f.cjs')
|
|
10
|
+
require('./types/string/test.f.cjs')
|
|
8
11
|
require('./json/tokenizer/test.f.cjs')
|
|
9
12
|
require('./types/object/test.f.cjs')
|
|
10
13
|
require('./commonjs/test.cjs')
|
package/text/test.f.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
|
-
const
|
|
2
|
+
const { string: { join } } = require('../types/module.f.cjs')
|
|
3
3
|
|
|
4
4
|
{
|
|
5
5
|
/** @type {_.Block} */
|
|
@@ -12,7 +12,7 @@ const list = require('../types/list/module.f.cjs')
|
|
|
12
12
|
],
|
|
13
13
|
'e',
|
|
14
14
|
]
|
|
15
|
-
const result =
|
|
15
|
+
const result = join('\n')(_.flat(':')(text))
|
|
16
16
|
if (result !== 'a\nb\n:c\n::d\ne') { throw result }
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -16,11 +16,6 @@ const join = separator => value => prior => `${prior}${separator}${value}`
|
|
|
16
16
|
/** @type {Fold<string>} */
|
|
17
17
|
const concat = i => acc => `${acc}${i}`
|
|
18
18
|
|
|
19
|
-
/** @type {Fold<number>} */
|
|
20
|
-
const addition = a => b => a + b
|
|
21
|
-
|
|
22
|
-
const increment = addition(1)
|
|
23
|
-
|
|
24
19
|
/**
|
|
25
20
|
* @template T
|
|
26
21
|
* @template R
|
|
@@ -38,12 +33,6 @@ const logicalNot = v => !v
|
|
|
38
33
|
/** @type {<T>(a: T) => (b: T) => boolean} */
|
|
39
34
|
const strictEqual = a => b => a === b
|
|
40
35
|
|
|
41
|
-
/** @type {Fold<number>} */
|
|
42
|
-
const min = a => b => a < b ? a : b
|
|
43
|
-
|
|
44
|
-
/** @type {Fold<number>} */
|
|
45
|
-
const max = a => b => a > b ? a : b
|
|
46
|
-
|
|
47
36
|
/**
|
|
48
37
|
* @template I,O
|
|
49
38
|
* @typedef {(input: I) => readonly[O, Scan<I,O>]} Scan
|
|
@@ -74,6 +63,17 @@ const reduceToScan = reduce => prior => i => {
|
|
|
74
63
|
/** @type {<T>(fold: Fold<T>) => Scan<T, T>} */
|
|
75
64
|
const foldToScan = op => init => [init, reduceToScan(op)(init)]
|
|
76
65
|
|
|
66
|
+
/** @type {Fold<number>} */
|
|
67
|
+
const addition = a => b => a + b
|
|
68
|
+
|
|
69
|
+
/** @type {Fold<number>} */
|
|
70
|
+
const min = a => b => a < b ? a : b
|
|
71
|
+
|
|
72
|
+
/** @type {Fold<number>} */
|
|
73
|
+
const max = a => b => a > b ? a : b
|
|
74
|
+
|
|
75
|
+
const increment = addition(1)
|
|
76
|
+
|
|
77
77
|
const counter = () => increment
|
|
78
78
|
|
|
79
79
|
module.exports = {
|
package/types/list/module.f.cjs
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
const { compose, identity } = require('../function/module.f.cjs')
|
|
2
2
|
const operator = require('../function/operator/module.f.cjs')
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
max: maxOp,
|
|
7
|
-
join: joinOp,
|
|
8
|
-
concat: concatOp,
|
|
3
|
+
const {
|
|
4
|
+
join: joinOp,
|
|
5
|
+
concat: concatOp,
|
|
9
6
|
counter,
|
|
10
|
-
logicalNot,
|
|
11
|
-
strictEqual,
|
|
12
|
-
stateScanToScan,
|
|
13
|
-
reduceToScan,
|
|
14
|
-
foldToScan
|
|
7
|
+
logicalNot,
|
|
8
|
+
strictEqual,
|
|
9
|
+
stateScanToScan,
|
|
10
|
+
reduceToScan,
|
|
11
|
+
foldToScan
|
|
15
12
|
} = operator
|
|
16
13
|
|
|
17
14
|
/**
|
|
@@ -264,16 +261,6 @@ const reduce = op => init => input => last(init)(reduceScan(op)(init)(input))
|
|
|
264
261
|
/** @type {<T>(op: operator.Fold<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
265
262
|
const fold = op => def => input => last(def)(scan(foldToScan(op))(input))
|
|
266
263
|
|
|
267
|
-
const sum = fold(addition)(0)
|
|
268
|
-
|
|
269
|
-
const min = fold(minOp)(undefined)
|
|
270
|
-
|
|
271
|
-
const max = fold(maxOp)(undefined)
|
|
272
|
-
|
|
273
|
-
/** @type {(separator: string) => (input: List<string>) => string} */
|
|
274
|
-
const join = separator => fold(joinOp(separator))('')
|
|
275
|
-
|
|
276
|
-
const stringConcat = fold(concatOp)('')
|
|
277
264
|
|
|
278
265
|
/** @type {<T>(input: List<T>) => number} */
|
|
279
266
|
const length = reduce(counter)(0)
|
|
@@ -380,16 +367,6 @@ module.exports = {
|
|
|
380
367
|
/** @readonly */
|
|
381
368
|
fold,
|
|
382
369
|
/** @readonly */
|
|
383
|
-
sum,
|
|
384
|
-
/** @readonly */
|
|
385
|
-
min,
|
|
386
|
-
/** @readonly */
|
|
387
|
-
max,
|
|
388
|
-
/** @readonly */
|
|
389
|
-
join,
|
|
390
|
-
/** @readonly */
|
|
391
|
-
stringConcat,
|
|
392
|
-
/** @readonly */
|
|
393
370
|
length,
|
|
394
371
|
/** @readonly */
|
|
395
372
|
entries,
|
package/types/list/test.f.cjs
CHANGED
|
@@ -99,11 +99,6 @@ const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
|
99
99
|
if (result !== '[2,5,9,14]') { throw result }
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
{
|
|
103
|
-
const result = _.sum([2, 3, 4, 5])
|
|
104
|
-
if (result !== 14) { throw result }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
102
|
{
|
|
108
103
|
const result = _.fold(addition)(undefined)([2, 3, 4, 5])
|
|
109
104
|
if (result !== 14) { throw result }
|
|
@@ -114,21 +109,6 @@ const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
|
114
109
|
if (result !== undefined) { throw result }
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
{
|
|
118
|
-
const result = _.join('/')([])
|
|
119
|
-
if (result !== '') { throw result }
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
const result = _.join('/')([''])
|
|
124
|
-
if (result !== '') { throw result }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
const result = _.join(' ')(['hello', 'world', '!'])
|
|
129
|
-
if (result !== 'hello world !') { throw result }
|
|
130
|
-
}
|
|
131
|
-
|
|
132
112
|
{
|
|
133
113
|
const result = stringify(_.entries([]))
|
|
134
114
|
if (result !== '[]') { throw result }
|
|
@@ -211,21 +191,6 @@ const map5 = _.map(x => x > 5)
|
|
|
211
191
|
if (!result) { throw result }
|
|
212
192
|
}
|
|
213
193
|
|
|
214
|
-
{
|
|
215
|
-
const result = _.min([])
|
|
216
|
-
if (result !== undefined) { throw result }
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
const result = _.min([1, 2, 12, -4, 8])
|
|
221
|
-
if (result !== -4) { throw result }
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
{
|
|
225
|
-
const result = _.max([1, 2, 12, -4, 8])
|
|
226
|
-
if (result !== 12) { throw result }
|
|
227
|
-
}
|
|
228
|
-
|
|
229
194
|
{
|
|
230
195
|
const result = _.isEmpty(() => [])
|
|
231
196
|
if (result !== true) { throw result }
|
|
@@ -352,16 +317,6 @@ const stress = () => {
|
|
|
352
317
|
}
|
|
353
318
|
}
|
|
354
319
|
|
|
355
|
-
{
|
|
356
|
-
const s = _.join('.')(_.repeat('x')(0))
|
|
357
|
-
if (s != '') { throw s }
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
{
|
|
361
|
-
const s = _.join('.')(_.repeat('x')(5))
|
|
362
|
-
if (s != 'x.x.x.x.x') { throw s }
|
|
363
|
-
}
|
|
364
|
-
|
|
365
320
|
// stress()
|
|
366
321
|
|
|
367
322
|
module.exports = {
|
package/types/module.f.cjs
CHANGED
|
@@ -16,5 +16,11 @@ module.exports = {
|
|
|
16
16
|
/** @readonly */
|
|
17
17
|
result: require('./result/module.f.cjs'),
|
|
18
18
|
/** @readonly */
|
|
19
|
-
|
|
19
|
+
string_set: require('./string_set/module.f.cjs'),
|
|
20
|
+
/** @readonly */
|
|
21
|
+
bigint: require('./bigint/module.f.cjs'),
|
|
22
|
+
/** @readonly */
|
|
23
|
+
number: require('./number/module.f.cjs'),
|
|
24
|
+
/** @readonly */
|
|
25
|
+
string: require('./string/module.f.cjs'),
|
|
20
26
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { fold } = require('../list/module.f.cjs')
|
|
2
|
+
const { addition, min: minOp, max: maxOp } = require('../function/operator/module.f.cjs')
|
|
3
|
+
|
|
4
|
+
const sum = fold(addition)(0)
|
|
5
|
+
|
|
6
|
+
const min = fold(minOp)(undefined)
|
|
7
|
+
|
|
8
|
+
const max = fold(maxOp)(undefined)
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
/** @readonly */
|
|
12
|
+
sum,
|
|
13
|
+
/** @readonly */
|
|
14
|
+
min,
|
|
15
|
+
/** @readonly */
|
|
16
|
+
max,
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { sum, min, max } = require('./module.f.cjs')
|
|
2
|
+
|
|
3
|
+
{
|
|
4
|
+
const result = sum([2, 3, 4, 5])
|
|
5
|
+
if (result !== 14) { throw result }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
{
|
|
9
|
+
const result = min([])
|
|
10
|
+
if (result !== undefined) { throw result }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
const result = min([1, 2, 12, -4, 8])
|
|
15
|
+
if (result !== -4) { throw result }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
const result = max([1, 2, 12, -4, 8])
|
|
20
|
+
if (result !== 12) { throw result }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const list = require('../list/module.f.cjs')
|
|
2
|
+
const { fold: listFold, repeat: listRepeat } = list
|
|
3
|
+
const { compose } = require('../function/module.f.cjs')
|
|
4
|
+
const op = require('../function/operator/module.f.cjs')
|
|
5
|
+
const { join: joinOp, concat: concatOp } = op
|
|
6
|
+
|
|
7
|
+
/** @type {(o: op.Fold<string>) => (input: list.List<string>) => string} */
|
|
8
|
+
const fold = o => listFold(o)('')
|
|
9
|
+
|
|
10
|
+
const join = compose(joinOp)(fold)
|
|
11
|
+
|
|
12
|
+
const concat = fold(concatOp)
|
|
13
|
+
|
|
14
|
+
/** @type {(n: string) => (v: number) => string} */
|
|
15
|
+
const repeat = v => compose(listRepeat(v))(concat)
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
/** @readonly */
|
|
19
|
+
join,
|
|
20
|
+
/** @readonly */
|
|
21
|
+
concat,
|
|
22
|
+
/** @readonly */
|
|
23
|
+
repeat,
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const { join, concat, repeat } = require('./module.f.cjs')
|
|
2
|
+
const { repeat: repeatList } = require('../list/module.f.cjs')
|
|
3
|
+
|
|
4
|
+
{
|
|
5
|
+
const result = join('/')([])
|
|
6
|
+
if (result !== '') { throw result }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
const result = join('/')([''])
|
|
11
|
+
if (result !== '') { throw result }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
const result = join(' ')(['hello', 'world', '!'])
|
|
16
|
+
if (result !== 'hello world !') { throw result }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
const result = concat(['hello', 'world'])
|
|
21
|
+
if (result !== 'helloworld') { throw result }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
const s = join('.')(repeatList('x')(0))
|
|
26
|
+
if (s != '') { throw s }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
const s = join('.')(repeatList('x')(5))
|
|
31
|
+
if (s != 'x.x.x.x.x') { throw s }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
const s = repeat('x')(5)
|
|
36
|
+
if (s != 'xxxxx') { throw s }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {}
|