functionalscript 0.0.422 → 0.0.423
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/package.json +2 -2
- package/{denotest.mjs → test.mjs} +33 -31
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.423",
|
|
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.
|
|
10
|
+
"test-only": "node --trace-uncaught ./test.mjs"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
// import * as fs from "https://deno.land/std/node/fs.ts"
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
* @
|
|
5
|
-
* readonly
|
|
6
|
-
*
|
|
7
|
-
* }}
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly withFileTypes: true
|
|
4
|
+
* }} Options
|
|
8
5
|
*/
|
|
9
|
-
const {
|
|
10
|
-
readDir,
|
|
11
|
-
readTextFile,
|
|
12
|
-
} = Deno
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* @typedef {{
|
|
16
|
-
* readonly isDirectory: boolean
|
|
17
|
-
* readonly isFile: boolean
|
|
18
|
-
* readonly isSymlink: boolean
|
|
19
9
|
* readonly name: string
|
|
20
|
-
*
|
|
10
|
+
* readonly isDirectory: () => boolean
|
|
11
|
+
* }} Dirent
|
|
21
12
|
*/
|
|
22
13
|
|
|
23
|
-
/** @typedef {{ exports?: unknown }} Module */
|
|
24
|
-
|
|
25
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
26
|
-
|
|
27
14
|
/**
|
|
28
15
|
* @typedef {{
|
|
29
|
-
*
|
|
30
|
-
*
|
|
16
|
+
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
+
* readonly readFile: (path: string, options: 'utf8') => Promise<Buffer>
|
|
18
|
+
* }} FsPromises
|
|
31
19
|
*/
|
|
32
20
|
|
|
33
|
-
/** @type {
|
|
34
|
-
const
|
|
21
|
+
/** @type {FsPromises} */
|
|
22
|
+
const { readdir, readFile } = await import(globalThis.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
23
|
+
|
|
24
|
+
const load = async() => {
|
|
35
25
|
/** @type {FunctionMap} */
|
|
36
26
|
const map = {}
|
|
37
27
|
/** @type {(path: string) => Promise<void>} */
|
|
38
28
|
const f = async p => {
|
|
39
|
-
for
|
|
29
|
+
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
40
30
|
const { name } = i
|
|
41
31
|
if (!name.startsWith('.')) {
|
|
42
32
|
const file = `${p}/${name}`
|
|
43
|
-
if (i.isDirectory) {
|
|
33
|
+
if (i.isDirectory()) {
|
|
44
34
|
if (!['node_modules', 'target'].includes(name)) {
|
|
45
35
|
await f(file)
|
|
46
36
|
}
|
|
47
37
|
} else if (name.endsWith('.f.cjs')) {
|
|
48
38
|
console.log(`loading ${file}`)
|
|
49
|
-
const source = await
|
|
39
|
+
const source = await readFile(file, 'utf8')
|
|
50
40
|
map[file] = Function('module', 'require', `"use strict";${source}`)
|
|
51
41
|
}
|
|
52
42
|
}
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
await f(
|
|
45
|
+
await f('.')
|
|
56
46
|
return map
|
|
57
47
|
}
|
|
58
48
|
|
|
49
|
+
const map = await load()
|
|
50
|
+
|
|
51
|
+
/** @typedef {{ exports?: unknown }} Module */
|
|
52
|
+
|
|
53
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {{
|
|
57
|
+
* [k in string]: Function
|
|
58
|
+
* }} FunctionMap
|
|
59
|
+
*/
|
|
60
|
+
|
|
59
61
|
/**
|
|
60
62
|
* @typedef {{
|
|
61
63
|
* [k in string]: unknown
|
|
62
64
|
* }} ModuleMap
|
|
63
65
|
*/
|
|
64
66
|
|
|
65
|
-
const
|
|
66
|
-
const m = await dir('.')
|
|
67
|
+
const build = async () => {
|
|
67
68
|
/** @type {ModuleMap} */
|
|
68
69
|
const d = {}
|
|
69
70
|
/** @type {(base: readonly string[]) => (i: string) => (k: string) => unknown} */
|
|
@@ -79,7 +80,7 @@ const run = async () => {
|
|
|
79
80
|
/** @type {Module} */
|
|
80
81
|
const me = {}
|
|
81
82
|
console.log(`${i}building ${pathStr}`)
|
|
82
|
-
|
|
83
|
+
map[pathStr](me, req(newBase)(`${i}| `))
|
|
83
84
|
const newResult = me.exports
|
|
84
85
|
d[pathStr] = newResult
|
|
85
86
|
return newResult
|
|
@@ -88,9 +89,10 @@ const run = async () => {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
const r = req(['.'])('')
|
|
91
|
-
for (const k of Object.keys(
|
|
92
|
+
for (const k of Object.keys(map)) {
|
|
92
93
|
r(k)
|
|
93
94
|
}
|
|
95
|
+
return d
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
const modules = await build()
|
package/tsconfig.json
CHANGED