@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.
Files changed (77) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/array.gr +65 -57
  3. package/array.md +54 -6
  4. package/buffer.gr +71 -1
  5. package/buffer.md +142 -0
  6. package/bytes.gr +52 -3
  7. package/bytes.md +117 -0
  8. package/char.gr +23 -20
  9. package/char.md +18 -3
  10. package/immutablemap.gr +493 -0
  11. package/immutablemap.md +479 -0
  12. package/immutablepriorityqueue.gr +44 -16
  13. package/immutablepriorityqueue.md +44 -1
  14. package/immutableset.gr +498 -0
  15. package/immutableset.md +449 -0
  16. package/int32.gr +39 -37
  17. package/int32.md +6 -0
  18. package/int64.gr +39 -37
  19. package/int64.md +6 -0
  20. package/list.gr +33 -24
  21. package/list.md +39 -10
  22. package/map.gr +19 -28
  23. package/marshal.gr +4 -4
  24. package/number.gr +727 -26
  25. package/number.md +345 -23
  26. package/option.gr +30 -26
  27. package/option.md +12 -0
  28. package/package.json +1 -1
  29. package/path.gr +787 -0
  30. package/path.md +727 -0
  31. package/pervasives.gr +3 -4
  32. package/pervasives.md +6 -1
  33. package/priorityqueue.gr +25 -5
  34. package/priorityqueue.md +30 -0
  35. package/queue.gr +22 -7
  36. package/queue.md +18 -1
  37. package/regex.gr +161 -65
  38. package/regex.md +70 -0
  39. package/result.gr +24 -20
  40. package/result.md +12 -0
  41. package/runtime/atof/common.gr +198 -0
  42. package/runtime/atof/common.md +243 -0
  43. package/runtime/atof/decimal.gr +663 -0
  44. package/runtime/atof/decimal.md +59 -0
  45. package/runtime/atof/lemire.gr +264 -0
  46. package/runtime/atof/lemire.md +6 -0
  47. package/runtime/atof/parse.gr +615 -0
  48. package/runtime/atof/parse.md +12 -0
  49. package/runtime/atof/slow.gr +238 -0
  50. package/runtime/atof/slow.md +6 -0
  51. package/runtime/atof/table.gr +2016 -0
  52. package/runtime/atof/table.md +12 -0
  53. package/runtime/{stringUtils.gr → atoi/parse.gr} +1 -1
  54. package/runtime/{stringUtils.md → atoi/parse.md} +1 -1
  55. package/runtime/bigint.gr +7 -7
  56. package/runtime/compare.gr +2 -1
  57. package/runtime/equal.gr +3 -2
  58. package/runtime/exception.gr +9 -5
  59. package/runtime/exception.md +8 -2
  60. package/runtime/gc.gr +2 -1
  61. package/runtime/malloc.gr +1 -3
  62. package/runtime/numberUtils.gr +13 -13
  63. package/runtime/numberUtils.md +6 -0
  64. package/runtime/numbers.gr +123 -39
  65. package/runtime/numbers.md +26 -0
  66. package/runtime/string.gr +4 -2
  67. package/runtime/unsafe/conv.gr +21 -41
  68. package/runtime/unsafe/conv.md +0 -3
  69. package/runtime/unsafe/printWasm.gr +4 -40
  70. package/runtime/utils/printing.gr +3 -3
  71. package/set.gr +25 -25
  72. package/stack.gr +14 -0
  73. package/stack.md +17 -0
  74. package/string.gr +313 -39
  75. package/string.md +99 -0
  76. package/sys/file.gr +1 -1
  77. 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
- 0N
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 rec realTime = () => {
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 rec monotonicTime = () => {
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 rec processCpuTime = () => {
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 rec threadCpuTime = () => {
74
+ export let threadCpuTime = () => {
75
75
  getClockTime(Wasi._CLOCK_THREAD_CPUTIME, 1N)
76
76
  }