@grain/stdlib 0.5.13 → 0.6.0

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 (155) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +47 -37
  21. package/hash.md +21 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2084 -0
  31. package/json.md +608 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +191 -172
  92. package/runtime/numberUtils.md +17 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +540 -242
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
package/uint16.md ADDED
@@ -0,0 +1,585 @@
1
+ ---
2
+ title: Uint16
3
+ ---
4
+
5
+ Utilities for working with the Uint16 type.
6
+
7
+ <details disabled>
8
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
9
+ No other changes yet.
10
+ </details>
11
+
12
+ ```grain
13
+ from "uint16" include Uint16
14
+ ```
15
+
16
+ ## Values
17
+
18
+ Functions and constants included in the Uint16 module.
19
+
20
+ ### Uint16.**fromNumber**
21
+
22
+ <details disabled>
23
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
24
+ No other changes yet.
25
+ </details>
26
+
27
+ ```grain
28
+ fromNumber : (number: Number) => Uint16
29
+ ```
30
+
31
+ Converts a Number to a Uint16.
32
+
33
+ Parameters:
34
+
35
+ |param|type|description|
36
+ |-----|----|-----------|
37
+ |`number`|`Number`|The value to convert|
38
+
39
+ Returns:
40
+
41
+ |type|description|
42
+ |----|-----------|
43
+ |`Uint16`|The Number represented as a Uint16|
44
+
45
+ ### Uint16.**toNumber**
46
+
47
+ <details disabled>
48
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
49
+ No other changes yet.
50
+ </details>
51
+
52
+ ```grain
53
+ toNumber : (value: Uint16) => Number
54
+ ```
55
+
56
+ Converts a Uint16 to a Number.
57
+
58
+ Parameters:
59
+
60
+ |param|type|description|
61
+ |-----|----|-----------|
62
+ |`value`|`Uint16`|The value to convert|
63
+
64
+ Returns:
65
+
66
+ |type|description|
67
+ |----|-----------|
68
+ |`Number`|The Uint16 represented as a Number|
69
+
70
+ ### Uint16.**fromInt16**
71
+
72
+ <details disabled>
73
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
74
+ No other changes yet.
75
+ </details>
76
+
77
+ ```grain
78
+ fromInt16 : (number: Int16) => Uint16
79
+ ```
80
+
81
+ Converts an Int16 to a Uint16.
82
+
83
+ Parameters:
84
+
85
+ |param|type|description|
86
+ |-----|----|-----------|
87
+ |`number`|`Int16`|The value to convert|
88
+
89
+ Returns:
90
+
91
+ |type|description|
92
+ |----|-----------|
93
+ |`Uint16`|The Int16 represented as a Uint16|
94
+
95
+ ### Uint16.**incr**
96
+
97
+ <details disabled>
98
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
99
+ No other changes yet.
100
+ </details>
101
+
102
+ ```grain
103
+ incr : (value: Uint16) => Uint16
104
+ ```
105
+
106
+ Increments the value by one.
107
+
108
+ Parameters:
109
+
110
+ |param|type|description|
111
+ |-----|----|-----------|
112
+ |`value`|`Uint16`|The value to increment|
113
+
114
+ Returns:
115
+
116
+ |type|description|
117
+ |----|-----------|
118
+ |`Uint16`|The incremented value|
119
+
120
+ ### Uint16.**decr**
121
+
122
+ <details disabled>
123
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
124
+ No other changes yet.
125
+ </details>
126
+
127
+ ```grain
128
+ decr : (value: Uint16) => Uint16
129
+ ```
130
+
131
+ Decrements the value by one.
132
+
133
+ Parameters:
134
+
135
+ |param|type|description|
136
+ |-----|----|-----------|
137
+ |`value`|`Uint16`|The value to decrement|
138
+
139
+ Returns:
140
+
141
+ |type|description|
142
+ |----|-----------|
143
+ |`Uint16`|The decremented value|
144
+
145
+ ### Uint16.**(+)**
146
+
147
+ <details disabled>
148
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
149
+ No other changes yet.
150
+ </details>
151
+
152
+ ```grain
153
+ (+) : (x: Uint16, y: Uint16) => Uint16
154
+ ```
155
+
156
+ Computes the sum of its operands.
157
+
158
+ Parameters:
159
+
160
+ |param|type|description|
161
+ |-----|----|-----------|
162
+ |`x`|`Uint16`|The first operand|
163
+ |`y`|`Uint16`|The second operand|
164
+
165
+ Returns:
166
+
167
+ |type|description|
168
+ |----|-----------|
169
+ |`Uint16`|The sum of the two operands|
170
+
171
+ ### Uint16.**(-)**
172
+
173
+ <details disabled>
174
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
175
+ No other changes yet.
176
+ </details>
177
+
178
+ ```grain
179
+ (-) : (x: Uint16, y: Uint16) => Uint16
180
+ ```
181
+
182
+ Computes the difference of its operands.
183
+
184
+ Parameters:
185
+
186
+ |param|type|description|
187
+ |-----|----|-----------|
188
+ |`x`|`Uint16`|The first operand|
189
+ |`y`|`Uint16`|The second operand|
190
+
191
+ Returns:
192
+
193
+ |type|description|
194
+ |----|-----------|
195
+ |`Uint16`|The difference of the two operands|
196
+
197
+ ### Uint16.**(*)**
198
+
199
+ <details disabled>
200
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
201
+ No other changes yet.
202
+ </details>
203
+
204
+ ```grain
205
+ (*) : (x: Uint16, y: Uint16) => Uint16
206
+ ```
207
+
208
+ Computes the product of its operands.
209
+
210
+ Parameters:
211
+
212
+ |param|type|description|
213
+ |-----|----|-----------|
214
+ |`x`|`Uint16`|The first operand|
215
+ |`y`|`Uint16`|The second operand|
216
+
217
+ Returns:
218
+
219
+ |type|description|
220
+ |----|-----------|
221
+ |`Uint16`|The product of the two operands|
222
+
223
+ ### Uint16.**(/)**
224
+
225
+ <details disabled>
226
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
227
+ No other changes yet.
228
+ </details>
229
+
230
+ ```grain
231
+ (/) : (x: Uint16, y: Uint16) => Uint16
232
+ ```
233
+
234
+ Computes the quotient of its operands.
235
+
236
+ Parameters:
237
+
238
+ |param|type|description|
239
+ |-----|----|-----------|
240
+ |`x`|`Uint16`|The first operand|
241
+ |`y`|`Uint16`|The second operand|
242
+
243
+ Returns:
244
+
245
+ |type|description|
246
+ |----|-----------|
247
+ |`Uint16`|The quotient of its operands|
248
+
249
+ ### Uint16.**rem**
250
+
251
+ <details disabled>
252
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
253
+ No other changes yet.
254
+ </details>
255
+
256
+ ```grain
257
+ rem : (x: Uint16, y: Uint16) => Uint16
258
+ ```
259
+
260
+ Computes the remainder of the division of its operands.
261
+
262
+ Parameters:
263
+
264
+ |param|type|description|
265
+ |-----|----|-----------|
266
+ |`x`|`Uint16`|The first operand|
267
+ |`y`|`Uint16`|The second operand|
268
+
269
+ Returns:
270
+
271
+ |type|description|
272
+ |----|-----------|
273
+ |`Uint16`|The remainder of its operands|
274
+
275
+ ### Uint16.**(<<)**
276
+
277
+ <details disabled>
278
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
279
+ No other changes yet.
280
+ </details>
281
+
282
+ ```grain
283
+ (<<) : (value: Uint16, amount: Uint16) => Uint16
284
+ ```
285
+
286
+ Shifts the bits of the value left by the given number of bits.
287
+
288
+ Parameters:
289
+
290
+ |param|type|description|
291
+ |-----|----|-----------|
292
+ |`value`|`Uint16`|The value to shift|
293
+ |`amount`|`Uint16`|The number of bits to shift by|
294
+
295
+ Returns:
296
+
297
+ |type|description|
298
+ |----|-----------|
299
+ |`Uint16`|The shifted value|
300
+
301
+ ### Uint16.**(>>>)**
302
+
303
+ <details disabled>
304
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
305
+ No other changes yet.
306
+ </details>
307
+
308
+ ```grain
309
+ (>>>) : (value: Uint16, amount: Uint16) => Uint16
310
+ ```
311
+
312
+ Shifts the bits of the value right by the given number of bits.
313
+
314
+ Parameters:
315
+
316
+ |param|type|description|
317
+ |-----|----|-----------|
318
+ |`value`|`Uint16`|The value to shift|
319
+ |`amount`|`Uint16`|The amount to shift by|
320
+
321
+ Returns:
322
+
323
+ |type|description|
324
+ |----|-----------|
325
+ |`Uint16`|The shifted value|
326
+
327
+ ### Uint16.**(==)**
328
+
329
+ <details disabled>
330
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
331
+ No other changes yet.
332
+ </details>
333
+
334
+ ```grain
335
+ (==) : (x: Uint16, y: Uint16) => Bool
336
+ ```
337
+
338
+ Checks if the first value is equal to the second value.
339
+
340
+ Parameters:
341
+
342
+ |param|type|description|
343
+ |-----|----|-----------|
344
+ |`x`|`Uint16`|The first value|
345
+ |`y`|`Uint16`|The second value|
346
+
347
+ Returns:
348
+
349
+ |type|description|
350
+ |----|-----------|
351
+ |`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
352
+
353
+ ### Uint16.**(!=)**
354
+
355
+ <details disabled>
356
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
357
+ No other changes yet.
358
+ </details>
359
+
360
+ ```grain
361
+ (!=) : (x: Uint16, y: Uint16) => Bool
362
+ ```
363
+
364
+ Checks if the first value is not equal to the second value.
365
+
366
+ Parameters:
367
+
368
+ |param|type|description|
369
+ |-----|----|-----------|
370
+ |`x`|`Uint16`|The first value|
371
+ |`y`|`Uint16`|The second value|
372
+
373
+ Returns:
374
+
375
+ |type|description|
376
+ |----|-----------|
377
+ |`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
378
+
379
+ ### Uint16.**(<)**
380
+
381
+ <details disabled>
382
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
383
+ No other changes yet.
384
+ </details>
385
+
386
+ ```grain
387
+ (<) : (x: Uint16, y: Uint16) => Bool
388
+ ```
389
+
390
+ Checks if the first value is less than the second value.
391
+
392
+ Parameters:
393
+
394
+ |param|type|description|
395
+ |-----|----|-----------|
396
+ |`x`|`Uint16`|The first value|
397
+ |`y`|`Uint16`|The second value|
398
+
399
+ Returns:
400
+
401
+ |type|description|
402
+ |----|-----------|
403
+ |`Bool`|`true` if the first value is less than the second value or `false` otherwise|
404
+
405
+ ### Uint16.**(>)**
406
+
407
+ <details disabled>
408
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
409
+ No other changes yet.
410
+ </details>
411
+
412
+ ```grain
413
+ (>) : (x: Uint16, y: Uint16) => Bool
414
+ ```
415
+
416
+ Checks if the first value is greater than the second value.
417
+
418
+ Parameters:
419
+
420
+ |param|type|description|
421
+ |-----|----|-----------|
422
+ |`x`|`Uint16`|The first value|
423
+ |`y`|`Uint16`|The second value|
424
+
425
+ Returns:
426
+
427
+ |type|description|
428
+ |----|-----------|
429
+ |`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
430
+
431
+ ### Uint16.**(<=)**
432
+
433
+ <details disabled>
434
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
435
+ No other changes yet.
436
+ </details>
437
+
438
+ ```grain
439
+ (<=) : (x: Uint16, y: Uint16) => Bool
440
+ ```
441
+
442
+ Checks if the first value is less than or equal to the second value.
443
+
444
+ Parameters:
445
+
446
+ |param|type|description|
447
+ |-----|----|-----------|
448
+ |`x`|`Uint16`|The first value|
449
+ |`y`|`Uint16`|The second value|
450
+
451
+ Returns:
452
+
453
+ |type|description|
454
+ |----|-----------|
455
+ |`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
456
+
457
+ ### Uint16.**(>=)**
458
+
459
+ <details disabled>
460
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
461
+ No other changes yet.
462
+ </details>
463
+
464
+ ```grain
465
+ (>=) : (x: Uint16, y: Uint16) => Bool
466
+ ```
467
+
468
+ Checks if the first value is greater than or equal to the second value.
469
+
470
+ Parameters:
471
+
472
+ |param|type|description|
473
+ |-----|----|-----------|
474
+ |`x`|`Uint16`|The first value|
475
+ |`y`|`Uint16`|The second value|
476
+
477
+ Returns:
478
+
479
+ |type|description|
480
+ |----|-----------|
481
+ |`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
482
+
483
+ ### Uint16.**lnot**
484
+
485
+ <details disabled>
486
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
487
+ No other changes yet.
488
+ </details>
489
+
490
+ ```grain
491
+ lnot : (value: Uint16) => Uint16
492
+ ```
493
+
494
+ Computes the bitwise NOT of the given value.
495
+
496
+ Parameters:
497
+
498
+ |param|type|description|
499
+ |-----|----|-----------|
500
+ |`value`|`Uint16`|The given value|
501
+
502
+ Returns:
503
+
504
+ |type|description|
505
+ |----|-----------|
506
+ |`Uint16`|Containing the inverted bits of the given value|
507
+
508
+ ### Uint16.**(&)**
509
+
510
+ <details disabled>
511
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
512
+ No other changes yet.
513
+ </details>
514
+
515
+ ```grain
516
+ (&) : (x: Uint16, y: Uint16) => Uint16
517
+ ```
518
+
519
+ Computes the bitwise AND (`&`) on the given operands.
520
+
521
+ Parameters:
522
+
523
+ |param|type|description|
524
+ |-----|----|-----------|
525
+ |`x`|`Uint16`|The first operand|
526
+ |`y`|`Uint16`|The second operand|
527
+
528
+ Returns:
529
+
530
+ |type|description|
531
+ |----|-----------|
532
+ |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
533
+
534
+ ### Uint16.**(|)**
535
+
536
+ <details disabled>
537
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
538
+ No other changes yet.
539
+ </details>
540
+
541
+ ```grain
542
+ (|) : (x: Uint16, y: Uint16) => Uint16
543
+ ```
544
+
545
+ Computes the bitwise OR (`|`) on the given operands.
546
+
547
+ Parameters:
548
+
549
+ |param|type|description|
550
+ |-----|----|-----------|
551
+ |`x`|`Uint16`|The first operand|
552
+ |`y`|`Uint16`|The second operand|
553
+
554
+ Returns:
555
+
556
+ |type|description|
557
+ |----|-----------|
558
+ |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
559
+
560
+ ### Uint16.**(^)**
561
+
562
+ <details disabled>
563
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
564
+ No other changes yet.
565
+ </details>
566
+
567
+ ```grain
568
+ (^) : (x: Uint16, y: Uint16) => Uint16
569
+ ```
570
+
571
+ Computes the bitwise XOR (`^`) on the given operands.
572
+
573
+ Parameters:
574
+
575
+ |param|type|description|
576
+ |-----|----|-----------|
577
+ |`x`|`Uint16`|The first operand|
578
+ |`y`|`Uint16`|The second operand|
579
+
580
+ Returns:
581
+
582
+ |type|description|
583
+ |----|-----------|
584
+ |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
585
+