functionalscript 0.0.481 → 0.0.482

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,13 +3,13 @@ const module_ = require('../module/module.f.cjs')
3
3
  const { idToString, dir } = module_
4
4
  const function_ = require('../module/function/module.f.cjs')
5
5
  const map = require('../../types/map/module.f.cjs')
6
- const { setReplace } = map
6
+ const { empty: mapEmpty, setReplace } = map
7
7
  const object = require('../../types/object/module.f.cjs')
8
8
  const { fromMap } = object
9
9
  const path = require('../path/module.f.cjs')
10
10
  const { parseAndFind } = path
11
11
  const stringSet = require('../../types/string_set/module.f.cjs')
12
- const { set: setSet, contains: setContains } = stringSet
12
+ const { set: setSet, contains: setContains, empty: stringSetEmpty } = stringSet
13
13
 
14
14
  /**
15
15
  * @template M
@@ -73,7 +73,7 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
73
73
  const [kind, result] = compile(source)
74
74
  if (kind === 'error') { return error(['compilation error', result])(moduleMap) }
75
75
  // build
76
- const [[state, value], [requireMap, moduleMap2]] = result(require_)([undefined, moduleMap])
76
+ const [[state, value], [requireMap, moduleMap2]] = result(require_)([mapEmpty, moduleMap])
77
77
  const x = state === 'error' ?
78
78
  error(['runtime error', value]) :
79
79
  set(['ok', { exports: value, requireMap: fromMap(requireMap) }])
@@ -93,7 +93,7 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
93
93
  if (p === null) { return notFound(moduleMap) }
94
94
  // check file
95
95
  const source = p.file(moduleId.path.join('/'))
96
- return (source === null ? notFound : build(undefined)(moduleId)(source))(moduleMap)
96
+ return (source === null ? notFound : build(stringSetEmpty)(moduleId)(source))(moduleMap)
97
97
  }
98
98
  return f
99
99
  }
@@ -71,7 +71,7 @@ const getOrBuild = _.getOrBuild
71
71
  (/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
72
72
 
73
73
  module.exports = () => {
74
- let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
74
+ let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(map.empty)
75
75
  {
76
76
  const x = JSON.stringify(r)
77
77
  if (x !==
@@ -8,14 +8,14 @@ const { entries } = Object
8
8
 
9
9
  /** @typedef {{readonly[k in string]: string}} DependencyMapJson */
10
10
 
11
- /** @typedef {DependencyMapJson|undefined} DependenciesJson */
11
+ /** @typedef {DependencyMapJson|null} DependenciesJson */
12
12
 
13
13
  /** @type {(entry: json.Entry) => boolean} */
14
14
  const isDependencyJson = ([, v]) => typeof v === 'string'
15
15
 
16
- /** @type {(j: json.Unknown|undefined) => j is DependenciesJson} */
16
+ /** @type {(j: json.Unknown) => j is DependenciesJson} */
17
17
  const isDependenciesJson = j => {
18
- if (j === undefined) { return true }
18
+ if (j === null) { return true }
19
19
  if (!isObject(j)) { return false }
20
20
  return every(map(isDependencyJson)(entries(j)))
21
21
  }
@@ -1,8 +1,7 @@
1
1
  const _ = require('./module.f.cjs')
2
2
 
3
3
  module.exports = () => {
4
- if (!_.isDependenciesJson(undefined)) { throw 'error' }
5
- if (_.isDependenciesJson(null)) { throw 'error' }
4
+ if (!_.isDependenciesJson(null)) { throw 'error' }
6
5
  if (!_.isDependenciesJson({})) { throw 'error' }
7
6
  if (!_.isDependenciesJson({'a':'b'})) { throw 'error' }
8
7
  if (_.isDependenciesJson({ 'a': 12 })) { throw 'error' }
@@ -2,6 +2,7 @@ const json = require('../../json/module.f.cjs')
2
2
  const { isObject } = json
3
3
  const dependencies = require('./dependencies/module.f.cjs')
4
4
  const { isDependenciesJson } = dependencies
5
+ const { at } = require('../../types/object/module.f.cjs')
5
6
 
6
7
  /**
7
8
  * @typedef {{
@@ -16,7 +17,7 @@ const isPackageJson = j => {
16
17
  if (!isObject(j)) { return false }
17
18
  if (typeof j.name !== 'string') { return false }
18
19
  if (typeof j.version !== 'string') { return false }
19
- if (!isDependenciesJson(j.dependencies)) { return false }
20
+ if (!isDependenciesJson(at('dependencies')(j))) { return false }
20
21
  return true
21
22
  }
22
23
 
@@ -9,11 +9,8 @@ const package_ = require('../package/module.f.cjs')
9
9
  /** @type {<T>(o: object.Map<T>) => (s: string) => T|null} */
10
10
  const i = o => s => at(s)(o)
11
11
 
12
- /** @type {(g: json.Unknown|undefined) => string} */
13
- const stringify = g => {
14
- if (g === undefined) { throw g }
15
- return json.stringify(identity)(g)
16
- }
12
+ /** @type {(g: json.Unknown) => string} */
13
+ const stringify = json.stringify(identity)
17
14
 
18
15
  module.exports = {
19
16
  0: () => {
package/dev/module.mjs CHANGED
@@ -121,7 +121,7 @@ export const loadModuleMap = async () => {
121
121
  const pathStr = path.join('/')
122
122
  {
123
123
  const module = d[pathStr]
124
- if (module !== undefined) {
124
+ if (module !== void 0) {
125
125
  return [pathStr, module]
126
126
  }
127
127
  }
package/doc/LANGUAGE.md CHANGED
@@ -226,7 +226,7 @@ const iterable = list => ({
226
226
  let i = list
227
227
  while (true) {
228
228
  const r = next(i)
229
- if (r === undefined) { return }
229
+ if (r === null) { return }
230
230
  yield r.first
231
231
  i = r.tail
232
232
  }
package/fsm/module.f.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const list = require('../types/list/module.f.cjs')
2
- const { equal, isEmpty, fold, toArray, scan, foldScan } = list
2
+ const { equal, isEmpty, fold, toArray, scan, foldScan, empty: emptyList } = list
3
3
  const byteSet = require('../types/byte_set/module.f.cjs')
4
4
  const { toRangeMap, union: byteSetUnion, one, empty } = byteSet
5
5
  const sortedSet = require('../types/sorted_set/module.f.cjs')
@@ -66,7 +66,7 @@ const scanFetch = scan(fetchOp)
66
66
  const addEntry = grammar => set => dfa => {
67
67
  const s = stringifyIdentity(set)
68
68
  if (s in dfa) { return dfa }
69
- const setMap = fold(foldOp(set))(undefined)(grammar)
69
+ const setMap = fold(foldOp(set))(emptyList)(grammar)
70
70
  const stringMap = toArray(scanStringify(setMap))
71
71
  const newDfa = { ...dfa, [s]: stringMap }
72
72
  const newStates = scanFetch(setMap)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.481",
3
+ "version": "0.0.482",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -30,6 +30,8 @@ const nodeValues = node => () => {
30
30
  const values = map(nodeValues)
31
31
 
32
32
  module.exports = {
33
+ /** @readonly */
34
+ empty: undefined,
33
35
  /** @readonly */
34
36
  find: require('./find/module.f.cjs'),
35
37
  /** @readonly */
@@ -6,6 +6,7 @@ const {
6
6
  set: { set: btreeSet },
7
7
  /** @type {(s: StringSet) => list.List<string>} */
8
8
  values,
9
+ empty,
9
10
  } = btree
10
11
  const { cmp } = require("../string/module.f.cjs")
11
12
  const list = require('../list/module.f.cjs')
@@ -29,6 +30,8 @@ const fromValues = fold(set)(undefined)
29
30
  const remove = compose(cmp)(btreeRemove)
30
31
 
31
32
  module.exports = {
33
+ /** @readonly */
34
+ empty,
32
35
  /** @readonly */
33
36
  contains,
34
37
  /** @readonly */