functionalscript 0.0.431 → 0.0.432

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.
@@ -1,3 +1,6 @@
1
+ const list = require('../../types/list/module.f.cjs')
2
+ const { fold } = list
3
+
1
4
  /**
2
5
  * @typedef {{
3
6
  * readonly[k in string]?: Module
@@ -31,6 +34,9 @@
31
34
  * }} Input
32
35
  */
33
36
 
37
+ /** @type {(s: string) => boolean} */
38
+ const isTest = s => s.endsWith('test.f.cjs')
39
+
34
40
  /** @type {<T>(input: Input<T>) => T} */
35
41
  const main = ({moduleMap, log, state}) => {
36
42
  /** @typedef {log extends Log<infer T> ? T : never} T */
@@ -47,15 +53,17 @@ const main = ({moduleMap, log, state}) => {
47
53
  break
48
54
  }
49
55
  case 'object': {
56
+ /** @type {(k: readonly[string|number, unknown]) => (state: T) => T} */
57
+ const f = ([k, v]) => state => {
58
+ state = log(`${i}${k}:`)(state)
59
+ state = next(v)(state)
60
+ return state
61
+ }
62
+ const foldF = fold(f)(state)
50
63
  if (v instanceof Array) {
51
- for (const v2 of v) {
52
- state = next(v2)(state)
53
- }
64
+ state = foldF(list.entries(v))
54
65
  } else if (v !== null) {
55
- for (const [k, v2] of Object.entries(v)) {
56
- state = log(`${i}${k}:`)(state)
57
- state = next(v2)(state)
58
- }
66
+ state = foldF(Object.entries(v))
59
67
  }
60
68
  break
61
69
  }
@@ -63,13 +71,15 @@ const main = ({moduleMap, log, state}) => {
63
71
  return state
64
72
  }
65
73
  const next = test('| ')
66
- for (const [k, v] of Object.entries(moduleMap)) {
67
- if (k.endsWith('test.f.cjs')) {
74
+ /** @type {(k: readonly[string, Module]) => (state: T) => T} */
75
+ const f = ([k, v]) => state => {
76
+ if (isTest(k)) {
68
77
  state = log(`testing ${k}`)(state)
69
78
  state = next(v.exports)(state)
70
79
  }
80
+ return state
71
81
  }
72
- return state
82
+ return fold(f)(state)(Object.entries(moduleMap))
73
83
  }
74
84
 
75
85
  module.exports = main
@@ -1,5 +1,3 @@
1
- const i = require('./module.f.cjs')
2
-
3
1
  /** @type {() => never} */
4
2
  const assert = () => { throw 'assert' }
5
3
 
package/module.f.cjs CHANGED
@@ -1,14 +1,22 @@
1
1
  module.exports = {
2
+ /** @readonly */
3
+ com: require('./com/module.f.cjs'),
2
4
  /** @readonly */
3
5
  commonjs: require('./commonjs/module.f.cjs'),
4
6
  /** @readonly */
5
7
  dev: require('./dev/module.f.cjs'),
6
8
  /** @readonly */
9
+ fsm: require('./fsm/module.f.cjs'),
10
+ /** @readonly */
7
11
  html: require('./html/module.f.cjs'),
8
12
  /** @readonly */
9
13
  json: require('./json/module.f.cjs'),
10
14
  /** @readonly */
15
+ nodejs: require('./nodejs/module.f.cjs'),
16
+ /** @readonly */
11
17
  sha2: require('./sha2/module.f.cjs'),
12
18
  /** @readonly */
19
+ text: require('./text/module.f.cjs'),
20
+ /** @readonly */
13
21
  types: require('./types/module.f.cjs'),
14
22
  }
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ /** @readonly */
3
+ version: require('./version/module.f.cjs')
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.431",
3
+ "version": "0.0.432",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {