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.
- package/.github/workflows/bun.yml +2 -2
- package/.github/workflows/deno.yml +1 -1
- package/com/cpp/com.hpp +47 -0
- package/com/cpp/main.f.cjs +10 -0
- package/com/cpp/test/build.cjs +11 -0
- package/com/cpp/test/main.cpp +5 -0
- package/com/cpp/test.f.cjs +3 -0
- package/com/cs/{main.f.js → main.f.cjs} +40 -36
- package/com/cs/test/{build.js → build.cjs} +2 -2
- package/com/cs/{test.f.js → test.f.cjs} +17 -14
- package/com/{main.f.js → main.f.cjs} +1 -1
- package/com/types/{main.f.js → main.f.cjs} +3 -9
- package/commonjs/build/{main.f.js → main.f.cjs} +7 -7
- package/commonjs/build/{test.f.js → test.f.cjs} +6 -6
- package/commonjs/{main.f.js → main.f.cjs} +8 -8
- package/commonjs/module/function/{main.f.js → main.f.cjs} +1 -1
- package/commonjs/module/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/dependencies/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/dependencies/{test.f.js → test.f.cjs} +1 -1
- package/commonjs/package/{main.f.js → main.f.cjs} +2 -2
- package/commonjs/package/{test.f.js → test.f.cjs} +2 -2
- package/commonjs/path/{main.f.js → main.f.cjs} +4 -4
- package/commonjs/path/{test.f.js → test.f.cjs} +7 -7
- package/dev/{main.f.js → main.f.cjs} +0 -0
- package/doc/README.md +9 -6
- package/html/{main.f.js → main.f.cjs} +4 -4
- package/html/{test.f.js → test.f.cjs} +1 -1
- package/io/commonjs/{main.js → main.cjs} +3 -3
- package/io/commonjs/{test.js → test.cjs} +2 -2
- package/io/nodejs/version/{main.js → main.cjs} +0 -0
- package/io/result/{main.js → main.cjs} +1 -1
- package/json/{main.f.js → main.f.cjs} +5 -5
- package/json/{test.f.js → test.f.cjs} +3 -3
- package/json/tokenizer/{main.f.js → main.f.cjs} +3 -3
- package/json/tokenizer/{test.f.js → test.f.cjs} +5 -5
- package/main.f.cjs +14 -0
- package/package.json +4 -4
- package/sha2/{main.f.js → main.f.cjs} +1 -1
- package/sha2/{test.f.js → test.f.cjs} +4 -4
- package/{test.f.js → test.f.cjs} +20 -20
- package/text/encoding/{main.f.js → main.f.cjs} +4 -4
- package/text/encoding/{test.f.js → test.f.cjs} +4 -4
- package/text/{main.f.js → main.f.cjs} +6 -1
- package/text/{test.f.js → test.f.cjs} +2 -2
- package/types/array/{main.f.js → main.f.cjs} +1 -1
- package/types/array/{test.f.js → test.f.cjs} +3 -3
- package/types/btree/find/{main.f.js → main.f.cjs} +4 -4
- package/types/btree/find/{test.f.js → test.f.cjs} +7 -7
- package/types/btree/{main.f.js → main.f.cjs} +6 -6
- package/types/btree/remove/{main.f.js → main.f.cjs} +6 -6
- package/types/btree/remove/{test.f.js → test.f.cjs} +6 -6
- package/types/btree/set/{main.f.js → main.f.cjs} +4 -4
- package/types/btree/set/{test.f.js → test.f.cjs} +5 -5
- package/types/btree/{test.f.js → test.f.cjs} +11 -11
- package/types/btree/types/{main.f.js → main.f.cjs} +0 -0
- package/types/function/compare/{main.f.js → main.f.cjs} +1 -1
- package/types/function/compare/{test.f.js → test.f.cjs} +1 -1
- package/types/function/{main.f.js → main.f.cjs} +2 -2
- package/types/function/operator/{main.f.js → main.f.cjs} +0 -0
- package/types/list/{main.f.js → main.f.cjs} +22 -25
- package/types/list/{test.f.js → test.f.cjs} +6 -6
- package/types/main.f.cjs +20 -0
- package/types/map/{main.f.js → main.f.cjs} +9 -9
- package/types/map/{test.f.js → test.f.cjs} +3 -3
- package/types/object/{main.f.js → main.f.cjs} +2 -2
- package/types/object/{test.f.js → test.f.cjs} +1 -1
- package/types/option/{main.f.js → main.f.cjs} +0 -0
- package/types/range/{main.f.js → main.f.cjs} +0 -0
- package/types/range/{test.f.js → test.f.cjs} +1 -1
- package/types/result/{main.f.js → main.f.cjs} +0 -0
- package/types/stringset/{main.f.js → main.f.cjs} +5 -5
- package/types/stringset/{test.f.js → test.f.cjs} +1 -1
- package/main.f.js +0 -14
- package/types/main.f.js +0 -20
package/com/cpp/com.hpp
ADDED
|
@@ -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,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
|
+
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
const types = require('../types/main.f.
|
|
2
|
-
const text = require('../../text/main.f.
|
|
3
|
-
const list = require('../../types/list/main.f.
|
|
4
|
-
const obj = require('../../types/object/main.f.
|
|
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
|
|
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
|
|
16
|
+
const typeDef = attributes => type => name => body =>
|
|
20
17
|
list.flat([
|
|
21
18
|
list.map(v => `[${v}]`)(attributes),
|
|
22
|
-
|
|
19
|
+
text.curly(`public ${type}`)(name)(body)
|
|
23
20
|
])
|
|
24
21
|
|
|
25
22
|
/** @type {(t: types.BaseType) => string} */
|
|
26
|
-
const
|
|
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
|
|
49
|
-
typeof (t) === 'string' ? [false,
|
|
50
|
-
t
|
|
51
|
-
[true, `${
|
|
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
|
|
51
|
+
const param = ([name, t]) => `${type(t)[1]} ${name}`
|
|
55
52
|
|
|
56
53
|
/** @type {(f: types.Field) => string} */
|
|
57
|
-
const
|
|
58
|
-
const [isUnsafe, t] =
|
|
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.
|
|
63
|
-
const
|
|
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 =>
|
|
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 {(
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
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
|
|
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
|
|
83
|
+
const def = ([n, d]) => {
|
|
80
84
|
const i = d.interface
|
|
81
85
|
return i === undefined ?
|
|
82
|
-
|
|
86
|
+
typeDef
|
|
83
87
|
(['StructLayout(LayoutKind.Sequential)'])
|
|
84
88
|
('struct')
|
|
85
89
|
(n)
|
|
86
|
-
(
|
|
87
|
-
|
|
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
|
-
(
|
|
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(
|
|
100
|
+
const v = list.flatMap(def)(Object.entries(library))
|
|
97
101
|
|
|
98
102
|
/** @type {text.Block} */
|
|
99
103
|
const h = [
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
using('System'),
|
|
105
|
+
using('System.Runtime.InteropServices'),
|
|
102
106
|
''
|
|
103
107
|
]
|
|
104
108
|
|
|
105
|
-
const ns =
|
|
106
|
-
return
|
|
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.
|
|
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.
|
|
10
|
+
console.error(e.output.toString())
|
|
11
11
|
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
const types = require('../types/main.f.
|
|
2
|
-
const _ = require('./main.f.
|
|
3
|
-
const list = require('../../types/list/main.f.
|
|
4
|
-
const text = require('../../text/main.f.
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* }} Struct
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
/** @typedef {readonly
|
|
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
|
|
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 {
|
|
47
|
+
/** @typedef {readonly['*', Type]} Pointer */
|
|
54
48
|
|
|
55
49
|
module.exports = {}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const package_ = require('../package/main.f.
|
|
2
|
-
const module_ = require('../module/main.f.
|
|
3
|
-
const function_ = require('../module/function/main.f.
|
|
4
|
-
const map = require('../../types/map/main.f.
|
|
5
|
-
const object = require('../../types/object/main.f.
|
|
6
|
-
const path = require('../path/main.f.
|
|
7
|
-
const stringSet = require('../../types/stringset/main.f.
|
|
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.
|
|
2
|
-
const map = require('../../types/map/main.f.
|
|
3
|
-
const module_ = require('../module/main.f.
|
|
4
|
-
const function_ = require('../module/function/main.f.
|
|
5
|
-
const result = require('../../types/result/main.f.
|
|
6
|
-
const package_ = require('../package/main.f.
|
|
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.
|
|
13
|
+
build: require('./build/main.f.cjs'),
|
|
14
14
|
/** @readonly */
|
|
15
|
-
module: require('./module/main.f.
|
|
15
|
+
module: require('./module/main.f.cjs'),
|
|
16
16
|
/** @readonly */
|
|
17
|
-
package: require('./package/main.f.
|
|
17
|
+
package: require('./package/main.f.cjs'),
|
|
18
18
|
/** @readonly */
|
|
19
|
-
path: require('./path/main.f.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
2
|
-
const list = require('../../../types/list/main.f.
|
|
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,6 +1,6 @@
|
|
|
1
|
-
const list = require("../../types/list/main.f.
|
|
2
|
-
const package_ = require("../package/main.f.
|
|
3
|
-
const module_ = require("../module/main.f.
|
|
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.
|
|
2
|
-
const { todo } = require('../../dev/main.f.
|
|
3
|
-
const json = require('../../json/main.f.
|
|
4
|
-
const { identity } = require('../../types/function/main.f.
|
|
5
|
-
const object = require('../../types/object/main.f.
|
|
6
|
-
const { at } = require('../../types/object/main.f.
|
|
7
|
-
const package_ = require('../package/main.f.
|
|
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
|
|
22
|
-
6. Edit the `
|
|
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/
|
|
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.
|
|
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.
|
|
2
|
-
const object = require('../types/object/main.f.
|
|
3
|
-
const { operator, compose } = require('../types/function/main.f.
|
|
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.
|
|
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,6 +1,6 @@
|
|
|
1
|
-
const { tryCatch } = require('../result/main.
|
|
2
|
-
const { unwrap } = require('../../types/result/main.f.
|
|
3
|
-
const moduleFunction = require('../../commonjs/module/function/main.f.
|
|
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 => {
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const list = require('../types/list/main.f.
|
|
2
|
-
const object = require('../types/object/main.f.
|
|
3
|
-
const operator = require('../types/function/operator/main.f.
|
|
4
|
-
const { compose } = require('../types/function/main.f.
|
|
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.
|
|
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.
|
|
2
|
-
const { sort } = require('../types/object/main.f.
|
|
3
|
-
const { identity } = require('../types/function/main.f.
|
|
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
|
|