@grain/stdlib 0.5.2 → 0.5.4

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 (54) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/array.gr +61 -1
  3. package/array.md +113 -0
  4. package/bigint.md +30 -30
  5. package/buffer.gr +24 -22
  6. package/char.gr +2 -2
  7. package/float32.md +3 -3
  8. package/float64.md +3 -3
  9. package/immutablemap.gr +493 -0
  10. package/immutablemap.md +479 -0
  11. package/immutablepriorityqueue.gr +360 -0
  12. package/immutablepriorityqueue.md +291 -0
  13. package/immutableset.gr +498 -0
  14. package/immutableset.md +449 -0
  15. package/list.gr +75 -2
  16. package/list.md +110 -0
  17. package/map.gr +1 -2
  18. package/marshal.gr +1058 -0
  19. package/marshal.md +76 -0
  20. package/number.gr +689 -23
  21. package/number.md +362 -27
  22. package/package.json +1 -1
  23. package/pervasives.gr +16 -5
  24. package/pervasives.md +28 -0
  25. package/priorityqueue.gr +261 -0
  26. package/priorityqueue.md +309 -0
  27. package/queue.gr +14 -1
  28. package/queue.md +16 -1
  29. package/regex.gr +90 -67
  30. package/runtime/bigint.gr +4 -4
  31. package/runtime/compare.gr +179 -0
  32. package/runtime/compare.md +6 -0
  33. package/runtime/equal.gr +3 -3
  34. package/runtime/exception.gr +9 -5
  35. package/runtime/exception.md +8 -2
  36. package/runtime/gc.gr +2 -1
  37. package/runtime/malloc.gr +1 -3
  38. package/runtime/numberUtils.gr +11 -11
  39. package/runtime/numbers.gr +423 -100
  40. package/runtime/numbers.md +50 -0
  41. package/runtime/string.gr +4 -2
  42. package/set.gr +26 -27
  43. package/stack.gr +12 -0
  44. package/stack.md +15 -0
  45. package/string.gr +409 -53
  46. package/string.md +164 -1
  47. package/sys/file.gr +4 -4
  48. package/sys/file.md +3 -3
  49. package/sys/process.gr +3 -3
  50. package/sys/process.md +3 -3
  51. package/sys/random.gr +2 -2
  52. package/sys/random.md +2 -2
  53. package/sys/time.gr +2 -2
  54. package/sys/time.md +2 -2
package/string.md CHANGED
@@ -148,7 +148,7 @@ No other changes yet.
148
148
  indexOf : (String, String) -> Option<Number>
149
149
  ```
150
150
 
151
- Finds the position of a substring in the input string.
151
+ Finds the first position of a substring in the input string.
152
152
 
153
153
  Parameters:
154
154
 
@@ -169,6 +169,70 @@ Examples:
169
169
  String.indexOf("world", "Hello world") == Some(6)
170
170
  ```
171
171
 
172
+ ### String.**lastIndexOf**
173
+
174
+ <details disabled>
175
+ <summary tabindex="-1">Added in <code>0.5.3</code></summary>
176
+ No other changes yet.
177
+ </details>
178
+
179
+ ```grain
180
+ lastIndexOf : (String, String) -> Option<Number>
181
+ ```
182
+
183
+ Finds the last position of a substring in the input string.
184
+
185
+ Parameters:
186
+
187
+ |param|type|description|
188
+ |-----|----|-----------|
189
+ |`search`|`String`|The substring to find|
190
+ |`string`|`String`|The string to inspect|
191
+
192
+ Returns:
193
+
194
+ |type|description|
195
+ |----|-----------|
196
+ |`Option<Number>`|`Some(position)` containing the starting position of the substring if found or `None` otherwise|
197
+
198
+ Examples:
199
+
200
+ ```grain
201
+ String.lastIndexOf("world", "Hello world world") == Some(12)
202
+ ```
203
+
204
+ ### String.**charCodeAt**
205
+
206
+ <details disabled>
207
+ <summary tabindex="-1">Added in <code>0.5.3</code></summary>
208
+ No other changes yet.
209
+ </details>
210
+
211
+ ```grain
212
+ charCodeAt : (Number, String) -> Number
213
+ ```
214
+
215
+ Get the Unicode code point at the position in the input string.
216
+
217
+ Parameters:
218
+
219
+ |param|type|description|
220
+ |-----|----|-----------|
221
+ |`position`|`Number`|The position to check|
222
+ |`string`|`String`|The string to search|
223
+
224
+ Returns:
225
+
226
+ |type|description|
227
+ |----|-----------|
228
+ |`Number`|The character code at the provided position|
229
+
230
+ Examples:
231
+
232
+ ```grain
233
+ String.charCodeAt(5, "Hello world") == 32
234
+ ```
235
+
172
236
  ### String.**charAt**
173
237
 
174
238
  <details disabled>
@@ -450,6 +514,105 @@ Examples:
450
514
  String.endsWith("world", "Hello world") == true
451
515
  ```
452
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
+
453
616
  ### String.**encodeAt**
454
617
 
455
618
  <details disabled>
package/sys/file.gr CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module Sys/File: Utilities for accessing the filesystem & working with files.
2
+ * @module File: Utilities for accessing the filesystem & working with files.
3
3
  *
4
4
  * Many of the functions in this module are not intended to be used directly, but rather for other libraries to be built on top of them.
5
5
  *
@@ -36,7 +36,7 @@ import {
36
36
  import List from "list"
37
37
 
38
38
  /**
39
- * @section Types: Type declarations included in the Sys/File module.
39
+ * @section Types: Type declarations included in the File module.
40
40
  */
41
41
 
42
42
  /**
@@ -421,7 +421,7 @@ export record DirectoryEntry {
421
421
  }
422
422
 
423
423
  /**
424
- * @section Values: Functions and constants included in the Sys/File module.
424
+ * @section Values: Functions and constants included in the File module.
425
425
  */
426
426
 
427
427
  /**
@@ -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/file.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Sys/File
2
+ title: File
3
3
  ---
4
4
 
5
5
  Utilities for accessing the filesystem & working with files.
@@ -12,7 +12,7 @@ import File from "sys/file"
12
12
 
13
13
  ## Types
14
14
 
15
- Type declarations included in the Sys/File module.
15
+ Type declarations included in the File module.
16
16
 
17
17
  ### File.**FileDescriptor**
18
18
 
@@ -173,7 +173,7 @@ An entry in a directory.
173
173
 
174
174
  ## Values
175
175
 
176
- Functions and constants included in the Sys/File module.
176
+ Functions and constants included in the File module.
177
177
 
178
178
  ### File.**stdin**
179
179
 
package/sys/process.gr CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module Sys/Process: Utilities for accessing functionality and information about the Grain program's process.
2
+ * @module Process: Utilities for accessing functionality and information about the Grain program's process.
3
3
  *
4
4
  * This includes things like accessing environment variables and sending signals.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  } from "runtime/dataStructures"
26
26
 
27
27
  /**
28
- * @section Types: Type declarations included in the Sys/Process module.
28
+ * @section Types: Type declarations included in the Process module.
29
29
  */
30
30
 
31
31
  /**
@@ -91,7 +91,7 @@ export enum Signal {
91
91
  }
92
92
 
93
93
  /**
94
- * @section Values: Functions and constants included in the Sys/Process module.
94
+ * @section Values: Functions and constants included in the Process module.
95
95
  */
96
96
 
97
97
  /**
package/sys/process.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Sys/Process
2
+ title: Process
3
3
  ---
4
4
 
5
5
  Utilities for accessing functionality and information about the Grain program's process.
@@ -12,7 +12,7 @@ import Process from "sys/process"
12
12
 
13
13
  ## Types
14
14
 
15
- Type declarations included in the Sys/Process module.
15
+ Type declarations included in the Process module.
16
16
 
17
17
  ### Process.**Signal**
18
18
 
@@ -55,7 +55,7 @@ Signals that can be sent to the host system.
55
55
 
56
56
  ## Values
57
57
 
58
- Functions and constants included in the Sys/Process module.
58
+ Functions and constants included in the Process module.
59
59
 
60
60
  ### Process.**argv**
61
61
 
package/sys/random.gr CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module Sys/Random: System access to random values.
2
+ * @module Random: System access to random values.
3
3
  *
4
4
  * @example import Random from "sys/random"
5
5
  */
@@ -11,7 +11,7 @@ import Wasi from "runtime/wasi"
11
11
  import { tagSimpleNumber, newInt32, newInt64 } from "runtime/dataStructures"
12
12
 
13
13
  /**
14
- * @section Values: Functions and constants included in the Sys/Random module.
14
+ * @section Values: Functions and constants included in the Random module.
15
15
  */
16
16
 
17
17
  /**
package/sys/random.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Sys/Random
2
+ title: Random
3
3
  ---
4
4
 
5
5
  System access to random values.
@@ -10,7 +10,7 @@ import Random from "sys/random"
10
10
 
11
11
  ## Values
12
12
 
13
- Functions and constants included in the Sys/Random module.
13
+ Functions and constants included in the Random module.
14
14
 
15
15
  ### Random.**randomInt32**
16
16
 
package/sys/time.gr CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @module Sys/Time: Access to system clocks.
2
+ * @module Time: Access to system clocks.
3
3
  *
4
4
  * @example import Time from "sys/time"
5
5
  */
@@ -15,7 +15,7 @@ import Errors from "runtime/unsafe/errors"
15
15
  import { allocateInt64, tagSimpleNumber } from "runtime/dataStructures"
16
16
 
17
17
  /**
18
- * @section Values: Functions and constants included in the Sys/Time module.
18
+ * @section Values: Functions and constants included in the Time module.
19
19
  */
20
20
 
21
21
  @unsafe
package/sys/time.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Sys/Time
2
+ title: Time
3
3
  ---
4
4
 
5
5
  Access to system clocks.
@@ -10,7 +10,7 @@ import Time from "sys/time"
10
10
 
11
11
  ## Values
12
12
 
13
- Functions and constants included in the Sys/Time module.
13
+ Functions and constants included in the Time module.
14
14
 
15
15
  ### Time.**realTime**
16
16