functionalscript 0.0.321 → 0.0.325

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.
@@ -10,13 +10,13 @@ const compileMap = {
10
10
  ':index.js': [
11
11
  'ok',
12
12
  require_ => m0 => {
13
- const [r1, m1] = require_('./b')(m0);
14
- if (r1[0] === 'error') { throw r1 }
15
- const [r2, m2] = require_('./a/')(m1);
16
- if (r2[0] === 'error') { throw r2 }
17
- const [r3, m3] = require_('x/r')(m2);
18
- if (r3[0] === 'error') { throw r3 }
19
- return [['ok', ':index.js'], m3]
13
+ let [r, m] = require_('./b')(m0);
14
+ if (r[0] === 'error') { throw r }
15
+ [r, m] = require_('./a/')(m);
16
+ if (r[0] === 'error') { throw r }
17
+ [r, m] = require_('x/r')(m);
18
+ if (r[0] === 'error') { throw r }
19
+ return [['ok', ':index.js'], m]
20
20
  }],
21
21
  ':b.js': [
22
22
  'ok',
@@ -32,11 +32,13 @@ const compileMap = {
32
32
  /** @type {function_.Compile} */
33
33
  const compile = source => compileMap[source] ?? ['error', 'invalid source']
34
34
 
35
- /** @type {{ readonly [k in string]?: { readonly dependencies: { readonly [k in string]?: string }, files:{ readonly [k in string]?: string } }}} */
35
+ /** @typedef {{ readonly [k in string]?: string }} StringMap */
36
+
37
+ /** @type {{ readonly [k in string]?: { readonly dependencies: StringMap, files: StringMap }}} */
36
38
  const packageMap = {
37
39
  '': {
38
40
  dependencies: {
39
- 'x': 'x'
41
+ 'x': '/node_modules/x'
40
42
  },
41
43
  files: {
42
44
  'index.js': ':index.js',
@@ -44,7 +46,7 @@ const packageMap = {
44
46
  'a/index.js': ':a/index.js',
45
47
  }
46
48
  },
47
- 'x': {
49
+ '/node_modules/x': {
48
50
  dependencies: {},
49
51
  files: {
50
52
  'r.js': 'x:r.js'
@@ -55,11 +57,11 @@ const packageMap = {
55
57
  /** @type {package_.Get} */
56
58
  const packageGet = packageId => {
57
59
  const p = packageMap[packageId]
58
- if (p === undefined) { return undefined }
59
- return {
60
- dependency: dependency => p.dependencies[dependency],
61
- file: file => p.files[file]
62
- }
60
+ return p === undefined ? undefined :
61
+ {
62
+ dependency: dependency => p.dependencies[dependency],
63
+ file: file => p.files[file]
64
+ }
63
65
  }
64
66
 
65
67
  const getOrBuild = _.getOrBuild
@@ -68,9 +70,21 @@ const getOrBuild = _.getOrBuild
68
70
  (/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
69
71
 
70
72
  {
71
- const [r] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
73
+ let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
74
+ if (JSON.stringify(r) !==
75
+ '["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js","x/r":"/node_modules/x/r.js"}}]'
76
+ ) {
77
+ throw r
78
+ }
79
+ [r, m] = getOrBuild({ package: '', path: ['b.js'] })(m)
80
+ if (JSON.stringify(r) !==
81
+ '["ok",{"exports":":b.js","requireMap":{}}]'
82
+ ) {
83
+ throw r
84
+ }
85
+ [r, m] = getOrBuild({ package: '', path: ['c.js']})(m)
72
86
  if (JSON.stringify(r) !==
73
- '["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js","x/r":"x/r.js"}}]'
87
+ '["error",["file not found"]]'
74
88
  ) {
75
89
  throw r
76
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.321",
3
+ "version": "0.0.325",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {