functionalscript 0.0.511 → 0.0.514

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.
@@ -10,8 +10,21 @@ on:
10
10
  pull_request:
11
11
 
12
12
  jobs:
13
- node:
13
+ locks:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: actions/setup-node@v2
18
+ with:
19
+ node-version: 16
20
+ - run: npm install
21
+ - uses: actions/upload-artifact@v3
22
+ with:
23
+ name: package-lock.json
24
+ path: package-lock.json
14
25
 
26
+ node:
27
+ needs: locks
15
28
  runs-on: ubuntu-latest
16
29
 
17
30
  strategy:
@@ -21,10 +34,12 @@ jobs:
21
34
 
22
35
  steps:
23
36
  - uses: actions/checkout@v2
24
- - name: Use Node.js ${{ matrix.node-version }}
25
- uses: actions/setup-node@v2
37
+ - uses: actions/setup-node@v2
26
38
  with:
27
39
  node-version: ${{ matrix.node-version }}
40
+ - uses: actions/download-artifact@v3
41
+ with:
42
+ name: package-lock.json
28
43
  - run: npm ci
29
44
  - run: npm test
30
45
  - run: npm run version
@@ -49,3 +64,25 @@ jobs:
49
64
  - uses: actions/checkout@v2
50
65
  - run: curl https://bun.sh/install | bash
51
66
  - run: /home/runner/.bun/bin/bun ./dev/test.mjs
67
+
68
+ COM:
69
+ needs: locks
70
+ strategy:
71
+ matrix:
72
+ os: ['ubuntu-latest', 'windows-latest', 'macos-12']
73
+
74
+ runs-on: ${{ matrix.os }}
75
+
76
+ steps:
77
+ - uses: actions/checkout@v3
78
+ - uses: actions/setup-node@v2
79
+ with:
80
+ node-version: 19
81
+ - uses: actions/download-artifact@v3
82
+ with:
83
+ name: package-lock.json
84
+ - uses: actions/setup-dotnet@v3
85
+ with:
86
+ dotnet-version: 7
87
+ - run: npm ci
88
+ - run: npm run comtest
@@ -18,7 +18,7 @@ jobs:
18
18
  with:
19
19
  node-version: 19
20
20
  registry-url: https://registry.npmjs.org/
21
- - run: npm ci
21
+ # - run: npm ci
22
22
  - run: npm run version
23
23
  - run: npm publish
24
24
  env:
@@ -62,7 +62,7 @@ const output = platform => name => {
62
62
  }
63
63
 
64
64
  /** @type {Func} */
65
- const cpp = ({dirname, platform}) => ({
65
+ const cpp = ({ dirname, platform }) => ({
66
66
  file: {
67
67
  name: `${dirname}/cpp/_result.hpp`,
68
68
  content: cppContent(),
@@ -77,7 +77,7 @@ const cpp = ({dirname, platform}) => ({
77
77
  })
78
78
 
79
79
  /** @type {Func} */
80
- const cs = ({dirname, platform}) => ({
80
+ const cs = ({ dirname, platform }) => ({
81
81
  file: {
82
82
  name: `${dirname}/cs/_result.cs`,
83
83
  content: csContent,
@@ -85,18 +85,18 @@ const cs = ({dirname, platform}) => ({
85
85
  line: [
86
86
  platform === 'win32'
87
87
  ? ['dotnet', 'run', '--project', `${dirname}/cs/cs.csproj`]
88
- // .Net on Linux and MacOS doesn't properly support COM object marshalling
88
+ // .Net on Linux and MacOS doesn't properly support COM object marshalling
89
89
  : ['dotnet', 'build', `${dirname}/cs/cs.csproj`]
90
90
  ],
91
91
  })
92
92
 
93
93
  /** @type {Func} */
94
- const rust = ({dirname}) => ({
94
+ const rust = ({ dirname }) => ({
95
95
  file: {
96
96
  name: `${dirname}/rust/src/_result.rs`,
97
97
  content: rustContent,
98
98
  },
99
- line: [['cargo', 'build']]
99
+ line: [['cargo', 'build' /**, '--locked' */]]
100
100
  })
101
101
 
102
102
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.511",
3
+ "version": "0.0.514",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "homepage": "https://github.com/functionalscript/functionalscript#readme",
32
32
  "devDependencies": {
33
- "@types/node": "^18.11.18",
33
+ "@types/node": "^18.14.6",
34
34
  "typescript": "^4.9.5"
35
35
  }
36
36
  }
@@ -4,6 +4,8 @@ const { todo } = require('../../dev/module.f.cjs')
4
4
 
5
5
  /** @typedef {readonly[bigint,number]} BigFloat */
6
6
 
7
+ /** @typedef {readonly[BigFloat,bigint]} BigFloatWithRemainder */
8
+
7
9
  const twoPow53 = 0b0010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000n
8
10
  const twoPow54 = 0b0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000n
9
11
 
@@ -44,20 +46,25 @@ const pow = base => exp => base ** BigInt(exp)
44
46
 
45
47
  const pow5 = pow(5n)
46
48
 
47
- /** @type {(div: BigFloat) => (p: bigint) => BigFloat} */
48
- const divide = ([m, e]) => div => {
49
+ /** @type {(b: BigFloat) => (mul: bigint) => BigFloat} */
50
+ const multiply = ([m, e]) => mul => [m * mul, e]
51
+
52
+ /** @type {(b: BigFloat) => (div: bigint) => BigFloatWithRemainder} */
53
+ const divide = ([m, e]) => div => [[m / div, e], m % div]
54
+
55
+ /** @type {(b: BigFloatWithRemainder) => BigFloat} */
56
+ const round53 = ([[m, e], r]) => {
49
57
  const mabs = abs(m)
50
- const q = mabs / div
51
58
  const s = BigInt(sign(m))
52
- const [q53, e53] = decreaseMantissa([q, e])(twoPow54)
53
- const r = q53 & 1n
54
- const q52 = q53 >> 1n
55
- const e52 = e53 + 1
56
- if (r === 1n && mabs === q * div && q === q53 >> BigInt(e - e53)) {
57
- const odd = q52 & 1n
58
- return [s * (q52 + odd), e52]
59
+ const [m54, e54] = decreaseMantissa([mabs, e])(twoPow54)
60
+ const o54 = m54 & 1n
61
+ const m53 = m54 >> 1n
62
+ const e53 = e54 + 1
63
+ if (o54 === 1n && r === 0n && mabs === m54 >> BigInt(e - e54)) {
64
+ const odd = m53 & 1n
65
+ return multiply([m53 + odd, e53])(s)
59
66
  }
60
- return [s * (q52 + r), e52]
67
+ return multiply([m53 + o54, e53])(s)
61
68
  }
62
69
 
63
70
  /** @type {(dec: BigFloat) => BigFloat} */
@@ -68,11 +75,16 @@ const decToBin = dec => {
68
75
  if (dec[1] >= 0) {
69
76
  /** @type {BigFloat} */
70
77
  const bin = [dec[0] * pow5(dec[1]), dec[1]]
71
- return divide(increaseMantissa(bin)(twoPow53))(1n)
78
+ const inc = increaseMantissa(bin)(twoPow53)
79
+ return round53([inc, 0n])
72
80
  }
73
81
  const p = pow5(-dec[1])
74
82
  const [m, e] = increaseMantissa(dec)(p * twoPow53)
75
- return divide([m, e])(p)
83
+ const mAbs = abs(m)
84
+ const s = BigInt(sign(m))
85
+ const qr = divide([mAbs, e])(p)
86
+ const r53 = round53(qr)
87
+ return multiply(r53)(s)
76
88
  }
77
89
 
78
90
  module.exports = {
@@ -1,31 +0,0 @@
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
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
-
4
- name: COM Test
5
-
6
- on:
7
- push:
8
- branches:
9
- - master
10
- pull_request:
11
-
12
- jobs:
13
- COM:
14
-
15
- strategy:
16
- matrix:
17
- os: ['ubuntu-latest', 'windows-latest', 'macos-12']
18
-
19
- runs-on: ${{ matrix.os }}
20
-
21
- steps:
22
- - uses: actions/checkout@v3
23
- - name: Use Node.js 19
24
- uses: actions/setup-node@v2
25
- with:
26
- node-version: 19
27
- - uses: actions/setup-dotnet@v3
28
- with:
29
- dotnet-version: 7
30
- - run: npm ci
31
- - run: npm run comtest
package/Cargo.lock DELETED
@@ -1,14 +0,0 @@
1
- # This file is automatically @generated by Cargo.
2
- # It is not intended for manual editing.
3
- version = 3
4
-
5
- [[package]]
6
- name = "nanocom"
7
- version = "0.2.1"
8
-
9
- [[package]]
10
- name = "testrust"
11
- version = "0.1.0"
12
- dependencies = [
13
- "nanocom",
14
- ]