functionalscript 0.0.361 → 0.0.364

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.
Files changed (74) hide show
  1. package/.github/workflows/bun.yml +2 -2
  2. package/.github/workflows/deno.yml +1 -1
  3. package/com/cpp/com.hpp +47 -0
  4. package/com/cpp/main.f.cjs +10 -0
  5. package/com/cpp/test/build.cjs +11 -0
  6. package/com/cpp/test/main.cpp +5 -0
  7. package/com/cpp/test.f.cjs +3 -0
  8. package/com/cs/{main.f.js → main.f.cjs} +40 -36
  9. package/com/cs/test/{build.js → build.cjs} +2 -2
  10. package/com/cs/{test.f.js → test.f.cjs} +17 -14
  11. package/com/{main.f.js → main.f.cjs} +1 -1
  12. package/com/types/{main.f.js → main.f.cjs} +3 -9
  13. package/commonjs/build/{main.f.js → main.f.cjs} +7 -7
  14. package/commonjs/build/{test.f.js → test.f.cjs} +6 -6
  15. package/commonjs/{main.f.js → main.f.cjs} +8 -8
  16. package/commonjs/module/function/{main.f.js → main.f.cjs} +1 -1
  17. package/commonjs/module/{main.f.js → main.f.cjs} +2 -2
  18. package/commonjs/package/dependencies/{main.f.js → main.f.cjs} +2 -2
  19. package/commonjs/package/dependencies/{test.f.js → test.f.cjs} +1 -1
  20. package/commonjs/package/{main.f.js → main.f.cjs} +2 -2
  21. package/commonjs/package/{test.f.js → test.f.cjs} +2 -2
  22. package/commonjs/path/{main.f.js → main.f.cjs} +4 -4
  23. package/commonjs/path/{test.f.js → test.f.cjs} +7 -7
  24. package/dev/{main.f.js → main.f.cjs} +0 -0
  25. package/doc/README.md +9 -6
  26. package/html/{main.f.js → main.f.cjs} +4 -4
  27. package/html/{test.f.js → test.f.cjs} +1 -1
  28. package/io/commonjs/{main.js → main.cjs} +3 -3
  29. package/io/commonjs/{test.js → test.cjs} +2 -2
  30. package/io/nodejs/version/{main.js → main.cjs} +0 -0
  31. package/io/result/{main.js → main.cjs} +1 -1
  32. package/json/{main.f.js → main.f.cjs} +5 -5
  33. package/json/{test.f.js → test.f.cjs} +3 -3
  34. package/json/tokenizer/{main.f.js → main.f.cjs} +3 -3
  35. package/json/tokenizer/{test.f.js → test.f.cjs} +5 -5
  36. package/main.f.cjs +14 -0
  37. package/package.json +4 -4
  38. package/sha2/{main.f.js → main.f.cjs} +1 -1
  39. package/sha2/{test.f.js → test.f.cjs} +4 -4
  40. package/{test.f.js → test.f.cjs} +20 -20
  41. package/text/encoding/{main.f.js → main.f.cjs} +4 -4
  42. package/text/encoding/{test.f.js → test.f.cjs} +4 -4
  43. package/text/{main.f.js → main.f.cjs} +6 -1
  44. package/text/{test.f.js → test.f.cjs} +2 -2
  45. package/types/array/{main.f.js → main.f.cjs} +1 -1
  46. package/types/array/{test.f.js → test.f.cjs} +3 -3
  47. package/types/btree/find/{main.f.js → main.f.cjs} +4 -4
  48. package/types/btree/find/{test.f.js → test.f.cjs} +7 -7
  49. package/types/btree/{main.f.js → main.f.cjs} +6 -6
  50. package/types/btree/remove/{main.f.js → main.f.cjs} +6 -6
  51. package/types/btree/remove/{test.f.js → test.f.cjs} +6 -6
  52. package/types/btree/set/{main.f.js → main.f.cjs} +4 -4
  53. package/types/btree/set/{test.f.js → test.f.cjs} +5 -5
  54. package/types/btree/{test.f.js → test.f.cjs} +11 -11
  55. package/types/btree/types/{main.f.js → main.f.cjs} +0 -0
  56. package/types/function/compare/{main.f.js → main.f.cjs} +1 -1
  57. package/types/function/compare/{test.f.js → test.f.cjs} +1 -1
  58. package/types/function/{main.f.js → main.f.cjs} +2 -2
  59. package/types/function/operator/{main.f.js → main.f.cjs} +0 -0
  60. package/types/list/{main.f.js → main.f.cjs} +22 -25
  61. package/types/list/{test.f.js → test.f.cjs} +6 -6
  62. package/types/main.f.cjs +20 -0
  63. package/types/map/{main.f.js → main.f.cjs} +9 -9
  64. package/types/map/{test.f.js → test.f.cjs} +3 -3
  65. package/types/object/{main.f.js → main.f.cjs} +2 -2
  66. package/types/object/{test.f.js → test.f.cjs} +1 -1
  67. package/types/option/{main.f.js → main.f.cjs} +0 -0
  68. package/types/range/{main.f.js → main.f.cjs} +0 -0
  69. package/types/range/{test.f.js → test.f.cjs} +1 -1
  70. package/types/result/{main.f.js → main.f.cjs} +0 -0
  71. package/types/stringset/{main.f.js → main.f.cjs} +5 -5
  72. package/types/stringset/{test.f.js → test.f.cjs} +1 -1
  73. package/main.f.js +0 -14
  74. package/types/main.f.js +0 -20
@@ -11,5 +11,5 @@ jobs:
11
11
 
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
- - run: curl https://bun.sh/install | bash
15
- - run: /home/runner/.bun/bin/bun ./test.f.js
14
+ - run: curl https://bun.sh/install | bash
15
+ - run: /home/runner/.bun/bin/bun ./test.f.cjs
@@ -14,4 +14,4 @@ jobs:
14
14
  - uses: denoland/setup-deno@v1
15
15
  with:
16
16
  deno-version: v1.x
17
- - run: deno run --unstable --compat --allow-read --allow-env ./test.f.js
17
+ - run: deno run --unstable --compat --allow-read --allow-env ./test.f.cjs
@@ -0,0 +1,47 @@
1
+ #ifndef COM_HPP
2
+ #define COM_HPP
3
+
4
+ #include <cstdint>
5
+
6
+ namespace com
7
+ {
8
+ class GUID
9
+ {
10
+ public:
11
+ uint64_t hi;
12
+ uint64_t lo;
13
+ };
14
+
15
+ typedef uint32_t HRESULT;
16
+ typedef uint32_t ULONG;
17
+
18
+ class IUnknown
19
+ {
20
+ public:
21
+ virtual HRESULT __stdcall QueryInterface(GUID const &riid, IUnknown **const ppvObject) noexcept = 0;
22
+ virtual ULONG __stdcall AddRef() noexcept = 0;
23
+ virtual ULONG __stdcall Release() noexcept = 0;
24
+ };
25
+
26
+ template <class I>
27
+ class Ref
28
+ {
29
+ public:
30
+ explicit Ref(I &other) noexcept : p(other.p)
31
+ {
32
+ p.AddRef();
33
+ }
34
+ Ref(Ref const &other) noexcept : Ref(other.p)
35
+ {
36
+ }
37
+ ~Ref() noexcept
38
+ {
39
+ p.Release();
40
+ }
41
+
42
+ private:
43
+ I &p;
44
+ };
45
+ }
46
+
47
+ #endif
@@ -0,0 +1,10 @@
1
+ const types = require('../types/main.f.cjs')
2
+ const text = require('../../text/main.f.cjs')
3
+
4
+ /** @type {(name: string) => (library: types.Library) => text.Block} */
5
+ const cpp = name => lib => []
6
+
7
+ module.exports = {
8
+ /** @readonly */
9
+ cpp,
10
+ }
@@ -0,0 +1,11 @@
1
+ const fs = require('node:fs')
2
+ const cp = require('node:child_process')
3
+ // const cs = require('../test.f.js').result
4
+
5
+ // fs.writeFileSync('_result.cpp', cs)
6
+ try {
7
+ console.log(cp.execSync('clang main.cpp').toString())
8
+ } catch (e) {
9
+ // @ts-ignore
10
+ console.error(e.output.toString())
11
+ }
@@ -0,0 +1,5 @@
1
+ #include "../com.hpp"
2
+
3
+ int main()
4
+ {
5
+ }
@@ -0,0 +1,3 @@
1
+ const _ = require('./main.f.cjs')
2
+
3
+ module.exports = {}
@@ -1,13 +1,10 @@
1
- const types = require('../types/main.f.js')
2
- const text = require('../../text/main.f.js')
3
- const list = require('../../types/list/main.f.js')
4
- const obj = require('../../types/object/main.f.js')
1
+ const types = require('../types/main.f.cjs')
2
+ const text = require('../../text/main.f.cjs')
3
+ const list = require('../../types/list/main.f.cjs')
4
+ const obj = require('../../types/object/main.f.cjs')
5
5
 
6
6
  /** @type {(v: string) => string} */
7
- const csUsing = v => `using ${v};`
8
-
9
- /** @type {(type: string) => (name: string) => (body: text.Block) => text.Block} */
10
- const csBlock = type => name => body => [`${type} ${name}`, '{', body, '}']
7
+ const using = v => `using ${v};`
11
8
 
12
9
  /**
13
10
  * @type {(attributes: list.List<string>) =>
@@ -16,14 +13,14 @@ const csBlock = type => name => body => [`${type} ${name}`, '{', body, '}']
16
13
  * (body: text.Block) =>
17
14
  * list.List<text.Item>}
18
15
  */
19
- const csTypeDef = attributes => type => name => body =>
16
+ const typeDef = attributes => type => name => body =>
20
17
  list.flat([
21
18
  list.map(v => `[${v}]`)(attributes),
22
- csBlock(`public ${type}`)(name)(body)
19
+ text.curly(`public ${type}`)(name)(body)
23
20
  ])
24
21
 
25
22
  /** @type {(t: types.BaseType) => string} */
26
- const csBaseType = t => {
23
+ const baseType = t => {
27
24
  switch (t) {
28
25
  case 'bool': return 'bool'
29
26
  case 'f32': return 'float'
@@ -45,65 +42,72 @@ const csBaseType = t => {
45
42
  const unsafe = isUnsafe => isUnsafe ? 'unsafe ' : ''
46
43
 
47
44
  /** @type {(t: types.Type) => readonly[boolean, string]} */
48
- const csType = t =>
49
- typeof (t) === 'string' ? [false, csBaseType(t)] :
50
- t instanceof Array ? [false, t[0]] :
51
- [true, `${csType(t['*'])[1]}*`]
45
+ const type = t =>
46
+ typeof (t) === 'string' ? [false, baseType(t)] :
47
+ t.length === 1 ? [false, t[0]] :
48
+ [true, `${type(t[1])[1]}*`]
52
49
 
53
50
  /** @type {(f: types.Field) => string} */
54
- const csParam = ([name, type]) => `${csType(type)[1]} ${name}`
51
+ const param = ([name, t]) => `${type(t)[1]} ${name}`
55
52
 
56
53
  /** @type {(f: types.Field) => string} */
57
- const csField = ([name, type]) => {
58
- const [isUnsafe, t] = csType(type)
54
+ const field = ([name, comType]) => {
55
+ const [isUnsafe, t] = type(comType)
59
56
  return `public ${unsafe(isUnsafe)}${t} ${name};`
60
57
  }
61
58
 
62
- /** @type {(m: types.Method) => readonly[boolean, string]} */
63
- const csResult = m => m.length === 2 ? [false, 'void'] : csType(m[2])
59
+ /** @type {(m: types.FieldArray) => string} */
60
+ const result = m => {
61
+ const result = m._
62
+ return result === undefined ? 'void' : type(result)[1]
63
+ }
64
64
 
65
65
  /** @type {(field: types.Field) => boolean} */
66
- const isUnsafeField = field => csType(field[1])[0]
66
+ const isUnsafeField = field => type(field[1])[0]
67
+
68
+ /** @type {(kv: obj.Entry<types.Type>) => boolean} */
69
+ const isParam = kv => kv[0] !== '_'
67
70
 
68
- /** @type {(m: types.Method) => readonly string[]} */
69
- const csMethod = m => {
70
- const result = csResult(m)
71
- const isUnsafe = result[0] || list.some(list.map(isUnsafeField)(m[1]))
71
+ /** @type {(e: obj.Entry<types.FieldArray>) => readonly string[]} */
72
+ const method = ([name, m]) => {
73
+ const paramAndResultList = Object.entries(m)
74
+ const paramList = list.filter(isParam)(paramAndResultList)
75
+ const isUnsafe = list.some(list.map(isUnsafeField)(paramAndResultList))
72
76
  return [
73
77
  '[PreserveSig]',
74
- `${unsafe(isUnsafe)}${result[1]} ${m[0]}(${list.join(', ')(list.map(csParam)(m[1]))});`
78
+ `${unsafe(isUnsafe)}${result(m)} ${name}(${list.join(', ')(list.map(param)(paramList))});`
75
79
  ]
76
80
  }
77
81
 
78
82
  /** @type {(e: obj.Entry<types.Definition>) => list.List<text.Item>} */
79
- const csDef = ([n, d]) => {
83
+ const def = ([n, d]) => {
80
84
  const i = d.interface
81
85
  return i === undefined ?
82
- csTypeDef
86
+ typeDef
83
87
  (['StructLayout(LayoutKind.Sequential)'])
84
88
  ('struct')
85
89
  (n)
86
- (() => list.map(csField)(d.struct)) :
87
- csTypeDef
90
+ (list.map(field)(Object.entries(d.struct))) :
91
+ typeDef
88
92
  ([`Guid("${d.guid}")`, 'InterfaceType(ComInterfaceType.InterfaceIsIUnknown)'])
89
93
  ('interface')
90
94
  (n)
91
- (() => list.flatMap(csMethod)(d.interface))
95
+ (list.flatMap(method)(Object.entries(d.interface)))
92
96
  }
93
97
 
94
98
  /** @type {(name: string) => (library: types.Library) => text.Block} */
95
99
  const cs = name => library => {
96
- const v = list.flatMap(csDef)(Object.entries(library))
100
+ const v = list.flatMap(def)(Object.entries(library))
97
101
 
98
102
  /** @type {text.Block} */
99
103
  const h = [
100
- csUsing('System'),
101
- csUsing('System.Runtime.InteropServices'),
104
+ using('System'),
105
+ using('System.Runtime.InteropServices'),
102
106
  ''
103
107
  ]
104
108
 
105
- const ns = csBlock('namespace')(name)(() => v)
106
- return () => list.flat([h, ns])
109
+ const ns = text.curly('namespace')(name)(() => v)
110
+ return list.flat([h, ns])
107
111
  }
108
112
 
109
113
  module.exports = {
@@ -1,11 +1,11 @@
1
1
  const fs = require('node:fs')
2
2
  const cp = require('node:child_process')
3
- const cs = require('../test.f.js').result
3
+ const cs = require('../test.f.cjs').result
4
4
 
5
5
  fs.writeFileSync('_result.cs', cs)
6
6
  try {
7
7
  console.log(cp.execSync('dotnet build').toString())
8
8
  } catch (e) {
9
9
  // @ts-ignore
10
- console.log(e.output.toString())
10
+ console.error(e.output.toString())
11
11
  }
@@ -1,24 +1,27 @@
1
- const types = require('../types/main.f.js')
2
- const _ = require('./main.f.js')
3
- const list = require('../../types/list/main.f.js')
4
- const text = require('../../text/main.f.js')
1
+ const types = require('../types/main.f.cjs')
2
+ const _ = require('./main.f.cjs')
3
+ const list = require('../../types/list/main.f.cjs')
4
+ const text = require('../../text/main.f.cjs')
5
5
 
6
6
  /** @type {types.Library} */
7
7
  const library = {
8
8
  Slice: {
9
- struct: [
10
- ['Start', { '*': 'u8' }],
11
- ['Size', 'usize'],
12
- ]
9
+ struct: {
10
+ Start: ['*', 'u8'],
11
+ Size: 'usize',
12
+ },
13
13
  },
14
14
  IMy: {
15
15
  guid: 'C66FB270-2D80-49AD-BB6E-88C1F90B805D',
16
- interface: [
17
- ['GetSlice', [], ['Slice']],
18
- ['SetSlice', [['slice', ['Slice']]]],
19
- ['GetUnsafe', [], {'*': 'bool'}],
20
- ['SetUnsafe', [['p', {'*': ['Slice']}], ['size', 'u32']]],
21
- ],
16
+ interface: {
17
+ GetSlice: { _: ['Slice'] },
18
+ SetSlice: { slice: ['Slice'] },
19
+ GetUnsafe: { _: ['*', 'bool'] },
20
+ SetUnsafe: {
21
+ p: ['*', ['Slice']],
22
+ size: 'u32'
23
+ },
24
+ },
22
25
  }
23
26
  }
24
27
 
@@ -1,4 +1,4 @@
1
- const types = require('./types/main.f.js');
1
+ const types = require('./types/main.f.cjs');
2
2
 
3
3
  module.exports = {
4
4
  /** @readonly */
@@ -9,7 +9,7 @@
9
9
  * }} Struct
10
10
  */
11
11
 
12
- /** @typedef {readonly Field[]} FieldArray */
12
+ /** @typedef {{readonly[k in string]: Type}} FieldArray */
13
13
 
14
14
  /** @typedef {readonly[string, Type]} Field */
15
15
 
@@ -20,13 +20,7 @@
20
20
  * }} Interface
21
21
  */
22
22
 
23
- /** @typedef {readonly Method[]} MethodArray */
24
-
25
- /** @typedef {readonly[string, FieldArray, Type]} GetMethod */
26
-
27
- /** @typedef {readonly[string, FieldArray]} SetMethod */
28
-
29
- /** @typedef {GetMethod|SetMethod} Method */
23
+ /** @typedef {{readonly[k in string]: FieldArray}} MethodArray */
30
24
 
31
25
  /** @typedef {BaseType|Id|Pointer} Type */
32
26
 
@@ -50,6 +44,6 @@
50
44
  * } BaseType
51
45
  */
52
46
 
53
- /** @typedef {{readonly '*': Type}} Pointer */
47
+ /** @typedef {readonly['*', Type]} Pointer */
54
48
 
55
49
  module.exports = {}
@@ -1,10 +1,10 @@
1
- const package_ = require('../package/main.f.js')
2
- const module_ = require('../module/main.f.js')
3
- const function_ = require('../module/function/main.f.js')
4
- const map = require('../../types/map/main.f.js')
5
- const object = require('../../types/object/main.f.js')
6
- const path = require('../path/main.f.js')
7
- const stringSet = require('../../types/stringset/main.f.js')
1
+ const package_ = require('../package/main.f.cjs')
2
+ const module_ = require('../module/main.f.cjs')
3
+ const function_ = require('../module/function/main.f.cjs')
4
+ const map = require('../../types/map/main.f.cjs')
5
+ const object = require('../../types/object/main.f.cjs')
6
+ const path = require('../path/main.f.cjs')
7
+ const stringSet = require('../../types/stringset/main.f.cjs')
8
8
 
9
9
  /**
10
10
  * @template M
@@ -1,9 +1,9 @@
1
- const _ = require('./main.f.js')
2
- const map = require('../../types/map/main.f.js')
3
- const module_ = require('../module/main.f.js')
4
- const function_ = require('../module/function/main.f.js')
5
- const result = require('../../types/result/main.f.js')
6
- const package_ = require('../package/main.f.js')
1
+ const _ = require('./main.f.cjs')
2
+ const map = require('../../types/map/main.f.cjs')
3
+ const module_ = require('../module/main.f.cjs')
4
+ const function_ = require('../module/function/main.f.cjs')
5
+ const result = require('../../types/result/main.f.cjs')
6
+ const package_ = require('../package/main.f.cjs')
7
7
 
8
8
  /** @type {{ readonly [k in string]?: result.Result<function_.Function_, unknown> }} */
9
9
  const compileMap = {
@@ -1,20 +1,20 @@
1
1
  /** @typedef {(packageName: string) => PackageMap|Package|undefined} PackageMap */
2
2
 
3
- /**
3
+ /**
4
4
  * @typedef {readonly[
5
- * string,
6
- * PackageMap,
5
+ * string,
6
+ * PackageMap,
7
7
  * (fileName: string) => string|undefined
8
- * ]} Package
8
+ * ]} Package
9
9
  */
10
10
 
11
11
  module.exports = {
12
12
  /** @readonly */
13
- build: require('./build/main.f.js'),
13
+ build: require('./build/main.f.cjs'),
14
14
  /** @readonly */
15
- module: require('./module/main.f.js'),
15
+ module: require('./module/main.f.cjs'),
16
16
  /** @readonly */
17
- package: require('./package/main.f.js'),
17
+ package: require('./package/main.f.cjs'),
18
18
  /** @readonly */
19
- path: require('./path/main.f.js'),
19
+ path: require('./path/main.f.cjs'),
20
20
  }
@@ -2,7 +2,7 @@
2
2
  * An IO interface for creating and running module functions.
3
3
  */
4
4
 
5
- const result = require('../../../types/result/main.f.js')
5
+ const result = require('../../../types/result/main.f.cjs')
6
6
 
7
7
  /** @typedef {<M>(require: Require<M>) => (prior: M) => Result<M>} Function_ */
8
8
 
@@ -1,4 +1,4 @@
1
- const object = require('../../types/object/main.f.js')
1
+ const object = require('../../types/object/main.f.cjs')
2
2
 
3
3
  /**
4
4
  * @template M
@@ -53,7 +53,7 @@ const idToString = id => `${id.package}/${id.path.join('/')}`
53
53
 
54
54
  module.exports = {
55
55
  /** @readonly */
56
- function: require('./function/main.f.js'),
56
+ function: require('./function/main.f.cjs'),
57
57
  /** @readonly */
58
58
  dir,
59
59
  /** @readonly */
@@ -1,5 +1,5 @@
1
- const json = require('../../../json/main.f.js')
2
- const list = require('../../../types/list/main.f.js')
1
+ const json = require('../../../json/main.f.cjs')
2
+ const list = require('../../../types/list/main.f.cjs')
3
3
 
4
4
  /** @typedef {readonly[string, string]} DependencyJson */
5
5
 
@@ -1,4 +1,4 @@
1
- const _ = require('./main.f.js')
1
+ const _ = require('./main.f.cjs')
2
2
 
3
3
  {
4
4
  if (!_.isDependenciesJson(undefined)) { throw 'error' }
@@ -1,5 +1,5 @@
1
- const json = require('../../json/main.f.js')
2
- const dependencies = require('./dependencies/main.f.js')
1
+ const json = require('../../json/main.f.cjs')
2
+ const dependencies = require('./dependencies/main.f.cjs')
3
3
 
4
4
  /**
5
5
  * @typedef {{
@@ -1,6 +1,6 @@
1
- const _ = require('./main.f.js')
1
+ const _ = require('./main.f.cjs')
2
2
 
3
- require('./dependencies/test.f.js')
3
+ require('./dependencies/test.f.cjs')
4
4
 
5
5
  {
6
6
  if (_.isPackageJson(null)) { throw 'error' }
@@ -1,6 +1,6 @@
1
- const list = require("../../types/list/main.f.js")
2
- const package_ = require("../package/main.f.js")
3
- const module_ = require("../module/main.f.js")
1
+ const list = require("../../types/list/main.f.cjs")
2
+ const package_ = require("../package/main.f.cjs")
3
+ const module_ = require("../module/main.f.cjs")
4
4
 
5
5
  /** @typedef {readonly string[]} Items */
6
6
 
@@ -98,7 +98,7 @@ const mapDependency = d => ([external, internal]) => {
98
98
  * (items: list.List<string>) =>
99
99
  * Path|undefined}
100
100
  */
101
- const parseGlobal = dependencies =>
101
+ const parseGlobal = dependencies =>
102
102
  {
103
103
  const filterMap = list.filterMap(mapDependency(dependencies))
104
104
  return dir => items => {
@@ -1,10 +1,10 @@
1
- const _ = require('./main.f.js')
2
- const { todo } = require('../../dev/main.f.js')
3
- const json = require('../../json/main.f.js')
4
- const { identity } = require('../../types/function/main.f.js')
5
- const object = require('../../types/object/main.f.js')
6
- const { at } = require('../../types/object/main.f.js')
7
- const package_ = require('../package/main.f.js')
1
+ const _ = require('./main.f.cjs')
2
+ const { todo } = require('../../dev/main.f.cjs')
3
+ const json = require('../../json/main.f.cjs')
4
+ const { identity } = require('../../types/function/main.f.cjs')
5
+ const object = require('../../types/object/main.f.cjs')
6
+ const { at } = require('../../types/object/main.f.cjs')
7
+ const package_ = require('../package/main.f.cjs')
8
8
 
9
9
  /** @type {(g: json.Unknown|undefined) => string} */
10
10
  const stringify = g => {
File without changes
package/doc/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Documentation
2
2
 
3
+ FunctionalScript files have `.f.cjs` file extensions because it's using a `Common.JS` module system. See
4
+ [ESM. Resolver Algorithm Specification](https://nodejs.org/api/esm.html#resolver-algorithm-specification).
5
+
3
6
  ## 1. Creating a New Repository
4
7
 
5
8
  Creating from a template https://github.com/functionalscript/template/generate
6
9
 
7
- ## 1.1. Creating From Scratch
10
+ ## 1.1. Creating From Scratch
8
11
 
9
12
  Prerequisites:
10
13
 
@@ -16,10 +19,10 @@ Creating a new GitHub repository
16
19
 
17
20
  1. Create a public git repository on GitHub using Node template.
18
21
  2. Clone the repository.
19
- 3. Go to the root directory of the cloned repository.
22
+ 3. Go to the root directory of the cloned repository.
20
23
  4. Run `npm init`. It should create `package.json` file.
21
- 5. Create an `index.js` file in the repository root directory.
22
- 6. Edit the `index.js` file. For example
24
+ 5. Create a `main.f.cjs` file in the repository root directory.
25
+ 6. Edit the `main.f.cjs` file. For example
23
26
  ```js
24
27
  module.exports = "Hello world!"
25
28
  ```
@@ -54,7 +57,7 @@ module.exports = x => x * x
54
57
  #### 2.2.1. Local File
55
58
 
56
59
  ```js
57
- const x = require('./folder/index.js')
60
+ const x = require('./folder/main.f.cjs')
58
61
  ```
59
62
 
60
63
  ### 2.2.2. External Module
@@ -62,7 +65,7 @@ const x = require('./folder/index.js')
62
65
  Run `npm install -D github:USER/REPO`
63
66
 
64
67
  ```js
65
- const x = require(`REPO/DIR/FILE.js`)
68
+ const x = require(`REPO/DIR/FILE.f.cjs`)
66
69
  ```
67
70
 
68
71
  ### 2.3. Functions
@@ -1,6 +1,6 @@
1
- const list = require('../types/list/main.f.js')
2
- const object = require('../types/object/main.f.js')
3
- const { operator, compose } = require('../types/function/main.f.js')
1
+ const list = require('../types/list/main.f.cjs')
2
+ const object = require('../types/object/main.f.cjs')
3
+ const { operator, compose } = require('../types/function/main.f.cjs')
4
4
 
5
5
  /**
6
6
  * @typedef {|
@@ -73,7 +73,7 @@ const escapeCharCode = code => {
73
73
  }
74
74
  }
75
75
 
76
- const escape = compose(list.toCharCodes)(list.map(escapeCharCode))
76
+ const escape = compose(list.toCharCodeList)(list.map(escapeCharCode))
77
77
 
78
78
  /** @type {(n: Node) => list.List<string>} */
79
79
  const node = n => typeof n === 'string' ? escape(n) : element(n)
@@ -1,4 +1,4 @@
1
- const _ = require('./main.f.js')
1
+ const _ = require('./main.f.cjs')
2
2
 
3
3
  {
4
4
  const r = _.htmlToString(['html', []])
@@ -1,6 +1,6 @@
1
- const { tryCatch } = require('../result/main.js')
2
- const { unwrap } = require('../../types/result/main.f.js')
3
- const moduleFunction = require('../../commonjs/module/function/main.f.js')
1
+ const { tryCatch } = require('../result/main.cjs')
2
+ const { unwrap } = require('../../types/result/main.f.cjs')
3
+ const moduleFunction = require('../../commonjs/module/function/main.f.cjs')
4
4
 
5
5
  /** @type {(f: Function) => moduleFunction.Function_} */
6
6
  const build = f => immutableRequire => mutableData => {
@@ -1,5 +1,5 @@
1
- const _ = require('./main.js')
2
- const run = require('../../commonjs/module/function/main.f.js')
1
+ const _ = require('./main.cjs')
2
+ const run = require('../../commonjs/module/function/main.f.cjs')
3
3
 
4
4
  // ok:
5
5
  {
File without changes
@@ -1,4 +1,4 @@
1
- const result = require('../../types/result/main.f.js')
1
+ const result = require('../../types/result/main.f.cjs')
2
2
 
3
3
  /** @type {<T>(f: () => T) => result.Result<T, unknown>} */
4
4
  const tryCatch = f => {
@@ -1,7 +1,7 @@
1
- const list = require('../types/list/main.f.js')
2
- const object = require('../types/object/main.f.js')
3
- const operator = require('../types/function/operator/main.f.js')
4
- const { compose } = require('../types/function/main.f.js')
1
+ const list = require('../types/list/main.f.cjs')
2
+ const object = require('../types/object/main.f.cjs')
3
+ const operator = require('../types/function/operator/main.f.cjs')
4
+ const { compose } = require('../types/function/main.f.cjs')
5
5
 
6
6
  /**
7
7
  * @typedef {{
@@ -111,7 +111,7 @@ const isObject = value => typeof value === 'object' && value !== null && !(value
111
111
 
112
112
  module.exports = {
113
113
  /** @readonly */
114
- tokenizer: require('./tokenizer/main.f.js'),
114
+ tokenizer: require('./tokenizer/main.f.cjs'),
115
115
  /** @readonly */
116
116
  setProperty,
117
117
  /** @readonly */
@@ -1,6 +1,6 @@
1
- const json = require('./main.f.js')
2
- const { sort } = require('../types/object/main.f.js')
3
- const { identity } = require('../types/function/main.f.js')
1
+ const json = require('./main.f.cjs')
2
+ const { sort } = require('../types/object/main.f.cjs')
3
+ const { identity } = require('../types/function/main.f.cjs')
4
4
 
5
5
  if (json.setProperty("Hello")([])({}) !== "Hello") { throw 'error' }
6
6