functionalscript 0.0.553 → 0.0.555

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.
@@ -18,7 +18,7 @@ jobs:
18
18
  with:
19
19
  node-version: 20
20
20
  - run: npm install
21
- - uses: actions/upload-artifact@v3
21
+ - uses: actions/upload-artifact@v4
22
22
  with:
23
23
  name: package-lock.json
24
24
  path: package-lock.json
@@ -37,7 +37,7 @@ jobs:
37
37
  - uses: actions/setup-node@v2
38
38
  with:
39
39
  node-version: ${{ matrix.node-version }}
40
- - uses: actions/download-artifact@v3
40
+ - uses: actions/download-artifact@v4
41
41
  with:
42
42
  name: package-lock.json
43
43
  - run: npm ci
@@ -78,7 +78,7 @@ jobs:
78
78
  - uses: actions/setup-node@v2
79
79
  with:
80
80
  node-version: 20
81
- - uses: actions/download-artifact@v3
81
+ - uses: actions/download-artifact@v4
82
82
  with:
83
83
  name: package-lock.json
84
84
  - uses: actions/setup-dotnet@v3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.553",
3
+ "version": "0.0.555",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {
@@ -44,6 +44,16 @@ const scalar_mul = ({ 0: _0, add }) => a => n => {
44
44
  }
45
45
  }
46
46
 
47
+ /** @type {(a: bigint) => bigint} */
48
+ const log2x = a => {
49
+ let i = 0n
50
+ while (a !== 0n) {
51
+ ++i
52
+ a >>= 1n
53
+ }
54
+ return i
55
+ }
56
+
47
57
  module.exports = {
48
58
  /** @readonly */
49
59
  addition,
@@ -57,4 +67,6 @@ module.exports = {
57
67
  serialize,
58
68
  /** @readonly */
59
69
  scalar_mul,
70
+ /** @readonly */
71
+ log2x,
60
72
  }
@@ -1,4 +1,4 @@
1
- const { sum, abs, serialize } = require('./module.f.cjs')
1
+ const { sum, abs, serialize, log2x } = require('./module.f.cjs')
2
2
 
3
3
  module.exports = {
4
4
  sum: () => {
@@ -28,5 +28,43 @@ module.exports = {
28
28
  const result = serialize(-55555n)
29
29
  if (result !== '-55555n') { throw result }
30
30
  },
31
+ ],
32
+ log2x: [
33
+ () => {
34
+ const result = log2x(0n)
35
+ if (result !== 0n) { throw result }
36
+ },
37
+ () => {
38
+ const result = log2x(1n)
39
+ if (result !== 1n) { throw result }
40
+ },
41
+ () => {
42
+ const result = log2x(2n)
43
+ if (result !== 2n) { throw result }
44
+ },
45
+ () => {
46
+ const result = log2x(3n)
47
+ if (result !== 2n) { throw result }
48
+ },
49
+ () => {
50
+ const result = log2x(4n)
51
+ if (result !== 3n) { throw result }
52
+ },
53
+ () => {
54
+ const result = log2x(7n)
55
+ if (result !== 3n) { throw result }
56
+ },
57
+ () => {
58
+ const result = log2x(8n)
59
+ if (result !== 4n) { throw result }
60
+ },
61
+ () => {
62
+ const result = log2x(15n)
63
+ if (result !== 4n) { throw result }
64
+ },
65
+ () => {
66
+ const result = log2x(16n)
67
+ if (result !== 5n) { throw result }
68
+ }
31
69
  ]
32
70
  }