functionalscript 0.0.419 → 0.0.420
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/deno.yml +2 -2
- package/commonjs/build/test.f.cjs +2 -0
- package/commonjs/package/dependencies/test.f.cjs +2 -0
- package/commonjs/path/test.f.cjs +3 -1
- package/deno-test +89 -0
- package/html/test.f.cjs +3 -1
- package/json/test.f.cjs +2 -0
- package/json/tokenizer/test.f.cjs +3 -1
- package/nodejs/version/module.f.cjs +7 -5
- package/nodejs/version/test.f.cjs +7 -2
- package/package.json +3 -3
- package/test.f.cjs +5 -2
- package/types/btree/find/test.f.cjs +3 -1
- package/types/btree/remove/test.f.cjs +3 -1
- package/types/btree/set/test.f.cjs +2 -0
- package/types/btree/test.f.cjs +3 -1
- package/types/map/test.f.cjs +2 -0
- package/types/object/test.f.cjs +3 -1
- package/types/range/test.f.cjs +2 -0
- package/types/stringset/test.f.cjs +2 -0
package/commonjs/path/test.f.cjs
CHANGED
|
@@ -188,4 +188,6 @@ const stringify = g => {
|
|
|
188
188
|
}
|
|
189
189
|
const result = stringify(_.parseAndFind(p => at(p)(packages))({package: '', path: ['a', 'b']})('z/a/c'))
|
|
190
190
|
if (result !== '{"id":{"package":"node_modules/z/a/c","path":["index.js"]},"source":"return \\"a/c\\""}') { throw result }
|
|
191
|
-
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
module.exports = {}
|
package/deno-test
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const {
|
|
2
|
+
/** @type {(path: string | URL) => AsyncIterable<DirEntry>} */
|
|
3
|
+
readDir,
|
|
4
|
+
/** @type {(path: string | URL) => Promise<string>} */
|
|
5
|
+
readTextFile,
|
|
6
|
+
} = Deno
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* readonly isDirectory: boolean
|
|
11
|
+
* readonly isFile: boolean
|
|
12
|
+
* readonly isSymlink: boolean
|
|
13
|
+
* readonly name: string
|
|
14
|
+
* }} DirEntry
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @typedef {{ exports?: unknown }} Module */
|
|
18
|
+
|
|
19
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{
|
|
23
|
+
* [k in string]: Function
|
|
24
|
+
* }} FunctionMap
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @type {(path: string) => Promise<FunctionMap>} */
|
|
28
|
+
const dir = async p => {
|
|
29
|
+
/** @type {FunctionMap} */
|
|
30
|
+
const map = {}
|
|
31
|
+
/** @type {(path: string) => Promise<void>} */
|
|
32
|
+
const f = async p => {
|
|
33
|
+
for await (const i of readDir(p)) {
|
|
34
|
+
const { name } = i
|
|
35
|
+
if (!name.startsWith('.')) {
|
|
36
|
+
const file = `${p}/${name}`
|
|
37
|
+
if (i.isDirectory) {
|
|
38
|
+
if (!['node_modules', 'target'].includes(name)) {
|
|
39
|
+
await f(file)
|
|
40
|
+
}
|
|
41
|
+
} else if (name.endsWith('.f.cjs')) {
|
|
42
|
+
// console.log(name)
|
|
43
|
+
const source = await readTextFile(file)
|
|
44
|
+
map[file] = Function('module', 'require', `"use strict";${source}`)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await f(p)
|
|
50
|
+
return map
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {{
|
|
55
|
+
* [k in string]: unknown
|
|
56
|
+
* }} ModuleMap
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
const run = async () => {
|
|
60
|
+
const m = await dir('.')
|
|
61
|
+
/** @type {ModuleMap} */
|
|
62
|
+
const d = {}
|
|
63
|
+
/** @type {(base: readonly string[]) => (k: string) => unknown} */
|
|
64
|
+
const req = p => k => {
|
|
65
|
+
const relativePath = k.split('/')
|
|
66
|
+
const bPath = relativePath.filter(v => !['..', '.'].includes(v))
|
|
67
|
+
const dif = relativePath.filter(v => v === '..').length
|
|
68
|
+
const path = [p.slice(0, p.length - dif), bPath.slice(0, bPath.length)].flat()
|
|
69
|
+
const pathStr = path.join('/')
|
|
70
|
+
const newBase = path.slice(0, path.length - 1)
|
|
71
|
+
const result = d[pathStr]
|
|
72
|
+
if (result === undefined) {
|
|
73
|
+
/** @type {Module} */
|
|
74
|
+
const me = {}
|
|
75
|
+
m[pathStr](me, req(newBase))
|
|
76
|
+
const newResult = me.exports
|
|
77
|
+
d[pathStr] = newResult
|
|
78
|
+
return newResult
|
|
79
|
+
} else {
|
|
80
|
+
return result
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const r = req(['.'])
|
|
84
|
+
for (const k of Object.keys(m)) {
|
|
85
|
+
r(k)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
run()
|
package/html/test.f.cjs
CHANGED
|
@@ -10,4 +10,6 @@ const _ = require('./module.f.cjs')
|
|
|
10
10
|
const x = ['div', {}, ['<div>&</div>', ['a', { href: 'hello"' }, []]]]
|
|
11
11
|
const s = _.htmlToString(x)
|
|
12
12
|
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') { throw s }
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {}
|
package/json/test.f.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* @typedef {{
|
|
3
3
|
* readonly execSync: (cmd: string) => Buffer
|
|
4
4
|
* }} ChildProcess
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/** @typedef {{}} Buffer */
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @template T
|
|
9
11
|
* @typedef {{
|
|
@@ -28,10 +30,10 @@ const version = ({ child_process, fs }) =>
|
|
|
28
30
|
'package.json',
|
|
29
31
|
stringify(
|
|
30
32
|
{
|
|
31
|
-
...parse(fs.readFileSync('package.json').toString()),
|
|
32
|
-
version: `0.0.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
|
|
33
|
-
},
|
|
34
|
-
null,
|
|
33
|
+
...parse(fs.readFileSync('package.json').toString()),
|
|
34
|
+
version: `0.0.${child_process.execSync('git log --oneline').toString().split('\n').length - 1}`
|
|
35
|
+
},
|
|
36
|
+
null,
|
|
35
37
|
2))
|
|
36
38
|
|
|
37
39
|
module.exports = {
|
|
@@ -72,12 +72,17 @@ const e = '{\n' +
|
|
|
72
72
|
' }\n' +
|
|
73
73
|
'}'
|
|
74
74
|
|
|
75
|
+
/** @type {(s: string) => _.Buffer} */
|
|
76
|
+
const buffer = s => ({
|
|
77
|
+
toString: () => s
|
|
78
|
+
})
|
|
79
|
+
|
|
75
80
|
{
|
|
76
81
|
/** @type {_.Node<string>} */
|
|
77
82
|
const node = {
|
|
78
|
-
child_process: { execSync: () =>
|
|
83
|
+
child_process: { execSync: () => buffer("123\n456\n") },
|
|
79
84
|
fs: {
|
|
80
|
-
readFileSync: () =>
|
|
85
|
+
readFileSync: () => buffer(JSON.stringify(x)),
|
|
81
86
|
writeFileSync: (_, content) => content
|
|
82
87
|
}
|
|
83
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.420",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^18.7.
|
|
33
|
-
"typescript": "^4.
|
|
32
|
+
"@types/node": "^18.7.16",
|
|
33
|
+
"typescript": "^4.8.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/test.f.cjs
CHANGED
|
@@ -8,11 +8,12 @@ require('./types/btree/test.f.cjs')
|
|
|
8
8
|
require('./types/byteSet/test.f.cjs')
|
|
9
9
|
require('./types/nibbleSet/test.f.cjs')
|
|
10
10
|
require('./sha2/test.f.cjs')
|
|
11
|
+
require('./types/map/test.f.cjs')
|
|
11
12
|
require('./json/test.f.cjs')
|
|
12
13
|
require('./types/string/test.f.cjs')
|
|
13
14
|
require('./json/tokenizer/test.f.cjs')
|
|
14
15
|
require('./types/object/test.f.cjs')
|
|
15
|
-
require('./commonjs/test.cjs')
|
|
16
|
+
// require('./commonjs/test.cjs')
|
|
16
17
|
require('./commonjs/package/dependencies/test.f.cjs')
|
|
17
18
|
require('./commonjs/package/test.f.cjs')
|
|
18
19
|
require('./commonjs/path/test.f.cjs')
|
|
@@ -89,4 +90,6 @@ const assert_if = c => { if (c) { throw 'assert_if' } }
|
|
|
89
90
|
const x = { 'a': 12 }
|
|
90
91
|
const c = Object.getOwnPropertyDescriptor(x, 'constructor')
|
|
91
92
|
const a = Object.getOwnPropertyDescriptor(x, 'a')
|
|
92
|
-
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module.exports = {}
|
package/types/btree/test.f.cjs
CHANGED
package/types/map/test.f.cjs
CHANGED
package/types/object/test.f.cjs
CHANGED
package/types/range/test.f.cjs
CHANGED