functionalscript 0.0.394 → 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 +1 -0
- package/text/test.f.cjs +2 -2
- package/types/list/module.f.cjs +0 -8
- package/types/list/test.f.cjs +0 -25
- package/types/module.f.cjs +2 -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
|
@@ -7,6 +7,7 @@ require('./types/array/test.f.cjs')
|
|
|
7
7
|
require('./types/btree/test.f.cjs')
|
|
8
8
|
require('./sha2/test.f.cjs')
|
|
9
9
|
require('./json/test.f.cjs')
|
|
10
|
+
require('./types/string/test.f.cjs')
|
|
10
11
|
require('./json/tokenizer/test.f.cjs')
|
|
11
12
|
require('./types/object/test.f.cjs')
|
|
12
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
|
|
package/types/list/module.f.cjs
CHANGED
|
@@ -261,10 +261,6 @@ const reduce = op => init => input => last(init)(reduceScan(op)(init)(input))
|
|
|
261
261
|
/** @type {<T>(op: operator.Fold<T>) => <D>(def: D) => (input: List<T>) => D|T} */
|
|
262
262
|
const fold = op => def => input => last(def)(scan(foldToScan(op))(input))
|
|
263
263
|
|
|
264
|
-
/** @type {(separator: string) => (input: List<string>) => string} */
|
|
265
|
-
const join = separator => fold(joinOp(separator))('')
|
|
266
|
-
|
|
267
|
-
const stringConcat = fold(concatOp)('')
|
|
268
264
|
|
|
269
265
|
/** @type {<T>(input: List<T>) => number} */
|
|
270
266
|
const length = reduce(counter)(0)
|
|
@@ -371,10 +367,6 @@ module.exports = {
|
|
|
371
367
|
/** @readonly */
|
|
372
368
|
fold,
|
|
373
369
|
/** @readonly */
|
|
374
|
-
join,
|
|
375
|
-
/** @readonly */
|
|
376
|
-
stringConcat,
|
|
377
|
-
/** @readonly */
|
|
378
370
|
length,
|
|
379
371
|
/** @readonly */
|
|
380
372
|
entries,
|
package/types/list/test.f.cjs
CHANGED
|
@@ -109,21 +109,6 @@ const stringify = sequence => json.stringify(sort)(_.toArray(sequence))
|
|
|
109
109
|
if (result !== undefined) { throw result }
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
{
|
|
113
|
-
const result = _.join('/')([])
|
|
114
|
-
if (result !== '') { throw result }
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
const result = _.join('/')([''])
|
|
119
|
-
if (result !== '') { throw result }
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
const result = _.join(' ')(['hello', 'world', '!'])
|
|
124
|
-
if (result !== 'hello world !') { throw result }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
112
|
{
|
|
128
113
|
const result = stringify(_.entries([]))
|
|
129
114
|
if (result !== '[]') { throw result }
|
|
@@ -332,16 +317,6 @@ const stress = () => {
|
|
|
332
317
|
}
|
|
333
318
|
}
|
|
334
319
|
|
|
335
|
-
{
|
|
336
|
-
const s = _.join('.')(_.repeat('x')(0))
|
|
337
|
-
if (s != '') { throw s }
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
{
|
|
341
|
-
const s = _.join('.')(_.repeat('x')(5))
|
|
342
|
-
if (s != 'x.x.x.x.x') { throw s }
|
|
343
|
-
}
|
|
344
|
-
|
|
345
320
|
// stress()
|
|
346
321
|
|
|
347
322
|
module.exports = {
|
package/types/module.f.cjs
CHANGED
|
@@ -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 = {}
|