functionalscript 0.0.350 → 0.0.351

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/com/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # COM (Component Object Model)
2
+
3
+ Basic Types: `f32`, `f64`, `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `usize`, `isize`, `bool`, ``.
package/com/main.f.js ADDED
@@ -0,0 +1,30 @@
1
+ /** @typedef {{readonly[k in string]: Definition}} Library */
2
+
3
+ /** @typedef {Struct|Interface} Definition */
4
+
5
+ /** @typedef {{readonly struct: FieldArray}} Struct */
6
+
7
+ /** @typedef {readonly Field[]} FieldArray */
8
+
9
+ /** @typedef {[string, Type]} Field */
10
+
11
+ /**
12
+ * @typedef {{
13
+ * readonly interface: MethodArray
14
+ * readonly guid: string
15
+ * }} Interface
16
+ */
17
+
18
+ /** @typedef {readonly Method[]} MethodArray */
19
+
20
+ /** @typedef {readonly[string, FieldArray, Type]} Method */
21
+
22
+ /** @typedef {BaseType|Id|Pointer} Type */
23
+
24
+ /** @typedef {readonly[string]} Id */
25
+
26
+ /** @typedef {'u8'|'i8'|'u16'|'i16'|'u32'|'i32'|'u64'|'i64'|'usize'|'isize'|'f32'|'f64'|'bool'|''} BaseType */
27
+
28
+ /** @typedef {{readonly '*': Type}} Pointer */
29
+
30
+ module.exports = {}
package/com/test.f.js ADDED
@@ -0,0 +1,23 @@
1
+ const _ = require('./main.f.js')
2
+
3
+ /** @type {_.Library} */
4
+ const library = {
5
+ Slice: {
6
+ struct: [
7
+ ['Start', { '*': 'u8' }],
8
+ ['End', 'usize'],
9
+ ]
10
+ },
11
+ IMy: {
12
+ guid: 'C66FB270-2D80-49AD-BB6E-88C1F90B805D',
13
+ interface: [
14
+ ['GetSlice', [], ['Slice']],
15
+ ['SetSlice',
16
+ [['slice', ['Slice']]],
17
+ ''
18
+ ],
19
+ ],
20
+ }
21
+ }
22
+
23
+ module.exports = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.350",
3
+ "version": "0.0.351",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "main.f.js",
6
6
  "scripts": {
package/test.f.js CHANGED
@@ -16,6 +16,7 @@ require('./types/stringset/test.f.js')
16
16
  require('./commonjs/build/test.f.js')
17
17
  require('./types/range/test.f.js')
18
18
  require('./html/test.f.js')
19
+ require('./text/test.f.js')
19
20
 
20
21
  /** @type {() => never} */
21
22
  const assert = () => { throw 'assert' }
package/text/main.f.js ADDED
@@ -0,0 +1,21 @@
1
+ const list = require('../types/list/main.f.js')
2
+
3
+ /** @typedef {readonly Item[]} Text */
4
+
5
+ /** @typedef {string|Text} Item */
6
+
7
+ /** @type {(indent: string) => (text: Text) => list.List<string>} */
8
+ const flat = indent => {
9
+ /** @type {(v: string) => string} */
10
+ const indentFn = v => `${indent}${v}`
11
+ const map = list.map(indentFn)
12
+ /** @type {(item: Item) => list.List<string>} */
13
+ const flatItem = item => typeof(item) === 'string' ? [item] : map(flatText(item))
14
+ const flatText = list.flatMap(flatItem)
15
+ return flatText
16
+ }
17
+
18
+ module.exports = {
19
+ /** @readonly */
20
+ flat,
21
+ }
package/text/test.f.js ADDED
@@ -0,0 +1,18 @@
1
+ const _ = require('./main.f.js')
2
+ const list = require('../types/list/main.f.js')
3
+
4
+ {
5
+ /** @type {_.Text} */
6
+ const text = [
7
+ 'a',
8
+ 'b',
9
+ [
10
+ 'c',
11
+ ['d'],
12
+ ]
13
+ ]
14
+ const result = list.join('\n')(_.flat('_')(text))
15
+ if (result !== 'a\nb\n_c\n__d') { throw result }
16
+ }
17
+
18
+ module.exports = {}