functionalscript 0.0.316 → 0.0.320

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.
@@ -3,7 +3,22 @@
3
3
  ```ts
4
4
  // package/index.js
5
5
 
6
+ // A dictionary of packages.
7
+ //
8
+ // A package contains a dictionary of dependencies and a dictionary of files.
9
+ //
10
+ // `packageId` examples:
11
+ // - Node.js:
12
+ // - normalized: `./node_modules/functionalscript`
13
+ // - fs modules:
14
+ // - normalized: `github:functionalscript/functionalscript:bf4f3ed9ad1d3c19ee7bea3e76000dec77d01b4f`
15
+ // - `localPackageId` examples:
16
+ // - `functionalscript`
17
+
6
18
  type PackageGet = (packageId: string) => Package | undefined
19
+
20
+ // A local file id is
21
+
7
22
  type Package = {
8
23
  // returns a global package id.
9
24
  readonly dependency: (localPackageId: string) => string | undefined
@@ -13,21 +28,35 @@ type Package = {
13
28
 
14
29
  // module/index.js
15
30
 
31
+ // A module map is a dictionary of modules.
32
+ //
33
+ // A module is a compiled and initialized source file.
34
+
35
+ type ModuleGet = (moduleId: string) => ModuleState | undefined
36
+
16
37
  type ModuleMapInterface<M> = {
17
- readonly at: (moduleId: string) => (moduleMap: M) => ModuleState | undefined
18
- readonly insert: (moduleId: string) => (moduleState: ModuleState) => (moduleMap: M) => M
38
+ readonly get: (moduleMap: M) => ModuleGet
39
+ readonly insert: (moduleMap: M) => (moduleId: string) => (moduleState: ModuleState) => M
19
40
  }
20
41
 
21
- type ModuleState = readonly['ok', Module] | readonly['error', ModuleError] | readonly['building']
42
+ type ModuleState = readonly['ok', Module] | readonly['error', ModuleError]
22
43
 
23
44
  type Module = {
45
+ // Exports is a result of module initialization.
24
46
  readonly exports: unknown
47
+ // A dictionary of required modules.
48
+ // For example, `require('functionalscript/types/list')` may produce the dictionary entry
49
+ // `['functionalscript/types/list', './node_modules/functionalscript/types/list/index.js']`
25
50
  readonly requireMap: object.Map<string>
26
51
  }
27
52
 
28
53
  type ModuleError = 'file not found' | 'compile error' | 'runtime error' | 'circular reference'
29
54
 
30
- type ModuleId = {
55
+ // A module id is a global module id. It contains a package id and file id. For example
56
+ // - `./node_modules/functionalscript/types/list/index.js`
57
+ // - `github:functionalscript/functionalscript:bf4f3ed9ad1d3c19ee7bea3e76000dec77d01b4f/types/list/index.js`
58
+
59
+ type ModuleId = {
31
60
  readonly packageId: string,
32
61
  readonly path: readonly string[],
33
62
  }
@@ -38,7 +67,7 @@ const moduleIdToString: (moduleId: ModuleId) => string;
38
67
 
39
68
  type BuildConfig<M> = {
40
69
  readonly packageGet: PackageGet
41
- readonly moduleMapInterface: ModuleMapInterface<M>
70
+ readonly moduleMapInterface: ModuleMapInterface<M>
42
71
  readonly moduleId: ModuleId
43
72
  readonly moduleMap: M // mutable
44
73
  }
@@ -5,11 +5,12 @@ const { todo } = require('../../dev')
5
5
  const map = require('../../types/map')
6
6
  const object = require('../../types/object')
7
7
  const path = require('../path')
8
+ const stringSet = require('../../types/stringSet')
8
9
 
9
10
  /**
10
11
  * @template M
11
12
  * @typedef {{
12
- * readonly pagkageGet: package_.Get
13
+ * readonly packageGet: package_.Get
13
14
  * readonly moduleMapInterface: module_.MapInterface<M>
14
15
  * readonly moduleId: module_.Id
15
16
  * readonly moduleMap: M
@@ -25,96 +26,66 @@ const path = require('../path')
25
26
  const notFound = moduleMap => [['error', ['file not found']], moduleMap]
26
27
 
27
28
  /**
28
- * @type {(packageGet: package_.Get) =>
29
+ * @type {(compile: function_.Compile) =>
30
+ * (packageGet: package_.Get) =>
29
31
  * <M>(moduleMapInterface: module_.MapInterface<M>) =>
30
- * (compile: function_.Compile) =>
31
32
  * (moduleId: module_.Id) =>
32
- * (moduleMapFirst: M) =>
33
+ * (moduleMap: M) =>
33
34
  * Result<M>
34
35
  * }
35
36
  */
36
- const getOrBuild = packageGet => moduleMapInterface => compile => moduleId => {
37
-
37
+ const getOrBuild = compile => packageGet => moduleMapInterface => {
38
38
  /** @typedef {typeof moduleMapInterface extends module_.MapInterface<infer M> ? M : never} M */
39
39
 
40
- const moduleIdStr = module_.idToString(moduleId)
41
-
42
- /** @type {(e: module_.Error) => (moduleMap: M) => Result<M>} */
43
- const error = e => moduleMap => {
44
- /** @type {module_.State} */
45
- const state = ['error', e]
46
- return [state, moduleMapInterface.insert(moduleIdStr)(state)(moduleMap)]
47
- }
48
-
49
- /** @type {function_.Require<readonly[M, map.Map<string>]>} */
50
- const require_ = pathStr => prior => {
51
- const pathResult = path.parseAndFind(packageGet)(moduleId.packageId)(moduleIdStr)(pathStr)
52
- if (pathResult === undefined) { return [['error', `file not found: '${pathStr}'`], prior] }
53
- const mId = { packageId: pathResult.package, path: pathResult.file.split('/') }
54
- const [state, newMap] = getOrBuild
55
- (packageGet)
56
- (moduleMapInterface)
57
- (compile)
58
- (mId)
59
- (prior[0])
60
- switch (state[0]) {
61
- case 'ok': {
62
- const newRequireMap = map.set(pathStr)(module_.idToString(mId))(prior[1])
63
- return [
64
- ['ok', state[1].exports],
65
- [newMap, newRequireMap]
66
- ]
67
- }
68
- case 'building': {
69
- return todo()
70
- }
71
- // 'ok'
72
- default: {
73
- return todo()
74
- }
40
+ /** @type {(buildSet: stringSet.StringSet) => (moduleId: module_.Id) => (source: string) => (moduleMap: M) => Result<M>} */
41
+ const build = buildSet => moduleId => {
42
+ const moduleIdStr = module_.idToString(moduleId)
43
+ const buildSet1 = stringSet.set(moduleIdStr)(buildSet)
44
+ const dir = module_.dir(moduleId)
45
+ /** @type {function_.Require<readonly[map.Map<string>, M]>} */
46
+ const require_ = p => ([requireMap, m]) => {
47
+ /** @type {(e: unknown) => function_.Result<readonly[map.Map<string>, M]>} */
48
+ const error = e => [['error', 'file not found'], [requireMap, m]]
49
+ if (dir === undefined) { return error('file not found') }
50
+ const r = path.parseAndFind(packageGet)(dir)(p)
51
+ if (r === undefined) { return error('file not found') }
52
+ const rIdStr = module_.idToString(r.id)
53
+ if (stringSet.contains(rIdStr)(buildSet1)) { return error('circular reference') }
54
+ const [state, m1] = build(buildSet1)(r.id)(r.source)(m)
55
+ return [state[0] === 'error' ? state : ['ok', state[1].exports], [map.set(p)(rIdStr)(requireMap), m1]]
56
+ }
57
+ return source => moduleMap => {
58
+ /** @type {(s: module_.State) => (m: M) => Result<M>} */
59
+ const set = s => m => [s, moduleMapInterface.set(moduleIdStr)(s)(m)]
60
+ /** @type {(e: module_.Error) => (m: M) => Result<M>} */
61
+ const error = e => set(['error', e])
62
+ // check compilation
63
+ const j = compile(source)
64
+ if (j[0] === 'error') { return error(['compilation error', j[1]])(moduleMap) }
65
+ // build
66
+ const [r, [requireMap, moduleMap2]] = j[1](require_)([undefined, moduleMap])
67
+ const x = r[0] === 'error' ?
68
+ error(['runtime error', r[1]]) :
69
+ set(['ok', { exports: r[1], requireMap: object.fromMap(requireMap) }])
70
+ return x(moduleMap2)
75
71
  }
76
72
  }
77
-
78
- return moduleMapFirst => {
79
- let moduleMap = moduleMapFirst
80
-
73
+ /** @type {(moduleId: module_.Id) => (moduleMap: M) => Result<M>} */
74
+ const f = moduleId => moduleMap => {
75
+ const moduleIdStr = module_.idToString(moduleId)
76
+ // check moduleMap
81
77
  {
82
78
  const m = moduleMapInterface.at(moduleIdStr)(moduleMap)
83
79
  if (m !== undefined) { return [m, moduleMap] }
84
80
  }
85
-
86
- const p = packageGet(moduleId.packageId)
81
+ // check package
82
+ const p = packageGet(moduleId.package)
87
83
  if (p === undefined) { return notFound(moduleMap) }
88
-
84
+ // check file
89
85
  const source = p.file(moduleId.path.join('/'))
90
- if (source === undefined) { return notFound(moduleMap) }
91
-
92
- const compileResult = compile(source)
93
- if (compileResult[0] === 'error') { return error(['compilation error', compileResult[1]])(moduleMap) }
94
-
95
- const moduleFunction = compileResult[1]
96
-
97
- moduleMap = moduleMapInterface.insert(moduleIdStr)(['building'])(moduleMap)
98
-
99
- const [[type, exportsOrError], [newModuleMap, requireMap]] = moduleFunction(require_)([moduleMap, map.empty])
100
- moduleMap = newModuleMap
101
-
102
- {
103
- const m = moduleMapInterface.at(moduleIdStr)(moduleMap)
104
- if (m === undefined ) { throw 'm === undefined' }
105
- if (m[0] !== 'building') { return [m, moduleMap] }
106
- }
107
-
108
- /** @type {module_.State} */
109
- const result = type === 'error' ?
110
- ['error', ['runtime error', exportsOrError]] :
111
- ['ok', {
112
- exports: exportsOrError,
113
- requireMap: object.fromMap(requireMap)
114
- }]
115
-
116
- return [result, moduleMapInterface.insert(moduleIdStr)(result)(moduleMap)]
86
+ return (source === undefined ? notFound : build(undefined)(moduleId)(source))(moduleMap)
117
87
  }
88
+ return f
118
89
  }
119
90
 
120
91
  module.exports = {
@@ -0,0 +1,65 @@
1
+ const _ = require('.')
2
+ const map = require('../../types/map')
3
+ const module_ = require('../module')
4
+ const function_ = require('../module/function')
5
+ const result = require('../../types/result')
6
+ const package_ = require('../package')
7
+
8
+ /** @type {{ readonly [k in string]?: result.Result<function_.Function_, unknown> }} */
9
+ const compileMap = {
10
+ ':index.js': [
11
+ 'ok',
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
+ return [['ok', ':index.js'], m2]
18
+ }],
19
+ ':b.js': [
20
+ 'ok',
21
+ () => m0 => {
22
+ return [['ok', ':b.js'], m0]
23
+ }],
24
+ ':a/index.js': [
25
+ 'ok',
26
+ () => m0 => {
27
+ return [['ok', ':a/index.js'], m0]
28
+ }]
29
+ }
30
+
31
+ /** @type {function_.Compile} */
32
+ const compile = source => compileMap[source] ?? ['error', 'invalid source']
33
+
34
+ /** @type {{ readonly [k in string]?: { readonly [k in string]?: string } }} */
35
+ const packageMap = {
36
+ '': {
37
+ 'index.js': ':index.js',
38
+ 'b.js': ':b.js',
39
+ 'a/index.js': ':a/index.js',
40
+ }
41
+ }
42
+
43
+ /** @type {package_.Get} */
44
+ const packageGet = packageId => {
45
+ const p = packageMap[packageId]
46
+ if (p === undefined) { return undefined }
47
+ return {
48
+ dependency: () => undefined,
49
+ file: file => p[file]
50
+ }
51
+ }
52
+
53
+ const getOrBuild = _.getOrBuild
54
+ (compile)
55
+ (packageGet)
56
+ (/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
57
+
58
+ {
59
+ const [r] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
60
+ if (JSON.stringify(r) !==
61
+ '["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js"}}]'
62
+ ) {
63
+ throw r
64
+ }
65
+ }
@@ -4,15 +4,14 @@ const object = require('../../types/object')
4
4
  * @template M
5
5
  * @typedef {{
6
6
  * readonly at: (moduleId: string) => (moduleMap: M) => State | undefined
7
- * readonly insert: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M
7
+ * readonly set: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M
8
8
  * }} MapInterface
9
9
  */
10
10
 
11
11
  /**
12
12
  * @typedef {|
13
13
  * readonly['ok', Module] |
14
- * readonly['error', Error] |
15
- * readonly['building']
14
+ * readonly['error', Error]
16
15
  * } State
17
16
  */
18
17
 
@@ -34,15 +33,27 @@ const object = require('../../types/object')
34
33
 
35
34
  /**
36
35
  * @typedef {{
37
- * readonly packageId: string
36
+ * readonly package: string
38
37
  * readonly path: readonly string[]
39
38
  * }} Id
40
39
  */
41
40
 
41
+ /** @type {(id: Id) => Id | undefined} */
42
+ const dir = id => {
43
+ const len = id.path.length
44
+ if (len < 1) { return undefined }
45
+ return {
46
+ package: id.package,
47
+ path: id.path.slice(0, len - 1)
48
+ }
49
+ }
50
+
42
51
  /** @type {(id: Id) => string} */
43
- const idToString = ({ packageId, path }) => `${packageId}/${path.join('/')}`
52
+ const idToString = id => `${id.package}/${id.path.join('/')}`
44
53
 
45
54
  module.exports = {
55
+ /** @readonly */
56
+ dir,
46
57
  /** @readonly */
47
58
  idToString,
48
59
  }
@@ -89,7 +89,7 @@ const mapDependency = d => ([external, internal]) => {
89
89
 
90
90
  /**
91
91
  * @typedef {{
92
- * readonly packageId: string,
92
+ * readonly package: string,
93
93
  * readonly items: Items,
94
94
  * readonly dir: boolean,
95
95
  * }} Path
@@ -105,7 +105,7 @@ const parseGlobal = d => dir => items => {
105
105
  const v = variants([undefined, items])
106
106
  const r = list.first(undefined)(list.filterMap(mapDependency(d))(v))
107
107
  if (r === undefined) { return undefined }
108
- return { packageId: r[0], items: list.toArray(r[1]), dir }
108
+ return { package: r[0], items: list.toArray(r[1]), dir }
109
109
  }
110
110
 
111
111
  /**
@@ -119,37 +119,35 @@ const parse = packageId => dependencies => local => path => {
119
119
  const parsed = parseLocal(local)(path)
120
120
  if (parsed === undefined) { return undefined }
121
121
  const {external, dir, items } = parsed
122
- if (!external) { return { packageId, items, dir } }
122
+ if (!external) { return { package: packageId, items, dir } }
123
123
  return parseGlobal(dependencies)(dir)(items)
124
124
  }
125
125
 
126
126
  /**
127
127
  * @typedef {{
128
- * readonly package: string
129
- * readonly file: string
128
+ * readonly id: module_.Id
130
129
  * readonly source: string
131
130
  * }| undefined} Result
132
131
  */
133
132
 
134
133
  /**
135
134
  * @type {(packageGet: package_.Get) =>
136
- * (packageId: string) =>
137
- * (local: string) =>
135
+ * (moduleId: module_.Id) =>
138
136
  * (path: string) =>
139
137
  * Result
140
138
  * }
141
139
  */
142
- const parseAndFind = packageGet => packageId => local => path => {
143
- const currentPack = packageGet(packageId)
140
+ const parseAndFind = packageGet => moduleId => path => {
141
+ const currentPack = packageGet(moduleId.package)
144
142
  if (currentPack === undefined) { return undefined }
145
- const p = parse(packageId)(currentPack.dependency)(local)(path)
143
+ const p = parse(moduleId.package)(currentPack.dependency)(moduleId.path.join('/'))(path)
146
144
  if (p === undefined) { return undefined }
147
- const pack = packageGet(p.packageId)
145
+ const pack = packageGet(p.package)
148
146
  if (pack === undefined) { return undefined }
149
147
  /** @type {(file: string) => Result } */
150
148
  const tryFile = file => {
151
149
  const source = pack.file(file)
152
- return source === undefined ? undefined : { package: p.packageId, file, source }
150
+ return source === undefined ? undefined : { id: { package: p.package, path: file.split('/') }, source }
153
151
  }
154
152
  const file = p.items.join('/')
155
153
  const indexJs = list.join('/')(list.concat(p.items)(['index.js']))
@@ -59,20 +59,20 @@ const stringify = g => {
59
59
  if (_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['d']) !== undefined) { throw 'error' }
60
60
  {
61
61
  const result = stringify(_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['b']))
62
- if (result !== '{"packageId":"x","items":[],"dir":false}') { throw result }
62
+ if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
63
63
  }
64
64
  if (_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b']) !== undefined) { throw 'error' }
65
65
  {
66
66
  const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r']))
67
- if (result !== '{"packageId":"x","items":[],"dir":false}') { throw result }
67
+ if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
68
68
  }
69
69
  {
70
70
  const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r', 'd', 't']))
71
- if (result !== '{"packageId":"x","items":["d","t"],"dir":false}') { throw result }
71
+ if (result !== '{"package":"x","items":["d","t"],"dir":false}') { throw result }
72
72
  }
73
73
  {
74
74
  const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(true)(['b', 'r', 'd', 't']))
75
- if (result !== '{"packageId":"x","items":["d","t"],"dir":true}') { throw result }
75
+ if (result !== '{"package":"x","items":["d","t"],"dir":true}') { throw result }
76
76
  }
77
77
  }
78
78
 
@@ -84,8 +84,8 @@ const stringify = g => {
84
84
  file: path => at(path)({ 'a/c': 'return "a/c"' }),
85
85
  }
86
86
  }
87
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('../c'))
88
- if (result !== '{"package":"","file":"a/c","source":"return \\"a/c\\""}') { throw result }
87
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('../c'))
88
+ if (result !== '{"id":{"package":"","path":["a","c"]},"source":"return \\"a/c\\""}') { throw result }
89
89
  }
90
90
 
91
91
  {
@@ -108,32 +108,34 @@ const stringify = g => {
108
108
  }
109
109
  }
110
110
  {
111
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('z/a/c'))
112
- if (result !== '{"package":"node_modules/z","file":"a/c/index.js","source":"return \\"a/c\\""}') { throw result }
111
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c'))
112
+ if (result !== '{"id":{"package":"node_modules/z","path":["a","c","index.js"]},"source":"return \\"a/c\\""}') {
113
+ throw result
114
+ }
113
115
  }
114
116
  {
115
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('../..'))
116
- if (result !== '{"package":"","file":"index.js","source":"return \\"index.js\\""}') { throw result }
117
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('../..'))
118
+ if (result !== '{"id":{"package":"","path":["index.js"]},"source":"return \\"index.js\\""}') { throw result }
117
119
  }
118
120
  {
119
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('')('./x'))
120
- if (result !== '{"package":"","file":"x.js","source":"return \\"x.js\\""}') { throw result }
121
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x'))
122
+ if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
121
123
  }
122
124
  {
123
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('')('./x.js'))
124
- if (result !== '{"package":"","file":"x.js","source":"return \\"x.js\\""}') { throw result }
125
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x.js'))
126
+ if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
125
127
  }
126
128
  {
127
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('')('./x/'))
128
- if (result !== '{"package":"","file":"x/index.js","source":"return \\"x/index.js\\""}') { throw result }
129
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x/'))
130
+ if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
129
131
  }
130
132
  {
131
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('x/a')('../'))
132
- if (result !== '{"package":"","file":"x/index.js","source":"return \\"x/index.js\\""}') { throw result }
133
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a']})('../'))
134
+ if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
133
135
  }
134
136
  {
135
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('x/a')('..'))
136
- if (result !== '{"package":"","file":"x/index.js","source":"return \\"x/index.js\\""}') { throw result }
137
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a']})('..'))
138
+ if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
137
139
  }
138
140
  }
139
141
 
@@ -156,12 +158,12 @@ const stringify = g => {
156
158
  }
157
159
  }
158
160
  {
159
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('z/a/c'))
160
- if (result !== '{"package":"node_modules/z/a","file":"c.js","source":"return \\"c.js\\""}') { throw result }
161
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c'))
162
+ if (result !== '{"id":{"package":"node_modules/z/a","path":["c.js"]},"source":"return \\"c.js\\""}') { throw result }
161
163
  }
162
164
  {
163
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('z/a/c/'))
164
- if (result !== '{"package":"node_modules/z/a","file":"c/index.js","source":"return \\"c/index.js\\""}') { throw result }
165
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c/'))
166
+ if (result !== '{"id":{"package":"node_modules/z/a","path":["c","index.js"]},"source":"return \\"c/index.js\\""}') { throw result }
165
167
  }
166
168
  }
167
169
 
@@ -184,6 +186,6 @@ const stringify = g => {
184
186
  }),
185
187
  }
186
188
  }
187
- const result = stringify(_.parseAndFind(p => at(p)(packages))('')('a/b')('z/a/c'))
188
- if (result !== '{"package":"node_modules/z/a/c","file":"index.js","source":"return \\"a/c\\""}') { throw result }
189
+ const result = stringify(_.parseAndFind(p => at(p)(packages))({package: '', path: ['a', 'b']})('z/a/c'))
190
+ if (result !== '{"id":{"package":"node_modules/z/a/c","path":["index.js"]},"source":"return \\"a/c\\""}') { throw result }
189
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.316",
3
+ "version": "0.0.320",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test.js CHANGED
@@ -12,6 +12,7 @@ require('./commonjs/package/test')
12
12
  require('./commonjs/path/test')
13
13
  require('./types/function/compare/test')
14
14
  require('./types/stringSet/test')
15
+ require('./commonjs/build/test')
15
16
 
16
17
  /** @type {() => never} */
17
18
  const assert = () => { throw 'assert' }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /**
8
- * Postfix Compose function.
8
+ * A postfix compose function.
9
9
  *
10
10
  * @type {<I, X>(g: Func<I, X>) => <O>(f: Func<X, O>) => Func<I, O>}
11
11
  */
@@ -22,6 +22,6 @@ module.exports = {
22
22
  identity,
23
23
  /** @readonly */
24
24
  compose,
25
- /** @reeadonly */
25
+ /** @readonly */
26
26
  flip,
27
- }
27
+ }