@grain/stdlib 0.5.3 → 0.5.5
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 +61 -0
- package/array.gr +65 -57
- package/array.md +54 -6
- package/buffer.gr +71 -1
- package/buffer.md +142 -0
- package/bytes.gr +52 -3
- package/bytes.md +117 -0
- package/char.gr +23 -20
- package/char.md +18 -3
- package/immutablemap.gr +493 -0
- package/immutablemap.md +479 -0
- package/immutablepriorityqueue.gr +44 -16
- package/immutablepriorityqueue.md +44 -1
- package/immutableset.gr +498 -0
- package/immutableset.md +449 -0
- package/int32.gr +39 -37
- package/int32.md +6 -0
- package/int64.gr +39 -37
- package/int64.md +6 -0
- package/list.gr +33 -24
- package/list.md +39 -10
- package/map.gr +19 -28
- package/marshal.gr +4 -4
- package/number.gr +727 -26
- package/number.md +345 -23
- package/option.gr +30 -26
- package/option.md +12 -0
- package/package.json +1 -1
- package/path.gr +787 -0
- package/path.md +727 -0
- package/pervasives.gr +3 -4
- package/pervasives.md +6 -1
- package/priorityqueue.gr +25 -5
- package/priorityqueue.md +30 -0
- package/queue.gr +22 -7
- package/queue.md +18 -1
- package/regex.gr +161 -65
- package/regex.md +70 -0
- package/result.gr +24 -20
- package/result.md +12 -0
- package/runtime/atof/common.gr +198 -0
- package/runtime/atof/common.md +243 -0
- package/runtime/atof/decimal.gr +663 -0
- package/runtime/atof/decimal.md +59 -0
- package/runtime/atof/lemire.gr +264 -0
- package/runtime/atof/lemire.md +6 -0
- package/runtime/atof/parse.gr +615 -0
- package/runtime/atof/parse.md +12 -0
- package/runtime/atof/slow.gr +238 -0
- package/runtime/atof/slow.md +6 -0
- package/runtime/atof/table.gr +2016 -0
- package/runtime/atof/table.md +12 -0
- package/runtime/{stringUtils.gr → atoi/parse.gr} +1 -1
- package/runtime/{stringUtils.md → atoi/parse.md} +1 -1
- package/runtime/bigint.gr +7 -7
- package/runtime/compare.gr +2 -1
- package/runtime/equal.gr +3 -2
- package/runtime/exception.gr +9 -5
- package/runtime/exception.md +8 -2
- package/runtime/gc.gr +2 -1
- package/runtime/malloc.gr +1 -3
- package/runtime/numberUtils.gr +13 -13
- package/runtime/numberUtils.md +6 -0
- package/runtime/numbers.gr +123 -39
- package/runtime/numbers.md +26 -0
- package/runtime/string.gr +4 -2
- package/runtime/unsafe/conv.gr +21 -41
- package/runtime/unsafe/conv.md +0 -3
- package/runtime/unsafe/printWasm.gr +4 -40
- package/runtime/utils/printing.gr +3 -3
- package/set.gr +25 -25
- package/stack.gr +14 -0
- package/stack.md +17 -0
- package/string.gr +313 -39
- package/string.md +99 -0
- package/sys/file.gr +1 -1
- package/sys/time.gr +4 -4
package/string.md
CHANGED
|
@@ -514,6 +514,105 @@ Examples:
|
|
|
514
514
|
String.endsWith("world", "Hello world") == true
|
|
515
515
|
```
|
|
516
516
|
|
|
517
|
+
### String.**replaceFirst**
|
|
518
|
+
|
|
519
|
+
<details disabled>
|
|
520
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
521
|
+
No other changes yet.
|
|
522
|
+
</details>
|
|
523
|
+
|
|
524
|
+
```grain
|
|
525
|
+
replaceFirst : (String, String, String) -> String
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Replaces the first appearance of the search pattern in the string with the replacement value.
|
|
529
|
+
|
|
530
|
+
Parameters:
|
|
531
|
+
|
|
532
|
+
|param|type|description|
|
|
533
|
+
|-----|----|-----------|
|
|
534
|
+
|`searchPattern`|`String`|The string to replace|
|
|
535
|
+
|`replacement`|`String`|The replacement|
|
|
536
|
+
|`string`|`String`|The string to change|
|
|
537
|
+
|
|
538
|
+
Returns:
|
|
539
|
+
|
|
540
|
+
|type|description|
|
|
541
|
+
|----|-----------|
|
|
542
|
+
|`String`|A new string with the first occurrence of the search pattern replaced|
|
|
543
|
+
|
|
544
|
+
Examples:
|
|
545
|
+
|
|
546
|
+
```grain
|
|
547
|
+
String.replaceFirst("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌎🌾"
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### String.**replaceLast**
|
|
551
|
+
|
|
552
|
+
<details disabled>
|
|
553
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
554
|
+
No other changes yet.
|
|
555
|
+
</details>
|
|
556
|
+
|
|
557
|
+
```grain
|
|
558
|
+
replaceLast : (String, String, String) -> String
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
Replaces the last appearance of the search pattern in the string with the replacement value.
|
|
562
|
+
|
|
563
|
+
Parameters:
|
|
564
|
+
|
|
565
|
+
|param|type|description|
|
|
566
|
+
|-----|----|-----------|
|
|
567
|
+
|`searchPattern`|`String`|The string to replace|
|
|
568
|
+
|`replacement`|`String`|The replacement|
|
|
569
|
+
|`string`|`String`|The string to change|
|
|
570
|
+
|
|
571
|
+
Returns:
|
|
572
|
+
|
|
573
|
+
|type|description|
|
|
574
|
+
|----|-----------|
|
|
575
|
+
|`String`|A new string with the last occurrence of the search pattern replaced|
|
|
576
|
+
|
|
577
|
+
Examples:
|
|
578
|
+
|
|
579
|
+
```grain
|
|
580
|
+
String.replaceLast("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌾🌎"
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### String.**replaceAll**
|
|
584
|
+
|
|
585
|
+
<details disabled>
|
|
586
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
587
|
+
No other changes yet.
|
|
588
|
+
</details>
|
|
589
|
+
|
|
590
|
+
```grain
|
|
591
|
+
replaceAll : (String, String, String) -> String
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
Replaces every appearance of the search pattern in the string with the replacement value.
|
|
595
|
+
|
|
596
|
+
Parameters:
|
|
597
|
+
|
|
598
|
+
|param|type|description|
|
|
599
|
+
|-----|----|-----------|
|
|
600
|
+
|`searchPattern`|`String`|The string to replace|
|
|
601
|
+
|`replacement`|`String`|The replacement|
|
|
602
|
+
|`string`|`String`|The string to change|
|
|
603
|
+
|
|
604
|
+
Returns:
|
|
605
|
+
|
|
606
|
+
|type|description|
|
|
607
|
+
|----|-----------|
|
|
608
|
+
|`String`|A new string with each occurrence of the search pattern replaced|
|
|
609
|
+
|
|
610
|
+
Examples:
|
|
611
|
+
|
|
612
|
+
```grain
|
|
613
|
+
String.replaceAll("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌎🌎"
|
|
614
|
+
```
|
|
615
|
+
|
|
517
616
|
### String.**encodeAt**
|
|
518
617
|
|
|
519
618
|
<details disabled>
|
package/sys/file.gr
CHANGED
|
@@ -816,7 +816,7 @@ export let fdStats = (fd: FileDescriptor) => {
|
|
|
816
816
|
let rightsInheriting = WasmI64.load(structPtr, 16n)
|
|
817
817
|
(rightsInheriting &
|
|
818
818
|
1N << WasmI64.extendI32U(WasmI32.fromGrain(i) >> 1n)) >
|
|
819
|
-
|
|
819
|
+
0N
|
|
820
820
|
}
|
|
821
821
|
let rightsInheritingList = List.filteri(flagsToWasmVal, orderedRights)
|
|
822
822
|
|
package/sys/time.gr
CHANGED
|
@@ -38,7 +38,7 @@ let getClockTime = (clockid, precision) => {
|
|
|
38
38
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
39
39
|
*/
|
|
40
40
|
@unsafe
|
|
41
|
-
export let
|
|
41
|
+
export let realTime = () => {
|
|
42
42
|
getClockTime(Wasi._CLOCK_REALTIME, 1000N)
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -51,7 +51,7 @@ export let rec realTime = () => {
|
|
|
51
51
|
* @returns `Ok(time)` of the current time if successful or `Err(exception)` otherwise
|
|
52
52
|
*/
|
|
53
53
|
@unsafe
|
|
54
|
-
export let
|
|
54
|
+
export let monotonicTime = () => {
|
|
55
55
|
getClockTime(Wasi._CLOCK_MONOTONIC, 1N)
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ export let rec monotonicTime = () => {
|
|
|
61
61
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
62
62
|
*/
|
|
63
63
|
@unsafe
|
|
64
|
-
export let
|
|
64
|
+
export let processCpuTime = () => {
|
|
65
65
|
getClockTime(Wasi._CLOCK_PROCESS_CPUTIME, 1N)
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -71,6 +71,6 @@ export let rec processCpuTime = () => {
|
|
|
71
71
|
* @returns `Ok(elapsed)` of the elapsed nanoseconds if successful or `Err(exception)` otherwise
|
|
72
72
|
*/
|
|
73
73
|
@unsafe
|
|
74
|
-
export let
|
|
74
|
+
export let threadCpuTime = () => {
|
|
75
75
|
getClockTime(Wasi._CLOCK_THREAD_CPUTIME, 1N)
|
|
76
76
|
}
|