functionalscript 0.0.422 → 0.0.425
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 +1 -1
- package/.github/workflows/deno.yml +1 -1
- package/com/cpp/test/build.cjs +1 -1
- package/com/cpp/{test.f.cjs → testlib.f.cjs} +1 -1
- package/com/cs/test/build.cjs +1 -1
- package/com/cs/{test.f.cjs → testlib.f.cjs} +1 -1
- package/com/rust/test.f.cjs +2 -4
- package/com/types/{test.f.cjs → testlib.f.cjs} +0 -0
- package/commonjs/build/test.f.cjs +2 -4
- package/commonjs/package/dependencies/test.f.cjs +1 -3
- package/commonjs/package/test.f.cjs +1 -5
- package/commonjs/path/test.f.cjs +158 -170
- package/commonjs/test.cjs +52 -61
- package/html/test.f.cjs +12 -13
- package/json/test.f.cjs +41 -37
- package/json/tokenizer/test.f.cjs +238 -296
- package/nodejs/version/test.f.cjs +1 -3
- package/package.json +2 -2
- package/sha2/test.f.cjs +37 -40
- package/test.f.cjs +49 -86
- package/test.mjs +142 -0
- package/text/test.f.cjs +1 -3
- package/text/utf16/test.f.cjs +96 -109
- package/text/utf8/test.f.cjs +116 -135
- package/tsconfig.json +1 -1
- package/types/array/test.f.cjs +83 -85
- package/types/bigint/test.f.cjs +6 -6
- package/types/btree/find/test.f.cjs +2 -2
- package/types/btree/remove/test.f.cjs +6 -3
- package/types/btree/set/test.f.cjs +372 -370
- package/types/btree/test.f.cjs +11 -7
- package/types/byteSet/module.f.cjs +2 -4
- package/types/byteSet/test.f.cjs +37 -40
- package/types/function/compare/module.f.cjs +1 -1
- package/types/function/compare/test.f.cjs +1 -3
- package/types/function/test.f.cjs +1 -3
- package/types/list/test.f.cjs +208 -219
- package/types/map/test.f.cjs +57 -57
- package/types/nibbleSet/test.f.cjs +37 -40
- package/types/number/test.f.cjs +24 -26
- package/types/object/test.f.cjs +12 -13
- package/types/option/test.f.cjs +1 -3
- package/types/range/test.f.cjs +1 -3
- package/types/string/test.f.cjs +37 -40
- package/types/stringset/test.f.cjs +32 -33
- package/denotest.mjs +0 -96
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
4
|
-
if (_.has(0)(_.empty)) { throw _.empty }
|
|
5
|
-
if (_.has(1)(_.empty)) { throw _.empty }
|
|
6
|
-
if (_.has(15)(_.empty)) { throw _.empty }
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
const s = _.set(0)(_.empty)
|
|
11
|
-
if (s !== 1) { throw s }
|
|
12
|
-
if (!_.has(0)(s)) { throw s }
|
|
13
|
-
if (_.has(1)(s)) { throw s }
|
|
14
|
-
if (_.has(15)(s)) { throw s }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
const s = _.set(15)(_.empty)
|
|
19
|
-
if (s !== 32768) { throw s }
|
|
20
|
-
if (_.has(0)(s)) { throw s }
|
|
21
|
-
if (_.has(1)(s)) { throw s }
|
|
22
|
-
if (!_.has(15)(s)) { throw s }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
const a = _.set(0)(_.empty)
|
|
27
|
-
const result = _.unset(0)(a)
|
|
28
|
-
if (result !== 0) { throw result }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
const a = _.set(15)(_.empty)
|
|
33
|
-
const result = _.unset(15)(a)
|
|
34
|
-
if (result !== 0) { throw result }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
const result = _.setRange([2, 5])(_.empty)
|
|
39
|
-
if (result !== 60) { throw result }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
3
|
module.exports = {
|
|
43
|
-
|
|
4
|
+
has: () => {
|
|
5
|
+
if (_.has(0)(_.empty)) { throw _.empty }
|
|
6
|
+
if (_.has(1)(_.empty)) { throw _.empty }
|
|
7
|
+
if (_.has(15)(_.empty)) { throw _.empty }
|
|
8
|
+
},
|
|
9
|
+
set: [
|
|
10
|
+
() => {
|
|
11
|
+
const s = _.set(0)(_.empty)
|
|
12
|
+
if(s !== 1) { throw s }
|
|
13
|
+
if(!_.has(0)(s)) { throw s }
|
|
14
|
+
if (_.has(1)(s)) { throw s }
|
|
15
|
+
if (_.has(15)(s)) { throw s }
|
|
16
|
+
},
|
|
17
|
+
() => {
|
|
18
|
+
const s = _.set(15)(_.empty)
|
|
19
|
+
if (s !== 32768) { throw s }
|
|
20
|
+
if (_.has(0)(s)) { throw s }
|
|
21
|
+
if (_.has(1)(s)) { throw s }
|
|
22
|
+
if (!_.has(15)(s)) { throw s }
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
unset: () => [
|
|
26
|
+
() => {
|
|
27
|
+
const a = _.set(0)(_.empty)
|
|
28
|
+
const result = _.unset(0)(a)
|
|
29
|
+
if (result !== 0) { throw result }
|
|
30
|
+
},
|
|
31
|
+
() => {
|
|
32
|
+
const a = _.set(15)(_.empty)
|
|
33
|
+
const result = _.unset(15)(a)
|
|
34
|
+
if (result !== 0) { throw result }
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
setRange: () => {
|
|
38
|
+
const result = _.setRange([2, 5])(_.empty)
|
|
39
|
+
if (result !== 60) { throw result }
|
|
40
|
+
}
|
|
44
41
|
}
|
package/types/number/test.f.cjs
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
const { sum, min, max, cmp } = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = {}
|
|
3
|
+
module.exports = {
|
|
4
|
+
sum: () => {
|
|
5
|
+
const result = sum([2, 3, 4, 5])
|
|
6
|
+
if (result !== 14) { throw result }
|
|
7
|
+
},
|
|
8
|
+
min: {
|
|
9
|
+
empty: () => {
|
|
10
|
+
const result = min([])
|
|
11
|
+
if (result !== undefined) { throw result }
|
|
12
|
+
},
|
|
13
|
+
multi: () => {
|
|
14
|
+
const result = min([1, 2, 12, -4, 8])
|
|
15
|
+
if (result !== -4) { throw result }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
max: () => {
|
|
19
|
+
const result = max([1, 2, 12, -4, 8])
|
|
20
|
+
if (result !== 12) { throw result }
|
|
21
|
+
},
|
|
22
|
+
cmp: () => {
|
|
23
|
+
const result = cmp(4)(5)
|
|
24
|
+
if (result !== -1) { throw result }
|
|
25
|
+
}
|
|
26
|
+
}
|
package/types/object/test.f.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = {}
|
|
3
|
+
module.exports = {
|
|
4
|
+
ctor: () => {
|
|
5
|
+
const a = {}
|
|
6
|
+
const value = _.at('constructor')(a)
|
|
7
|
+
if (value !== undefined) { throw value }
|
|
8
|
+
},
|
|
9
|
+
property: () => {
|
|
10
|
+
const a = { constructor: 42 }
|
|
11
|
+
const value = _.at('constructor')(a)
|
|
12
|
+
if (value !== 42) { throw value }
|
|
13
|
+
}
|
|
14
|
+
}
|
package/types/option/test.f.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
4
4
|
const optionSq = _.map(v => v * v)
|
|
5
5
|
const sq3 = optionSq(3)
|
|
6
6
|
if (sq3 !== 9) { throw sq3 }
|
|
7
7
|
const sqUndefined = optionSq(undefined)
|
|
8
8
|
if (sqUndefined !== undefined) { throw sqUndefined }
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
module.exports = {}
|
package/types/range/test.f.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
4
4
|
if (!_.contains([0, 5])(1)) { throw 1 }
|
|
5
5
|
if (!_.contains([0, 5])(0)) { throw 0 }
|
|
6
6
|
if (!_.contains([0, 5])(5)) { throw 5 }
|
|
7
7
|
if (_.contains([0, 5])(-1)) { throw -1 }
|
|
8
8
|
if (_.contains([0, 5])(6)) { throw 6 }
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
module.exports = {}
|
package/types/string/test.f.cjs
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
const { join, concat, repeat, cmp } = require('./module.f.cjs')
|
|
2
2
|
const { repeat: repeatList } = require('../list/module.f.cjs')
|
|
3
3
|
|
|
4
|
-
{
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
module.exports = {
|
|
5
|
+
join: {
|
|
6
|
+
0: () => {
|
|
7
|
+
const result = join('/')([])
|
|
8
|
+
if (result !== '') { throw result }
|
|
9
|
+
},
|
|
10
|
+
1: () => {
|
|
11
|
+
const result = join('/')([''])
|
|
12
|
+
if (result !== '') { throw result }
|
|
13
|
+
},
|
|
14
|
+
3: () => {
|
|
15
|
+
const result = join(' ')(['hello', 'world', '!'])
|
|
16
|
+
if (result !== 'hello world !') { throw result }
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
concat: () => {
|
|
20
|
+
const result = concat(['hello', 'world'])
|
|
21
|
+
if (result !== 'helloworld') { throw result }
|
|
22
|
+
},
|
|
23
|
+
repeatList: {
|
|
24
|
+
0: () => {
|
|
25
|
+
const s = join('.')(repeatList('x')(0))
|
|
26
|
+
if (s != '') { throw s }
|
|
27
|
+
},
|
|
28
|
+
5: () => {
|
|
29
|
+
const s = join('.')(repeatList('x')(5))
|
|
30
|
+
if (s != 'x.x.x.x.x') { throw s }
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
repeat: () => {
|
|
34
|
+
const s = repeat('x')(5)
|
|
35
|
+
if(s != 'xxxxx') { throw s }
|
|
36
|
+
},
|
|
37
|
+
cmp: () => {
|
|
38
|
+
const result = cmp('3')('4')
|
|
39
|
+
if (result !== -1) { throw result }
|
|
40
|
+
}
|
|
7
41
|
}
|
|
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
|
-
{
|
|
40
|
-
const result = cmp('3')('4')
|
|
41
|
-
if (result !== -1) { throw result }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = {}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = {}
|
|
3
|
+
module.exports = {
|
|
4
|
+
contains: () => {
|
|
5
|
+
const r = _.set('hello')(undefined)
|
|
6
|
+
if (!_.contains('hello')(r)) { throw r }
|
|
7
|
+
if (_.contains('hello1')(r)) { throw r }
|
|
8
|
+
},
|
|
9
|
+
remove: () => {
|
|
10
|
+
let r = _.set('hello')(undefined)
|
|
11
|
+
r = _.set('world')(r)
|
|
12
|
+
r = _.set('HELLO')(r)
|
|
13
|
+
r = _.set('WORLD!')(r)
|
|
14
|
+
if (!_.contains('hello')(r)) { throw r }
|
|
15
|
+
if (_.contains('hello1')(r)) { throw r }
|
|
16
|
+
if (!_.contains('HELLO')(r)) { throw r }
|
|
17
|
+
if (_.contains('WORLD')(r)) { throw r }
|
|
18
|
+
if (!_.contains('world')(r)) { throw r }
|
|
19
|
+
if (_.contains('world!')(r)) { throw r }
|
|
20
|
+
if (!_.contains('WORLD!')(r)) { throw r }
|
|
21
|
+
//
|
|
22
|
+
r = _.remove('hello')(r)
|
|
23
|
+
if (_.contains('hello')(r)) { throw r }
|
|
24
|
+
if (!_.contains('world')(r)) { throw r }
|
|
25
|
+
r = _.remove('world')(r)
|
|
26
|
+
if (_.contains('world')(r)) { throw r }
|
|
27
|
+
if (!_.contains('HELLO')(r)) { throw r }
|
|
28
|
+
r = _.remove('HELLO')(r)
|
|
29
|
+
if (_.contains('HELLO')(r)) { throw r }
|
|
30
|
+
if (!_.contains('WORLD!')(r)) { throw r }
|
|
31
|
+
r = _.remove('WORLD!')(r)
|
|
32
|
+
if (r !== undefined) { throw r }
|
|
33
|
+
}
|
|
34
|
+
}
|
package/denotest.mjs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// import * as fs from "https://deno.land/std/node/fs.ts"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @type {{
|
|
5
|
-
* readonly readDir: (path: string | URL) => AsyncIterable<DirEntry>,
|
|
6
|
-
* readonly readTextFile: (path: string | URL) => Promise<string>,
|
|
7
|
-
* }}
|
|
8
|
-
*/
|
|
9
|
-
const {
|
|
10
|
-
readDir,
|
|
11
|
-
readTextFile,
|
|
12
|
-
} = Deno
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {{
|
|
16
|
-
* readonly isDirectory: boolean
|
|
17
|
-
* readonly isFile: boolean
|
|
18
|
-
* readonly isSymlink: boolean
|
|
19
|
-
* readonly name: string
|
|
20
|
-
* }} DirEntry
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** @typedef {{ exports?: unknown }} Module */
|
|
24
|
-
|
|
25
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {{
|
|
29
|
-
* [k in string]: Function
|
|
30
|
-
* }} FunctionMap
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/** @type {(path: string) => Promise<FunctionMap>} */
|
|
34
|
-
const dir = async p => {
|
|
35
|
-
/** @type {FunctionMap} */
|
|
36
|
-
const map = {}
|
|
37
|
-
/** @type {(path: string) => Promise<void>} */
|
|
38
|
-
const f = async p => {
|
|
39
|
-
for await (const i of readDir(p)) {
|
|
40
|
-
const { name } = i
|
|
41
|
-
if (!name.startsWith('.')) {
|
|
42
|
-
const file = `${p}/${name}`
|
|
43
|
-
if (i.isDirectory) {
|
|
44
|
-
if (!['node_modules', 'target'].includes(name)) {
|
|
45
|
-
await f(file)
|
|
46
|
-
}
|
|
47
|
-
} else if (name.endsWith('.f.cjs')) {
|
|
48
|
-
console.log(`loading ${file}`)
|
|
49
|
-
const source = await readTextFile(file)
|
|
50
|
-
map[file] = Function('module', 'require', `"use strict";${source}`)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
await f(p)
|
|
56
|
-
return map
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @typedef {{
|
|
61
|
-
* [k in string]: unknown
|
|
62
|
-
* }} ModuleMap
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
const run = async () => {
|
|
66
|
-
const m = await dir('.')
|
|
67
|
-
/** @type {ModuleMap} */
|
|
68
|
-
const d = {}
|
|
69
|
-
/** @type {(base: readonly string[]) => (i: string) => (k: string) => unknown} */
|
|
70
|
-
const req = p => i => k => {
|
|
71
|
-
const relativePath = k.split('/')
|
|
72
|
-
const dif = relativePath.filter(v => v === '..').length
|
|
73
|
-
const path = [p.slice(0, p.length - dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
74
|
-
.flat()
|
|
75
|
-
const pathStr = path.join('/')
|
|
76
|
-
const newBase = path.slice(0, path.length - 1)
|
|
77
|
-
const result = d[pathStr]
|
|
78
|
-
if (result === undefined) {
|
|
79
|
-
/** @type {Module} */
|
|
80
|
-
const me = {}
|
|
81
|
-
console.log(`${i}building ${pathStr}`)
|
|
82
|
-
m[pathStr](me, req(newBase)(`${i}| `))
|
|
83
|
-
const newResult = me.exports
|
|
84
|
-
d[pathStr] = newResult
|
|
85
|
-
return newResult
|
|
86
|
-
} else {
|
|
87
|
-
return result
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const r = req(['.'])('')
|
|
91
|
-
for (const k of Object.keys(m)) {
|
|
92
|
-
r(k)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
run()
|