functionalscript 0.0.439 → 0.0.440

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,7 +1,7 @@
1
1
  # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
2
  # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
3
 
4
- name: node ci & pack
4
+ name: COM Test
5
5
 
6
6
  on:
7
7
  push:
@@ -12,15 +12,17 @@ on:
12
12
  jobs:
13
13
  build:
14
14
 
15
- runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ os: ['ubuntu-latest', 'windows-latest', 'macos-12']
18
+
19
+ runs-on: ${{ matrix.os }}
16
20
 
17
21
  steps:
18
22
  - uses: actions/checkout@v2
19
- - name: Use Node.js
23
+ - name: Use Node.js 19
20
24
  uses: actions/setup-node@v2
21
25
  with:
22
- node-version: 18
26
+ node-version: 19
23
27
  - run: npm ci
24
- - run: npm test
25
- - run: npm run version
26
- - run: npm pack
28
+ - run: node ./com/test/build.cjs
@@ -1,7 +1,7 @@
1
1
  # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
2
  # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
3
 
4
- name: node install
4
+ name: node CI
5
5
 
6
6
  on:
7
7
  push:
@@ -16,7 +16,7 @@ jobs:
16
16
 
17
17
  strategy:
18
18
  matrix:
19
- node-version: [16.x, 18.x]
19
+ node-version: [16.x, 18.x, 19.x]
20
20
  # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
21
 
22
22
  steps:
@@ -25,7 +25,7 @@ jobs:
25
25
  uses: actions/setup-node@v2
26
26
  with:
27
27
  node-version: ${{ matrix.node-version }}
28
- - run: npm install
28
+ - run: npm ci
29
29
  - run: npm test
30
30
  - run: npm run version
31
31
  - run: npm pack
@@ -14,7 +14,7 @@ jobs:
14
14
  - uses: actions/checkout@v2
15
15
  - uses: actions/setup-node@v2
16
16
  with:
17
- node-version: 18
17
+ node-version: 19
18
18
  - run: npm ci
19
19
  - run: npm test
20
20
 
@@ -27,7 +27,7 @@ jobs:
27
27
  fetch-depth: 0
28
28
  - uses: actions/setup-node@v2
29
29
  with:
30
- node-version: 18
30
+ node-version: 19
31
31
  registry-url: https://registry.npmjs.org/
32
32
  - run: npm ci
33
33
  - run: npm run version
package/com/cpp/com.hpp CHANGED
@@ -3,7 +3,7 @@
3
3
  #include <cstdint>
4
4
  #include <cstddef>
5
5
 
6
- #if defined(__aarch64__)
6
+ #if defined(__aarch64__) || defined(__amd64__)
7
7
  #define COM_STDCALL
8
8
  #elif defined(__clang__)
9
9
  #define COM_STDCALL __attribute__((stdcall))
@@ -82,7 +82,7 @@ const cpp = name => lib => {
82
82
 
83
83
  const e = entries(lib)
84
84
 
85
- return list.flat([
85
+ return flat([
86
86
  ['#pragma once', ''],
87
87
  namespace(name)(flat([flatMap(forward)(e), flatMap(def)(e)]))
88
88
  ])
@@ -1,37 +1,32 @@
1
- const fs = require('node:fs')
2
- const cp = require('node:child_process')
3
- const os = require('node:os');
4
- const cpp = require('../cpp/test.f.cjs').result
5
- const { string: { join }, list: { flat } } = require('../../types/module.f.cjs')
1
+ const { writeFileSync } = require('node:fs')
2
+ const { execSync } = require('node:child_process')
3
+ const { platform } = require('node:process')
4
+ const build = require('./build.f.cjs')
5
+ const { cpp, cs, rust } = build
6
+ const { join } = require('../../types/string/module.f.cjs')
7
+ const { log, error } = console
8
+ const { bold, reset } = require('../../text/sgr/module.f.cjs')
6
9
 
7
- const dirname = __dirname
8
-
9
- fs.writeFileSync(`${dirname}/cpp/_result.hpp`, cpp)
10
- try {
11
- const flags = os.platform() === 'win32' ? [] : ['-std=c++11', '-lc++']
12
- const line = join(' ')(flat([['clang'], flags, [dirname + '/cpp/main.cpp']]))
13
- console.log(cp.execSync(line).toString())
14
- } catch (e) {
15
- // @ts-ignore
16
- console.error(e.output.toString())
10
+ const nodeJs = {
11
+ dirname: __dirname,
12
+ platform,
17
13
  }
18
14
 
19
- const cs = require('../cs/test.f.cjs').result
20
-
21
- fs.writeFileSync(`${dirname}/cs/_result.cs`, cs)
22
- try {
23
- console.log(cp.execSync(`dotnet build ${dirname}/cs/cs.csproj`).toString())
24
- } catch (e) {
25
- // @ts-ignore
26
- console.error(e.output.toString())
15
+ /** @type {(f: build.Func) => void} */
16
+ const run = f => {
17
+ const { file: { name, content }, line } = f(nodeJs)
18
+ log(`${bold}writing: ${name}${reset}`)
19
+ writeFileSync(name, content)
20
+ const cmd = join(' ')(line)
21
+ log(`${bold}running: ${cmd}${reset}`)
22
+ try {
23
+ log(execSync(cmd).toString())
24
+ } catch (e) {
25
+ // @ts-ignore
26
+ error(e.output.toString())
27
+ }
27
28
  }
28
29
 
29
- const rust = require("../rust/test.f.cjs").result();
30
-
31
- fs.writeFileSync(`${dirname}/rust/src/_result.rs`, rust);
32
- try {
33
- console.log(cp.execSync("cargo build").toString());
34
- } catch (e) {
35
- // @ts-ignore
36
- console.error(e.output.toString());
37
- }
30
+ run(cpp)
31
+ run(cs)
32
+ run(rust)
@@ -0,0 +1,93 @@
1
+ const list = require('../../types/list/module.f.cjs')
2
+ const { flat } = list
3
+
4
+ const cppContent = require('../cpp/test.f.cjs').result
5
+ const csContent = require('../cs/test.f.cjs').result
6
+ const rustContent = require("../rust/test.f.cjs").result();
7
+
8
+ /**
9
+ * @typedef {|
10
+ * 'aix' |
11
+ * 'android' |
12
+ * 'darwin' |
13
+ * 'freebsd' |
14
+ * 'haiku' |
15
+ * 'linux' |
16
+ * 'openbsd' |
17
+ * 'sunos' |
18
+ * 'win32' |
19
+ * 'cygwin' |
20
+ * 'netbsd'
21
+ * } Platform
22
+ */
23
+
24
+ /**
25
+ * @typedef {{
26
+ * readonly dirname: string
27
+ * readonly platform: Platform
28
+ * }} NodeJs
29
+ */
30
+
31
+ /**
32
+ * @typedef {{
33
+ * readonly file: {
34
+ * readonly name: string
35
+ * readonly content: string
36
+ * }
37
+ * readonly line: list.List<string>
38
+ * }} Output
39
+ */
40
+
41
+ /** @typedef {(nodejs: NodeJs) => Output} Func */
42
+
43
+ /** @type {(platform: Platform) => readonly string[]} */
44
+ const flags = platform => {
45
+ switch (platform) {
46
+ case 'win32':
47
+ return []
48
+ case 'linux':
49
+ return ['-lstdc++']
50
+ default:
51
+ return ['-std=c++11', '-lc++']
52
+ }
53
+ }
54
+
55
+ /** @type {Func} */
56
+ const cpp = ({dirname, platform}) => ({
57
+ file: {
58
+ name: `${dirname}/cpp/_result.hpp`,
59
+ content: cppContent,
60
+ },
61
+ line: flat([
62
+ ['clang'],
63
+ flags(platform),
64
+ [`${dirname}/cpp/main.cpp`]]
65
+ ),
66
+ })
67
+
68
+ /** @type {Func} */
69
+ const cs = ({dirname}) => ({
70
+ file: {
71
+ name: `${dirname}/cs/_result.cs`,
72
+ content: csContent,
73
+ },
74
+ line: ['dotnet', 'build', `${dirname}/cs/cs.csproj`],
75
+ })
76
+
77
+ /** @type {Func} */
78
+ const rust = ({dirname}) => ({
79
+ file: {
80
+ name: `${dirname}/rust/src/_result.rs`,
81
+ content: rustContent,
82
+ },
83
+ line: ['cargo', 'build']
84
+ })
85
+
86
+ module.exports = {
87
+ /** @readonly */
88
+ cpp,
89
+ /** @readonly */
90
+ cs,
91
+ /** @readonly */
92
+ rust,
93
+ }
@@ -0,0 +1,9 @@
1
+ [package]
2
+ name = "testrust"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+ [dependencies]
9
+ nanocom = { path = "../../rust/nanocom" }
@@ -0,0 +1 @@
1
+ mod _result;
@@ -1,5 +1,6 @@
1
1
  const list = require('../../types/list/module.f.cjs')
2
2
  const { fold } = list
3
+ const { reset, fgGreen } = require('../../text/sgr/module.f.cjs')
3
4
 
4
5
  /**
5
6
  * @typedef {{
@@ -34,17 +35,6 @@ const { fold } = list
34
35
  * }} Input
35
36
  */
36
37
 
37
- /**
38
- * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
39
- *
40
- * @type {(c: number) => string}
41
- */
42
- const sgr = c => `\x1b[${c.toString()}m`
43
-
44
- const reset = sgr(0)
45
-
46
- const fgGreen = sgr(32)
47
-
48
38
  /** @type {(s: string) => boolean} */
49
39
  const isTest = s => s.endsWith('test.f.cjs')
50
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.439",
3
+ "version": "0.0.440",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
31
31
  "devDependencies": {
32
- "@types/node": "^18.8.4",
32
+ "@types/node": "^18.11.2",
33
33
  "typescript": "^4.8.4"
34
34
  }
35
35
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
3
+ *
4
+ * @type {(c: number) => string}
5
+ */
6
+ const sgr = c => `\x1b[${c.toString()}m`
7
+
8
+ module.exports = {
9
+ /** @readonly */
10
+ sgr,
11
+ /** @readonly */
12
+ reset: sgr(0),
13
+ /** @readonly */
14
+ bold: sgr(1),
15
+ /** @readonly */
16
+ fgGreen: sgr(32),
17
+ }