functionalscript 0.0.200 → 0.0.204

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/btree/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const btree = require('.')
2
- const { setVisitor, values: valuesList } = btree
2
+ const { setVisitor, values } = btree
3
3
  const { cmp } = require('../cmp')
4
4
  const list = require('../sequence')
5
5
 
@@ -23,7 +23,7 @@ const test = () => {
23
23
  //
24
24
  {
25
25
  /** @type {import('../sequence').Result<string>} */
26
- let _item = list.next(valuesList(_map))
26
+ let _item = list.next(values(_map))
27
27
  while (_item !== undefined) {
28
28
  _item = list.next(_item[1])
29
29
  }
@@ -0,0 +1,32 @@
1
+ # Module Manager
2
+
3
+ ## Module Provider
4
+
5
+ ```js
6
+ /** @typedef {(packageName: string) => PackageMap|Package|undefined} PackageMap */
7
+
8
+ /**
9
+ * @typedef {{
10
+ * readonly id: string,
11
+ * readonly packages: PackageMap,
12
+ * readonly files: (fileName: string) => string|undefined,
13
+ * }} Package
14
+ */
15
+ ```
16
+
17
+ ## Runner IO
18
+
19
+ ```js
20
+ /**
21
+ * @typedef {(require: Require<T>) => (info: T) => (source: string) => readonly[Result<unknown, Error>, T]} RunnerIo
22
+ */
23
+ ```
24
+
25
+ ```js
26
+ /**
27
+ * @template T
28
+ * @typedef {(info: T) => (module: string) => readonly[Result<unknown, Error>, T]} Require<T>
29
+ */
30
+ ```
31
+
32
+ `Require` is using a `Package` to provide sources.
@@ -1,7 +1,7 @@
1
1
  const mm = require('..')
2
2
  const i = require('.')
3
3
 
4
- /** @type {{ [_ in string]: string}} */
4
+ /** @type {{ readonly [_ in string]: string}} */
5
5
  const files = {
6
6
  'index.js': './index.js',
7
7
  'a/index.js': './a/index.js',
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.200",
3
+ "version": "0.0.204",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
+ }