functionalscript 0.0.429 → 0.0.431
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 +4 -2
- package/.github/workflows/deno.yml +4 -2
- package/.github/workflows/node-pack.yml +26 -0
- package/.github/workflows/node.js.yml +3 -1
- package/.github/workflows/npm-publish.yml +3 -3
- package/dev/test/module.f.cjs +70 -14
- package/dev/test.mjs +175 -0
- package/package.json +3 -3
- package/tsconfig.json +1 -1
- package/test.mjs +0 -174
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: bun
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
5
7
|
pull_request:
|
|
6
8
|
|
|
7
9
|
jobs:
|
|
@@ -12,4 +14,4 @@ jobs:
|
|
|
12
14
|
steps:
|
|
13
15
|
- uses: actions/checkout@v2
|
|
14
16
|
- run: curl https://bun.sh/install | bash
|
|
15
|
-
- run: /home/runner/.bun/bin/bun ./test.mjs
|
|
17
|
+
- run: /home/runner/.bun/bin/bun ./dev/test.mjs
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: deno
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
5
7
|
pull_request:
|
|
6
8
|
|
|
7
9
|
jobs:
|
|
@@ -14,4 +16,4 @@ jobs:
|
|
|
14
16
|
- uses: denoland/setup-deno@v1
|
|
15
17
|
with:
|
|
16
18
|
deno-version: v1.x
|
|
17
|
-
- run: deno run --allow-read --allow-env --allow-net ./test.mjs
|
|
19
|
+
- run: deno run --allow-read --allow-env --allow-net ./dev/test.mjs
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: node ci & pack
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
pull_request:
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v2
|
|
19
|
+
- name: Use Node.js
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
|
+
with:
|
|
22
|
+
node-version: 18
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm test
|
|
25
|
+
- run: npm run version
|
|
26
|
+
- run: npm pack
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
2
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
3
|
|
|
4
|
-
name:
|
|
4
|
+
name: node install
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
push:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
8
10
|
pull_request:
|
|
9
11
|
|
|
10
12
|
jobs:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
2
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
3
|
|
|
4
|
-
name:
|
|
4
|
+
name: node publish
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
push:
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
- uses: actions/checkout@v2
|
|
15
15
|
- uses: actions/setup-node@v2
|
|
16
16
|
with:
|
|
17
|
-
node-version:
|
|
17
|
+
node-version: 18
|
|
18
18
|
- run: npm ci
|
|
19
19
|
- run: npm test
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ jobs:
|
|
|
27
27
|
fetch-depth: 0
|
|
28
28
|
- uses: actions/setup-node@v2
|
|
29
29
|
with:
|
|
30
|
-
node-version:
|
|
30
|
+
node-version: 18
|
|
31
31
|
registry-url: https://registry.npmjs.org/
|
|
32
32
|
- run: npm ci
|
|
33
33
|
- run: npm run version
|
package/dev/test/module.f.cjs
CHANGED
|
@@ -1,19 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly[k in string]?: Module
|
|
4
|
+
* }} DependencyMap
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* readonly dependencyMap: DependencyMap
|
|
10
|
+
* readonly exports?: unknown
|
|
11
|
+
* }} Module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* readonly[k in string]: Module
|
|
17
|
+
* }} ModuleMap
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @template T
|
|
22
|
+
* @typedef {(v: string) => (state: T) => T} Log
|
|
23
|
+
*/
|
|
5
24
|
|
|
6
25
|
/**
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
26
|
+
* @template T
|
|
27
|
+
* @typedef {{
|
|
28
|
+
* readonly moduleMap: ModuleMap,
|
|
29
|
+
* readonly log: Log<T>,
|
|
30
|
+
* readonly state: T,
|
|
31
|
+
* }} Input
|
|
11
32
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
|
|
34
|
+
/** @type {<T>(input: Input<T>) => T} */
|
|
35
|
+
const main = ({moduleMap, log, state}) => {
|
|
36
|
+
/** @typedef {log extends Log<infer T> ? T : never} T */
|
|
37
|
+
/** @type {(i: string) => (v: unknown) => (state: T) => T} */
|
|
38
|
+
const test = i => v => state => {
|
|
39
|
+
const next = test(`${i}| `)
|
|
40
|
+
switch (typeof v) {
|
|
41
|
+
case 'function': {
|
|
42
|
+
if (v.length === 0) {
|
|
43
|
+
const r = v()
|
|
44
|
+
state = log(`${i}() passed`)(state)
|
|
45
|
+
state = next(r)(state)
|
|
46
|
+
}
|
|
47
|
+
break
|
|
48
|
+
}
|
|
49
|
+
case 'object': {
|
|
50
|
+
if (v instanceof Array) {
|
|
51
|
+
for (const v2 of v) {
|
|
52
|
+
state = next(v2)(state)
|
|
53
|
+
}
|
|
54
|
+
} else if (v !== null) {
|
|
55
|
+
for (const [k, v2] of Object.entries(v)) {
|
|
56
|
+
state = log(`${i}${k}:`)(state)
|
|
57
|
+
state = next(v2)(state)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
break
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return state
|
|
64
|
+
}
|
|
65
|
+
const next = test('| ')
|
|
66
|
+
for (const [k, v] of Object.entries(moduleMap)) {
|
|
67
|
+
if (k.endsWith('test.f.cjs')) {
|
|
68
|
+
state = log(`testing ${k}`)(state)
|
|
69
|
+
state = next(v.exports)(state)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return state
|
|
14
73
|
}
|
|
15
74
|
|
|
16
|
-
module.exports =
|
|
17
|
-
/** @readonly */
|
|
18
|
-
test,
|
|
19
|
-
}
|
|
75
|
+
module.exports = main
|
package/dev/test.mjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly withFileTypes: true
|
|
4
|
+
* }} Options
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* readonly name: string
|
|
10
|
+
* readonly isDirectory: () => boolean
|
|
11
|
+
* }} Dirent
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
+
* readonly readFile: (path: string, options: 'utf8') => Promise<string>
|
|
18
|
+
* }} FsPromises
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* [k in string]?: MutableModule
|
|
24
|
+
* }} MutableDependencyMap
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{
|
|
29
|
+
* dependencyMap: MutableDependencyMap
|
|
30
|
+
* exports?: unknown
|
|
31
|
+
* }} MutableModule
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {{
|
|
36
|
+
* readonly dependencyMap: DependencyMap
|
|
37
|
+
* readonly exports?: unknown
|
|
38
|
+
* }} Module
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {{
|
|
43
|
+
* readonly[k in string]?: Module
|
|
44
|
+
* }} DependencyMap
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @typedef {{
|
|
51
|
+
* readonly[k in string]: Function
|
|
52
|
+
* }} FunctionMap
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @template T
|
|
57
|
+
* @typedef {readonly[string, T]} Entry
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
61
|
+
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {{
|
|
65
|
+
* [k in string]: MutableModule
|
|
66
|
+
* }} MutableModuleMap
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @typedef {{
|
|
71
|
+
* readonly[k in string]: Module
|
|
72
|
+
* }} ModuleMap
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/** @type {(v: readonly string[]) => (dif: number) => readonly string[]} */
|
|
76
|
+
const remove_tail = v => dif => v.slice(0, v.length - dif)
|
|
77
|
+
|
|
78
|
+
/** @type {any} */
|
|
79
|
+
const self = globalThis
|
|
80
|
+
|
|
81
|
+
const boot = async() => {
|
|
82
|
+
/** @type {FsPromises} */
|
|
83
|
+
const { readdir, readFile } = await import(self.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
84
|
+
|
|
85
|
+
/** @type {() => Promise<FunctionMap>} */
|
|
86
|
+
const load = async () => {
|
|
87
|
+
/** @type {(readonly[string, Function])[]} */
|
|
88
|
+
const map = []
|
|
89
|
+
/** @type {(path: string) => Promise<void>} */
|
|
90
|
+
const f = async p => {
|
|
91
|
+
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
92
|
+
const { name } = i
|
|
93
|
+
if (!name.startsWith('.')) {
|
|
94
|
+
const file = `${p}/${name}`
|
|
95
|
+
if (i.isDirectory()) {
|
|
96
|
+
await f(file)
|
|
97
|
+
} else if (name.endsWith('.f.cjs')) {
|
|
98
|
+
const source = await readFile(file, 'utf8')
|
|
99
|
+
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
await f('.')
|
|
105
|
+
map.sort(cmp)
|
|
106
|
+
return Object.fromEntries(map)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const map = await load()
|
|
110
|
+
|
|
111
|
+
/** @type {() => ModuleMap} */
|
|
112
|
+
const build = () => {
|
|
113
|
+
/** @type {MutableModuleMap} */
|
|
114
|
+
const d = {}
|
|
115
|
+
/** @type {(base: readonly string[]) => (k: string) => readonly[string, MutableModule]} */
|
|
116
|
+
const getModule = base => k => {
|
|
117
|
+
const relativePath = k.split('/')
|
|
118
|
+
const dif = relativePath.filter(v => v === '..').length
|
|
119
|
+
const path = [remove_tail(base)(dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
120
|
+
.flat()
|
|
121
|
+
const pathStr = path.join('/')
|
|
122
|
+
{
|
|
123
|
+
const module = d[pathStr]
|
|
124
|
+
if (module !== undefined) {
|
|
125
|
+
return [pathStr, module]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
{
|
|
129
|
+
/** @type {MutableDependencyMap} */
|
|
130
|
+
const dependencyMap = {}
|
|
131
|
+
/** @type {MutableModule} */
|
|
132
|
+
const module = { dependencyMap }
|
|
133
|
+
const get = getModule(remove_tail(path)(1))
|
|
134
|
+
/** @type {(s: string) => unknown} */
|
|
135
|
+
const newReq = s => {
|
|
136
|
+
const [p, result] = get(s)
|
|
137
|
+
dependencyMap[p] = result
|
|
138
|
+
return result.exports
|
|
139
|
+
}
|
|
140
|
+
map[pathStr](module, newReq)
|
|
141
|
+
d[pathStr] = module
|
|
142
|
+
return [pathStr, module]
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
{
|
|
146
|
+
const get = getModule(['.'])
|
|
147
|
+
for (const k of Object.keys(map)) {
|
|
148
|
+
get(k)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return d
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return build()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// test runner.
|
|
158
|
+
const main = async() => {
|
|
159
|
+
const moduleMap = await boot()
|
|
160
|
+
|
|
161
|
+
/** @type {(s: string) => (_: undefined) => undefined} */
|
|
162
|
+
const log = s => state => {
|
|
163
|
+
console.log(s)
|
|
164
|
+
return state
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** @type {any} */
|
|
168
|
+
const f = moduleMap['./dev/test/module.f.cjs'].exports
|
|
169
|
+
f({
|
|
170
|
+
moduleMap,
|
|
171
|
+
log,
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
main()
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.431",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"test": "tsc && npm run test-only",
|
|
9
9
|
"version": "node ./nodejs/version/main.cjs",
|
|
10
|
-
"test-only": "node --trace-uncaught ./test.mjs"
|
|
10
|
+
"test-only": "node --trace-uncaught ./dev/test.mjs"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -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.18",
|
|
33
33
|
"typescript": "^4.8.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/tsconfig.json
CHANGED
package/test.mjs
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {{
|
|
3
|
-
* readonly withFileTypes: true
|
|
4
|
-
* }} Options
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {{
|
|
9
|
-
* readonly name: string
|
|
10
|
-
* readonly isDirectory: () => boolean
|
|
11
|
-
* }} Dirent
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {{
|
|
16
|
-
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
-
* readonly readFile: (path: string, options: 'utf8') => Promise<Buffer>
|
|
18
|
-
* }} FsPromises
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/** @type {FsPromises} */
|
|
22
|
-
const { readdir, readFile } = await import(globalThis.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {{
|
|
26
|
-
* [k: in string]?: Module
|
|
27
|
-
* }} Dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {{
|
|
32
|
-
* dependencies: Dependencies
|
|
33
|
-
* exports?: unknown
|
|
34
|
-
* }} Module
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @typedef {{
|
|
41
|
-
* readonly[k in string]: Function
|
|
42
|
-
* }} FunctionMap
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @template T
|
|
47
|
-
* @typedef {readonly[string, T]} Entry
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
51
|
-
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
52
|
-
|
|
53
|
-
/** @type {() => Promise<FunctionMap>} */
|
|
54
|
-
const load = async () => {
|
|
55
|
-
/** @type {(readonly[string, Function])[]} */
|
|
56
|
-
const map = []
|
|
57
|
-
/** @type {(path: string) => Promise<void>} */
|
|
58
|
-
const f = async p => {
|
|
59
|
-
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
60
|
-
const { name } = i
|
|
61
|
-
if (!name.startsWith('.')) {
|
|
62
|
-
const file = `${p}/${name}`
|
|
63
|
-
if (i.isDirectory()) {
|
|
64
|
-
if (!['node_modules', 'target'].includes(name)) {
|
|
65
|
-
await f(file)
|
|
66
|
-
}
|
|
67
|
-
} else if (name.endsWith('.f.cjs')) {
|
|
68
|
-
// console.log(`loading ${file}`)
|
|
69
|
-
const source = await readFile(file, 'utf8')
|
|
70
|
-
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
await f('.')
|
|
76
|
-
map.sort(cmp)
|
|
77
|
-
return Object.fromEntries(map)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const map = await load()
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @typedef {{
|
|
84
|
-
* [k in string]: Module
|
|
85
|
-
* }} ModuleMap
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
const build = async () => {
|
|
89
|
-
/** @type {ModuleMap} */
|
|
90
|
-
const d = {}
|
|
91
|
-
/** @type {(base: readonly string[]) => (i: string) => (k: string) => readonly[string, Module]} */
|
|
92
|
-
const req = base => i => k => {
|
|
93
|
-
const relativePath = k.split('/')
|
|
94
|
-
const dif = relativePath.filter(v => v === '..').length
|
|
95
|
-
const path = [base.slice(0, base.length - dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
96
|
-
.flat()
|
|
97
|
-
const pathStr = path.join('/')
|
|
98
|
-
const newBase = path.slice(0, path.length - 1)
|
|
99
|
-
{
|
|
100
|
-
const module = d[pathStr]
|
|
101
|
-
if (module !== undefined) {
|
|
102
|
-
return [pathStr, module]
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
{
|
|
106
|
-
/** @type {Module} */
|
|
107
|
-
const module = {
|
|
108
|
-
dependencies: {}
|
|
109
|
-
}
|
|
110
|
-
// console.log(`${i}building ${pathStr}`)
|
|
111
|
-
const getModule = req(newBase)(`${i}| `)
|
|
112
|
-
const newReq = s => {
|
|
113
|
-
const [p, result] = getModule(s)
|
|
114
|
-
module.dependencies[p] = result
|
|
115
|
-
return result.exports
|
|
116
|
-
}
|
|
117
|
-
map[pathStr](module, newReq)
|
|
118
|
-
d[pathStr] = module
|
|
119
|
-
return [pathStr, module]
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const r = req(['.'])('')
|
|
123
|
-
for (const k of Object.keys(map)) {
|
|
124
|
-
r(k)
|
|
125
|
-
}
|
|
126
|
-
return d
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const modules = await build()
|
|
130
|
-
|
|
131
|
-
// graph
|
|
132
|
-
|
|
133
|
-
/*
|
|
134
|
-
for (const [k, v] of Object.entries(modules)) {
|
|
135
|
-
console.log(`: ${k}`)
|
|
136
|
-
console.log(Object.keys(v.dependencies))
|
|
137
|
-
}
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
// test runner.
|
|
141
|
-
|
|
142
|
-
/** @type {(i: string) => (v: unknown) => void} */
|
|
143
|
-
const test = i => v => {
|
|
144
|
-
switch (typeof v) {
|
|
145
|
-
case 'function': {
|
|
146
|
-
if (v.length === 0) {
|
|
147
|
-
const r = v()
|
|
148
|
-
console.log(`${i}() passed`)
|
|
149
|
-
test(`${i}| `)(r)
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
case 'object': {
|
|
154
|
-
if (v instanceof Array) {
|
|
155
|
-
for (const v2 of v) {
|
|
156
|
-
test(`${i}| `)(v2)
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
for (const [k, v2] of Object.entries(v)) {
|
|
160
|
-
console.log(`${i}${k}:`)
|
|
161
|
-
test(`${i}| `)(v2)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
for (const [k, v] of Object.entries(modules)) {
|
|
170
|
-
if (k.endsWith('test.f.cjs')) {
|
|
171
|
-
console.log(`testing ${k}`)
|
|
172
|
-
test('| ')(v.exports)
|
|
173
|
-
}
|
|
174
|
-
}
|