functionalscript 0.0.201 → 0.0.205
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/module-manager/README.md +35 -0
- package/module-manager/node/test.js +1 -1
- package/module-manager/test.js +4 -4
- package/package.json +1 -1
- package/result/index.js +17 -0
- package/test.js +48 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Module Manager
|
|
2
|
+
|
|
3
|
+
## Module Provider
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
/** @typedef {(packageName: string) => PackageMap|Package|undefined} PackageMap */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {readonly[
|
|
10
|
+
* string,
|
|
11
|
+
* PackageMap,
|
|
12
|
+
* (fileName: string) => string|undefined
|
|
13
|
+
* ]} Package
|
|
14
|
+
*/
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Runner IO
|
|
18
|
+
|
|
19
|
+
The main target of this design is to simplify `RunnerIo` as much as possible.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
/**
|
|
23
|
+
* @template T
|
|
24
|
+
* @typedef {readonly[Result<unknown, Error>, Require<T>]} RunnerResult
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** @typedef {<T>(require: Require<T>) => (source: string) => RunnerResult<T>} RunnerIo */
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @template T
|
|
31
|
+
* @typedef {readonly[(path: string) => RunnerResult<T>, T]} Require<T>
|
|
32
|
+
*/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`Require` is using a `Package` and it contains also `RunnerIo` to provide sources also it contains
|
package/module-manager/test.js
CHANGED
|
@@ -31,7 +31,7 @@ if (cast(i.pathNorm('./a/../b/c/..//d/'.split('/'))).join('/') !== 'b/d') { thro
|
|
|
31
31
|
const c = {
|
|
32
32
|
dependencies: () => undefined,
|
|
33
33
|
file: path => {
|
|
34
|
-
/** @type {{ [_ in string]?: string}} */
|
|
34
|
+
/** @type {{ readonly [_ in string]?: string}} */
|
|
35
35
|
const f = {
|
|
36
36
|
'index.js': 'b/c ./index.js',
|
|
37
37
|
'x/index.js': 'b/c ./x/index.js',
|
|
@@ -41,11 +41,11 @@ if (cast(i.pathNorm('./a/../b/c/..//d/'.split('/'))).join('/') !== 'b/d') { thro
|
|
|
41
41
|
},
|
|
42
42
|
id: ['c']
|
|
43
43
|
}
|
|
44
|
-
/** @type {{ [_ in string]: i.Package|i.Dependencies}} */
|
|
44
|
+
/** @type {{ readonly [_ in string]: i.Package|i.Dependencies}} */
|
|
45
45
|
const packages = {
|
|
46
46
|
a,
|
|
47
47
|
b: s => {
|
|
48
|
-
/** @type {{ [_ in string]: i.Package|i.Dependencies}} */
|
|
48
|
+
/** @type {{ readonly [_ in string]: i.Package|i.Dependencies}} */
|
|
49
49
|
const p = { c }
|
|
50
50
|
return p[s]
|
|
51
51
|
}
|
|
@@ -54,7 +54,7 @@ if (cast(i.pathNorm('./a/../b/c/..//d/'.split('/'))).join('/') !== 'b/d') { thro
|
|
|
54
54
|
const pack = {
|
|
55
55
|
dependencies: s => packages[s],
|
|
56
56
|
file: path => {
|
|
57
|
-
/** @type {{ [_ in string]?: string}} */
|
|
57
|
+
/** @type {{ readonly [_ in string]?: string}} */
|
|
58
58
|
const f = {
|
|
59
59
|
'index.js': './index.js',
|
|
60
60
|
'index/index.js': './index/index.js',
|
package/package.json
CHANGED
package/result/index.js
ADDED
package/test.js
CHANGED
|
@@ -59,3 +59,51 @@ const assert_if = c => { if (c) { throw 'assert_if' } }
|
|
|
59
59
|
v.commit !== '4b14a7a2b11cf53f037931eb7bef240f96dcea64'),
|
|
60
60
|
assert)
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
const c = (()=>{})['constructor']
|
|
65
|
+
const f = c('return 5')
|
|
66
|
+
const result = f()
|
|
67
|
+
if (result !== 5) { throw 'function' }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
/** @type {any} */
|
|
72
|
+
const o = {}
|
|
73
|
+
const c = o['constructor']
|
|
74
|
+
// console.log(c)
|
|
75
|
+
// console.log(c(()=>{}))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
{
|
|
79
|
+
/** @type {any} */
|
|
80
|
+
const o = {
|
|
81
|
+
constructor: undefined
|
|
82
|
+
}
|
|
83
|
+
const c = o['constructor']
|
|
84
|
+
console.log(c)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
/** @type {any} */
|
|
89
|
+
const b = '42'
|
|
90
|
+
const r = Number(b)
|
|
91
|
+
console.log(r)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
{
|
|
95
|
+
/** @type {any} */
|
|
96
|
+
const o = {}
|
|
97
|
+
//const c = o['constructor']
|
|
98
|
+
//const c = o['__proto__']
|
|
99
|
+
//const c = o['__defineGetter__']
|
|
100
|
+
//const c = o['__defineSetter__']
|
|
101
|
+
//const c = o['__lookupGetter__']
|
|
102
|
+
//const c = o['__lookupSetter__']
|
|
103
|
+
//const c = o['hasOwnProperty']
|
|
104
|
+
//const c = o['isPrototypeOf']
|
|
105
|
+
//const c = o['propertyIsEnumerable']
|
|
106
|
+
//const c = o['toString']
|
|
107
|
+
const c = o['valueOf']
|
|
108
|
+
console.log(c)
|
|
109
|
+
}
|