@grain/stdlib 0.5.2 → 0.5.3
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/CHANGELOG.md +21 -0
- package/array.gr +56 -1
- package/array.md +83 -0
- package/bigint.md +30 -30
- package/buffer.gr +24 -22
- package/float32.md +3 -3
- package/float64.md +3 -3
- package/immutablepriorityqueue.gr +332 -0
- package/immutablepriorityqueue.md +248 -0
- package/list.gr +73 -0
- package/list.md +110 -0
- package/map.gr +1 -2
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +41 -0
- package/number.md +80 -5
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +241 -0
- package/priorityqueue.md +279 -0
- package/regex.gr +5 -5
- package/runtime/compare.gr +178 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +1 -2
- package/runtime/numbers.gr +307 -68
- package/runtime/numbers.md +24 -0
- package/set.gr +1 -2
- package/string.gr +97 -15
- package/string.md +65 -1
- package/sys/file.gr +3 -3
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +2 -2
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### [0.5.3](https://github.com/grain-lang/grain/compare/stdlib-v0.5.2...stdlib-v0.5.3) (2022-08-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Implement Pervasives.compare ([#1399](https://github.com/grain-lang/grain/issues/1399)) ([ebd87e4](https://github.com/grain-lang/grain/commit/ebd87e4308a8950fd95f060ebc446833b064237c))
|
|
9
|
+
* **stdlib:** Add `charCodeAt` function to String module ([#1376](https://github.com/grain-lang/grain/issues/1376)) ([c3abbc9](https://github.com/grain-lang/grain/commit/c3abbc991c8b05e3de20e670d2bc3e491feebf8a))
|
|
10
|
+
* **stdlib:** Add `lastIndexOf` function to String module ([#1372](https://github.com/grain-lang/grain/issues/1372)) ([b73d9bf](https://github.com/grain-lang/grain/commit/b73d9bf9ff3291b83e6f4263e392395d04dc9995))
|
|
11
|
+
* **stdlib:** Implement `isFloat`, `isInteger` & `isRational` in Number module ([#1393](https://github.com/grain-lang/grain/issues/1393)) ([0af0669](https://github.com/grain-lang/grain/commit/0af066993a2b80e417d2c625b27fd11cb1f1f55f))
|
|
12
|
+
* **stdlib:** Implement List.zip, List.unzip, List.zipWith, Array.reduceRight, Array.zipWith ([#1363](https://github.com/grain-lang/grain/issues/1363)) ([3e7c147](https://github.com/grain-lang/grain/commit/3e7c147fea2d2fb8b7c5a3d6b3eb1453f2861e36))
|
|
13
|
+
* **stdlib:** Implement mutable/immutable priority queues ([#1397](https://github.com/grain-lang/grain/issues/1397)) ([244be1b](https://github.com/grain-lang/grain/commit/244be1b7254caf0b451902ac56413382eb196747))
|
|
14
|
+
* **stdlib:** Marshal ([#1352](https://github.com/grain-lang/grain/issues/1352)) ([d659de2](https://github.com/grain-lang/grain/commit/d659de2d92260f7726164876827c639bfd9d0590))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **compiler:** Correctly handle underscores in bigint literals ([0af0669](https://github.com/grain-lang/grain/commit/0af066993a2b80e417d2c625b27fd11cb1f1f55f))
|
|
20
|
+
* **graindoc:** Use defined module name throughout generated doc ([#1406](https://github.com/grain-lang/grain/issues/1406)) ([c33a777](https://github.com/grain-lang/grain/commit/c33a777a93d5e40a081991db5e6ea61ade4fbabc))
|
|
21
|
+
* **stdlib:** Correctly promote numbers to bigints when left-shifting ([#1354](https://github.com/grain-lang/grain/issues/1354)) ([5280e98](https://github.com/grain-lang/grain/commit/5280e98a91a57fae074299fc7bad3c41f69fa2a3))
|
|
22
|
+
* **stdlib:** Prevent addBytesSlice throwing error on empty buffer ([#1394](https://github.com/grain-lang/grain/issues/1394)) ([bdd4be4](https://github.com/grain-lang/grain/commit/bdd4be46730290908b7b939f41679acce7834167))
|
|
23
|
+
|
|
3
24
|
### [0.5.2](https://github.com/grain-lang/grain/compare/stdlib-v0.5.1...stdlib-v0.5.2) (2022-06-29)
|
|
4
25
|
|
|
5
26
|
|
package/array.gr
CHANGED
|
@@ -358,6 +358,32 @@ export let reduce = (fn, initial, array) => {
|
|
|
358
358
|
acc
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Combines all elements of an array using a reducer function,
|
|
363
|
+
* starting from the "end", or right side, of the array.
|
|
364
|
+
*
|
|
365
|
+
* In `Array.reduceRight(fn, initial, array)`, `fn` is called with
|
|
366
|
+
* each element of the array and an accumulator, and returns
|
|
367
|
+
* a new accumulator. The final value is the last accumulator
|
|
368
|
+
* returned. The accumulator starts with value `initial`.
|
|
369
|
+
*
|
|
370
|
+
* @param fn: The reducer function to call on each element, where the value returned will be the next accumulator value
|
|
371
|
+
* @param initial: The initial value to use for the accumulator on the first iteration
|
|
372
|
+
* @param array: The array to iterate
|
|
373
|
+
* @returns The final accumulator returned from `fn`
|
|
374
|
+
*
|
|
375
|
+
* @example Array.reduceRight((a, b) => b ++ a, "", [> "baz", "bar", "foo"]) // "foobarbaz"
|
|
376
|
+
*
|
|
377
|
+
* @since v0.5.3
|
|
378
|
+
*/
|
|
379
|
+
export let reduceRight = (fn, initial, array) => {
|
|
380
|
+
let mut acc = initial
|
|
381
|
+
for (let mut i = length(array) - 1; i >= 0; i -= 1) {
|
|
382
|
+
acc = fn(array[i], acc)
|
|
383
|
+
}
|
|
384
|
+
acc
|
|
385
|
+
}
|
|
386
|
+
|
|
361
387
|
/**
|
|
362
388
|
* Combines all elements of an array using a reducer function,
|
|
363
389
|
* starting from the "head", or left side, of the array.
|
|
@@ -555,7 +581,7 @@ export let fromList = list => {
|
|
|
555
581
|
* @since v0.2.0
|
|
556
582
|
*/
|
|
557
583
|
export let contains = (search, array) => {
|
|
558
|
-
// TODO: This should use recursion
|
|
584
|
+
// TODO(#189): This should be rewritten to use recursion and pattern matching
|
|
559
585
|
let len = length(array)
|
|
560
586
|
let mut found = false
|
|
561
587
|
for (let mut index = 0; !found && index < len; index += 1) {
|
|
@@ -787,6 +813,35 @@ export let zip = (array1: Array<a>, array2: Array<b>) => {
|
|
|
787
813
|
}
|
|
788
814
|
}
|
|
789
815
|
|
|
816
|
+
/**
|
|
817
|
+
* Produces a new array filled with elements defined by applying a function on
|
|
818
|
+
* pairs from both given arrays. The first element will contain the result of
|
|
819
|
+
* applying the function to the first elements of each array, the second element
|
|
820
|
+
* will contain the result of applying the function to the second elements of
|
|
821
|
+
* each array, and so on.
|
|
822
|
+
*
|
|
823
|
+
* Calling this function with arrays of different sizes will cause the returned
|
|
824
|
+
* array to have the length of the smaller array.
|
|
825
|
+
*
|
|
826
|
+
* @param fn: The function to apply to pairs of elements
|
|
827
|
+
* @param array1: The array whose elements will each be passed to the function as the first argument
|
|
828
|
+
* @param array2: The array whose elements will each be passed to the function as the second argument
|
|
829
|
+
* @returns The new array containing elements derived from applying the function to pairs of input array elements
|
|
830
|
+
*
|
|
831
|
+
* @example Array.zipWith((a, b) => a + b, [> 1, 2, 3], [> 4, 5, 6]) // [> 5, 7, 9]
|
|
832
|
+
* @example Array.zipWith((a, b) => a * b, [> 1, 2, 3], [> 4, 5]) // [> 4, 10]
|
|
833
|
+
*
|
|
834
|
+
* @since v0.5.3
|
|
835
|
+
*/
|
|
836
|
+
export let zipWith = (fn, array1: Array<a>, array2: Array<b>) => {
|
|
837
|
+
let len1 = length(array1)
|
|
838
|
+
let len2 = length(array2)
|
|
839
|
+
let minLen = if (len1 > len2) len2 else len1
|
|
840
|
+
init(minLen, index => {
|
|
841
|
+
fn(array1[index], array2[index])
|
|
842
|
+
})
|
|
843
|
+
}
|
|
844
|
+
|
|
790
845
|
/**
|
|
791
846
|
* Produces two arrays by splitting apart an array of tuples.
|
|
792
847
|
*
|
package/array.md
CHANGED
|
@@ -439,6 +439,45 @@ Examples:
|
|
|
439
439
|
Array.reduce((a, b) => a + b, 0, [> 1, 2, 3]) // 6
|
|
440
440
|
```
|
|
441
441
|
|
|
442
|
+
### Array.**reduceRight**
|
|
443
|
+
|
|
444
|
+
<details disabled>
|
|
445
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
446
|
+
No other changes yet.
|
|
447
|
+
</details>
|
|
448
|
+
|
|
449
|
+
```grain
|
|
450
|
+
reduceRight : (((a, b) -> b), b, Array<a>) -> b
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
Combines all elements of an array using a reducer function,
|
|
454
|
+
starting from the "end", or right side, of the array.
|
|
455
|
+
|
|
456
|
+
In `Array.reduceRight(fn, initial, array)`, `fn` is called with
|
|
457
|
+
each element of the array and an accumulator, and returns
|
|
458
|
+
a new accumulator. The final value is the last accumulator
|
|
459
|
+
returned. The accumulator starts with value `initial`.
|
|
460
|
+
|
|
461
|
+
Parameters:
|
|
462
|
+
|
|
463
|
+
|param|type|description|
|
|
464
|
+
|-----|----|-----------|
|
|
465
|
+
|`fn`|`(a, b) -> b`|The reducer function to call on each element, where the value returned will be the next accumulator value|
|
|
466
|
+
|`initial`|`b`|The initial value to use for the accumulator on the first iteration|
|
|
467
|
+
|`array`|`Array<a>`|The array to iterate|
|
|
468
|
+
|
|
469
|
+
Returns:
|
|
470
|
+
|
|
471
|
+
|type|description|
|
|
472
|
+
|----|-----------|
|
|
473
|
+
|`b`|The final accumulator returned from `fn`|
|
|
474
|
+
|
|
475
|
+
Examples:
|
|
476
|
+
|
|
477
|
+
```grain
|
|
478
|
+
Array.reduceRight((a, b) => b ++ a, "", [> "baz", "bar", "foo"]) // "foobarbaz"
|
|
479
|
+
```
|
|
480
|
+
|
|
442
481
|
### Array.**reducei**
|
|
443
482
|
|
|
444
483
|
<details disabled>
|
|
@@ -945,6 +984,50 @@ Returns:
|
|
|
945
984
|
|----|-----------|
|
|
946
985
|
|`Array<(a, b)>`|The new array containing indexed pairs of `(a, b)`|
|
|
947
986
|
|
|
987
|
+
### Array.**zipWith**
|
|
988
|
+
|
|
989
|
+
<details disabled>
|
|
990
|
+
<summary tabindex="-1">Added in <code>0.5.3</code></summary>
|
|
991
|
+
No other changes yet.
|
|
992
|
+
</details>
|
|
993
|
+
|
|
994
|
+
```grain
|
|
995
|
+
zipWith : (((a, b) -> c), Array<a>, Array<b>) -> Array<c>
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
Produces a new array filled with elements defined by applying a function on
|
|
999
|
+
pairs from both given arrays. The first element will contain the result of
|
|
1000
|
+
applying the function to the first elements of each array, the second element
|
|
1001
|
+
will contain the result of applying the function to the second elements of
|
|
1002
|
+
each array, and so on.
|
|
1003
|
+
|
|
1004
|
+
Calling this function with arrays of different sizes will cause the returned
|
|
1005
|
+
array to have the length of the smaller array.
|
|
1006
|
+
|
|
1007
|
+
Parameters:
|
|
1008
|
+
|
|
1009
|
+
|param|type|description|
|
|
1010
|
+
|-----|----|-----------|
|
|
1011
|
+
|`fn`|`(a, b) -> c`|The function to apply to pairs of elements|
|
|
1012
|
+
|`array1`|`Array<a>`|The array whose elements will each be passed to the function as the first argument|
|
|
1013
|
+
|`array2`|`Array<b>`|The array whose elements will each be passed to the function as the second argument|
|
|
1014
|
+
|
|
1015
|
+
Returns:
|
|
1016
|
+
|
|
1017
|
+
|type|description|
|
|
1018
|
+
|----|-----------|
|
|
1019
|
+
|`Array<c>`|The new array containing elements derived from applying the function to pairs of input array elements|
|
|
1020
|
+
|
|
1021
|
+
Examples:
|
|
1022
|
+
|
|
1023
|
+
```grain
|
|
1024
|
+
Array.zipWith((a, b) => a + b, [> 1, 2, 3], [> 4, 5, 6]) // [> 5, 7, 9]
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
```grain
|
|
1028
|
+
Array.zipWith((a, b) => a * b, [> 1, 2, 3], [> 4, 5]) // [> 4, 10]
|
|
1029
|
+
```
|
|
1030
|
+
|
|
948
1031
|
### Array.**unzip**
|
|
949
1032
|
|
|
950
1033
|
<details disabled>
|
package/bigint.md
CHANGED
|
@@ -17,7 +17,7 @@ import BigInt from "bigint"
|
|
|
17
17
|
|
|
18
18
|
Functions for converting between Numbers and the BigInt type.
|
|
19
19
|
|
|
20
|
-
###
|
|
20
|
+
### BigInt.**fromNumber**
|
|
21
21
|
|
|
22
22
|
<details disabled>
|
|
23
23
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -42,7 +42,7 @@ Returns:
|
|
|
42
42
|
|----|-----------|
|
|
43
43
|
|`BigInt`|The Number represented as a BigInt|
|
|
44
44
|
|
|
45
|
-
###
|
|
45
|
+
### BigInt.**toNumber**
|
|
46
46
|
|
|
47
47
|
<details disabled>
|
|
48
48
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -71,7 +71,7 @@ Returns:
|
|
|
71
71
|
|
|
72
72
|
Mathematical operations for BigInt values.
|
|
73
73
|
|
|
74
|
-
###
|
|
74
|
+
### BigInt.**incr**
|
|
75
75
|
|
|
76
76
|
<details disabled>
|
|
77
77
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -96,7 +96,7 @@ Returns:
|
|
|
96
96
|
|----|-----------|
|
|
97
97
|
|`BigInt`|The incremented value|
|
|
98
98
|
|
|
99
|
-
###
|
|
99
|
+
### BigInt.**decr**
|
|
100
100
|
|
|
101
101
|
<details disabled>
|
|
102
102
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -121,7 +121,7 @@ Returns:
|
|
|
121
121
|
|----|-----------|
|
|
122
122
|
|`BigInt`|The decremented value|
|
|
123
123
|
|
|
124
|
-
###
|
|
124
|
+
### BigInt.**neg**
|
|
125
125
|
|
|
126
126
|
<details disabled>
|
|
127
127
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -146,7 +146,7 @@ Returns:
|
|
|
146
146
|
|----|-----------|
|
|
147
147
|
|`BigInt`|The negated operand|
|
|
148
148
|
|
|
149
|
-
###
|
|
149
|
+
### BigInt.**abs**
|
|
150
150
|
|
|
151
151
|
<details disabled>
|
|
152
152
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -171,7 +171,7 @@ Returns:
|
|
|
171
171
|
|----|-----------|
|
|
172
172
|
|`BigInt`|The operand's absolute value|
|
|
173
173
|
|
|
174
|
-
###
|
|
174
|
+
### BigInt.**add**
|
|
175
175
|
|
|
176
176
|
<details disabled>
|
|
177
177
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -197,7 +197,7 @@ Returns:
|
|
|
197
197
|
|----|-----------|
|
|
198
198
|
|`BigInt`|The sum of the two operands|
|
|
199
199
|
|
|
200
|
-
###
|
|
200
|
+
### BigInt.**sub**
|
|
201
201
|
|
|
202
202
|
<details disabled>
|
|
203
203
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -223,7 +223,7 @@ Returns:
|
|
|
223
223
|
|----|-----------|
|
|
224
224
|
|`BigInt`|The difference of the two operands|
|
|
225
225
|
|
|
226
|
-
###
|
|
226
|
+
### BigInt.**mul**
|
|
227
227
|
|
|
228
228
|
<details disabled>
|
|
229
229
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -249,7 +249,7 @@ Returns:
|
|
|
249
249
|
|----|-----------|
|
|
250
250
|
|`BigInt`|The product of the two operands|
|
|
251
251
|
|
|
252
|
-
###
|
|
252
|
+
### BigInt.**div**
|
|
253
253
|
|
|
254
254
|
<details disabled>
|
|
255
255
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -276,7 +276,7 @@ Returns:
|
|
|
276
276
|
|----|-----------|
|
|
277
277
|
|`BigInt`|The quotient of its operands|
|
|
278
278
|
|
|
279
|
-
###
|
|
279
|
+
### BigInt.**rem**
|
|
280
280
|
|
|
281
281
|
<details disabled>
|
|
282
282
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -303,7 +303,7 @@ Returns:
|
|
|
303
303
|
|----|-----------|
|
|
304
304
|
|`BigInt`|The remainder of its operands|
|
|
305
305
|
|
|
306
|
-
###
|
|
306
|
+
### BigInt.**quotRem**
|
|
307
307
|
|
|
308
308
|
<details disabled>
|
|
309
309
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -329,7 +329,7 @@ Returns:
|
|
|
329
329
|
|----|-----------|
|
|
330
330
|
|`(BigInt, BigInt)`|The quotient and remainder of its operands|
|
|
331
331
|
|
|
332
|
-
###
|
|
332
|
+
### BigInt.**gcd**
|
|
333
333
|
|
|
334
334
|
<details disabled>
|
|
335
335
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -359,7 +359,7 @@ Returns:
|
|
|
359
359
|
|
|
360
360
|
Functions for operating on bits of BigInt values.
|
|
361
361
|
|
|
362
|
-
###
|
|
362
|
+
### BigInt.**shl**
|
|
363
363
|
|
|
364
364
|
<details disabled>
|
|
365
365
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -385,7 +385,7 @@ Returns:
|
|
|
385
385
|
|----|-----------|
|
|
386
386
|
|`BigInt`|The shifted value|
|
|
387
387
|
|
|
388
|
-
###
|
|
388
|
+
### BigInt.**shr**
|
|
389
389
|
|
|
390
390
|
<details disabled>
|
|
391
391
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -415,7 +415,7 @@ Returns:
|
|
|
415
415
|
|
|
416
416
|
Functions for comparing BigInt values.
|
|
417
417
|
|
|
418
|
-
###
|
|
418
|
+
### BigInt.**eqz**
|
|
419
419
|
|
|
420
420
|
<details disabled>
|
|
421
421
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -440,7 +440,7 @@ Returns:
|
|
|
440
440
|
|----|-----------|
|
|
441
441
|
|`Bool`|`true` if the first value is equal to zero or `false` otherwise|
|
|
442
442
|
|
|
443
|
-
###
|
|
443
|
+
### BigInt.**eq**
|
|
444
444
|
|
|
445
445
|
<details disabled>
|
|
446
446
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -466,7 +466,7 @@ Returns:
|
|
|
466
466
|
|----|-----------|
|
|
467
467
|
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
468
468
|
|
|
469
|
-
###
|
|
469
|
+
### BigInt.**ne**
|
|
470
470
|
|
|
471
471
|
<details disabled>
|
|
472
472
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -492,7 +492,7 @@ Returns:
|
|
|
492
492
|
|----|-----------|
|
|
493
493
|
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
494
494
|
|
|
495
|
-
###
|
|
495
|
+
### BigInt.**lt**
|
|
496
496
|
|
|
497
497
|
<details disabled>
|
|
498
498
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -518,7 +518,7 @@ Returns:
|
|
|
518
518
|
|----|-----------|
|
|
519
519
|
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
520
520
|
|
|
521
|
-
###
|
|
521
|
+
### BigInt.**lte**
|
|
522
522
|
|
|
523
523
|
<details disabled>
|
|
524
524
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -544,7 +544,7 @@ Returns:
|
|
|
544
544
|
|----|-----------|
|
|
545
545
|
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
546
546
|
|
|
547
|
-
###
|
|
547
|
+
### BigInt.**gt**
|
|
548
548
|
|
|
549
549
|
<details disabled>
|
|
550
550
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -570,7 +570,7 @@ Returns:
|
|
|
570
570
|
|----|-----------|
|
|
571
571
|
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
572
572
|
|
|
573
|
-
###
|
|
573
|
+
### BigInt.**gte**
|
|
574
574
|
|
|
575
575
|
<details disabled>
|
|
576
576
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -600,7 +600,7 @@ Returns:
|
|
|
600
600
|
|
|
601
601
|
Boolean operations on the bits of BigInt values.
|
|
602
602
|
|
|
603
|
-
###
|
|
603
|
+
### BigInt.**lnot**
|
|
604
604
|
|
|
605
605
|
<details disabled>
|
|
606
606
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -625,7 +625,7 @@ Returns:
|
|
|
625
625
|
|----|-----------|
|
|
626
626
|
|`BigInt`|Containing the inverted bits of the given value|
|
|
627
627
|
|
|
628
|
-
###
|
|
628
|
+
### BigInt.**land**
|
|
629
629
|
|
|
630
630
|
<details disabled>
|
|
631
631
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -651,7 +651,7 @@ Returns:
|
|
|
651
651
|
|----|-----------|
|
|
652
652
|
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
653
653
|
|
|
654
|
-
###
|
|
654
|
+
### BigInt.**lor**
|
|
655
655
|
|
|
656
656
|
<details disabled>
|
|
657
657
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -677,7 +677,7 @@ Returns:
|
|
|
677
677
|
|----|-----------|
|
|
678
678
|
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
679
679
|
|
|
680
|
-
###
|
|
680
|
+
### BigInt.**lxor**
|
|
681
681
|
|
|
682
682
|
<details disabled>
|
|
683
683
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -703,7 +703,7 @@ Returns:
|
|
|
703
703
|
|----|-----------|
|
|
704
704
|
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
705
705
|
|
|
706
|
-
###
|
|
706
|
+
### BigInt.**clz**
|
|
707
707
|
|
|
708
708
|
<details disabled>
|
|
709
709
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -729,7 +729,7 @@ Returns:
|
|
|
729
729
|
|----|-----------|
|
|
730
730
|
|`Int32`|The amount of leading zeros|
|
|
731
731
|
|
|
732
|
-
###
|
|
732
|
+
### BigInt.**ctz**
|
|
733
733
|
|
|
734
734
|
<details disabled>
|
|
735
735
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -754,7 +754,7 @@ Returns:
|
|
|
754
754
|
|----|-----------|
|
|
755
755
|
|`Int64`|The amount of trailing zeros|
|
|
756
756
|
|
|
757
|
-
###
|
|
757
|
+
### BigInt.**popcnt**
|
|
758
758
|
|
|
759
759
|
<details disabled>
|
|
760
760
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
@@ -784,7 +784,7 @@ Returns:
|
|
|
784
784
|
|
|
785
785
|
Other functions on BigInts.
|
|
786
786
|
|
|
787
|
-
###
|
|
787
|
+
### BigInt.**toString**
|
|
788
788
|
|
|
789
789
|
<details disabled>
|
|
790
790
|
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
package/buffer.gr
CHANGED
|
@@ -339,32 +339,34 @@ export let addBytesSlice =
|
|
|
339
339
|
bytes: Bytes,
|
|
340
340
|
buffer: Buffer,
|
|
341
341
|
) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
if (length != 0) {
|
|
343
|
+
let (-) = WasmI32.sub
|
|
344
|
+
let (<) = WasmI32.ltS
|
|
345
|
+
let (>) = WasmI32.gtS
|
|
346
|
+
let (>=) = WasmI32.geS
|
|
347
|
+
|
|
348
|
+
// bounds check start
|
|
349
|
+
let bytelen = WasmI32.load(WasmI32.fromGrain(bytes), 4n)
|
|
350
|
+
let srcOff = coerceNumberToWasmI32(start)
|
|
351
|
+
if (srcOff < 0n || srcOff >= bytelen) {
|
|
352
|
+
throw Exception.IndexOutOfBounds
|
|
353
|
+
}
|
|
353
354
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
// bounds check length
|
|
356
|
+
let len = coerceNumberToWasmI32(length)
|
|
357
|
+
if (len < 0n || len > bytelen - srcOff) {
|
|
358
|
+
throw Exception.IndexOutOfBounds
|
|
359
|
+
}
|
|
359
360
|
|
|
360
|
-
|
|
361
|
+
autogrow(length, buffer)
|
|
361
362
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
let dstOff = coerceNumberToWasmI32(buffer.len)
|
|
364
|
+
let src = WasmI32.fromGrain(bytes)
|
|
365
|
+
let dst = WasmI32.fromGrain(buffer.data)
|
|
366
|
+
appendBytes(srcOff, dstOff, len, src, dst)
|
|
366
367
|
|
|
367
|
-
|
|
368
|
+
buffer.len += length
|
|
369
|
+
}
|
|
368
370
|
}
|
|
369
371
|
|
|
370
372
|
/**
|
package/float32.md
CHANGED
|
@@ -46,7 +46,7 @@ NaN (Not a Number) represented as a Float32 value.
|
|
|
46
46
|
### Float32.**pi**
|
|
47
47
|
|
|
48
48
|
<details disabled>
|
|
49
|
-
<summary tabindex="-1">Added in <code>
|
|
49
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
50
50
|
No other changes yet.
|
|
51
51
|
</details>
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ Pi represented as a Float32 value.
|
|
|
59
59
|
### Float32.**tau**
|
|
60
60
|
|
|
61
61
|
<details disabled>
|
|
62
|
-
<summary tabindex="-1">Added in <code>
|
|
62
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
63
63
|
No other changes yet.
|
|
64
64
|
</details>
|
|
65
65
|
|
|
@@ -72,7 +72,7 @@ Tau represented as a Float32 value.
|
|
|
72
72
|
### Float32.**e**
|
|
73
73
|
|
|
74
74
|
<details disabled>
|
|
75
|
-
<summary tabindex="-1">Added in <code>
|
|
75
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
76
76
|
No other changes yet.
|
|
77
77
|
</details>
|
|
78
78
|
|
package/float64.md
CHANGED
|
@@ -46,7 +46,7 @@ NaN (Not a Number) represented as a Float64 value.
|
|
|
46
46
|
### Float64.**pi**
|
|
47
47
|
|
|
48
48
|
<details disabled>
|
|
49
|
-
<summary tabindex="-1">Added in <code>
|
|
49
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
50
50
|
No other changes yet.
|
|
51
51
|
</details>
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ Pi represented as a Float64 value.
|
|
|
59
59
|
### Float64.**tau**
|
|
60
60
|
|
|
61
61
|
<details disabled>
|
|
62
|
-
<summary tabindex="-1">Added in <code>
|
|
62
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
63
63
|
No other changes yet.
|
|
64
64
|
</details>
|
|
65
65
|
|
|
@@ -72,7 +72,7 @@ Tau represented as a Float64 value.
|
|
|
72
72
|
### Float64.**e**
|
|
73
73
|
|
|
74
74
|
<details disabled>
|
|
75
|
-
<summary tabindex="-1">Added in <code>
|
|
75
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
76
76
|
No other changes yet.
|
|
77
77
|
</details>
|
|
78
78
|
|