@grain/stdlib 0.7.0 → 0.7.2
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 +18 -0
- package/array.md +491 -491
- package/bigint.md +198 -198
- package/buffer.gr +66 -1
- package/buffer.md +395 -272
- package/bytes.gr +1 -0
- package/bytes.md +200 -199
- package/char.md +125 -125
- package/exception.md +9 -9
- package/float32.md +195 -195
- package/float64.md +195 -195
- package/fs.md +115 -115
- package/hash.md +16 -16
- package/int16.md +155 -155
- package/int32.gr +1 -1
- package/int32.md +207 -207
- package/int64.gr +1 -1
- package/int64.md +207 -207
- package/int8.md +155 -155
- package/json.md +59 -59
- package/list.md +347 -347
- package/map.md +222 -222
- package/marshal.md +12 -12
- package/number.gr +119 -5
- package/number.md +503 -261
- package/option.md +141 -141
- package/package.json +2 -2
- package/path.gr +82 -65
- package/path.md +210 -141
- package/pervasives.md +238 -238
- package/priorityqueue.md +112 -112
- package/queue.md +117 -117
- package/random.md +37 -37
- package/range.md +36 -36
- package/rational.md +107 -107
- package/regex.md +91 -91
- package/result.md +102 -102
- package/runtime/atof/decimal.md +6 -6
- package/runtime/compare.md +7 -7
- package/runtime/dataStructures.md +178 -178
- package/runtime/equal.md +7 -7
- package/runtime/exception.md +15 -15
- package/runtime/malloc.md +9 -9
- package/runtime/numbers.md +269 -269
- package/runtime/string.md +17 -17
- package/runtime/unsafe/conv.md +6 -6
- package/runtime/unsafe/memory.gr +2 -19
- package/runtime/unsafe/memory.md +10 -10
- package/runtime/utf8.md +31 -31
- package/runtime/wasi.md +9 -9
- package/set.md +211 -211
- package/stack.md +122 -122
- package/string.md +228 -228
- package/uint16.md +148 -148
- package/uint32.md +192 -192
- package/uint64.md +192 -192
- package/uint8.md +148 -148
- package/uri.md +77 -77
- package/wasi/file.md +269 -269
- package/wasi/process.md +21 -21
- package/wasi/random.md +9 -9
- package/wasi/time.md +12 -12
package/int8.md
CHANGED
|
@@ -40,15 +40,15 @@ Converts a Number to an Int8.
|
|
|
40
40
|
|
|
41
41
|
Parameters:
|
|
42
42
|
|
|
43
|
-
|param|type|description|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
| param | type | description |
|
|
44
|
+
| -------- | -------- | -------------------- |
|
|
45
|
+
| `number` | `Number` | The value to convert |
|
|
46
46
|
|
|
47
47
|
Returns:
|
|
48
48
|
|
|
49
|
-
|type|description|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
| type | description |
|
|
50
|
+
| ------ | --------------------------------- |
|
|
51
|
+
| `Int8` | The Number represented as an Int8 |
|
|
52
52
|
|
|
53
53
|
### Int8.**toNumber**
|
|
54
54
|
|
|
@@ -65,15 +65,15 @@ Converts an Int8 to a Number.
|
|
|
65
65
|
|
|
66
66
|
Parameters:
|
|
67
67
|
|
|
68
|
-
|param|type|description|
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
| param | type | description |
|
|
69
|
+
| ------- | ------ | -------------------- |
|
|
70
|
+
| `value` | `Int8` | The value to convert |
|
|
71
71
|
|
|
72
72
|
Returns:
|
|
73
73
|
|
|
74
|
-
|type|description|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
| type | description |
|
|
75
|
+
| -------- | -------------------------------- |
|
|
76
|
+
| `Number` | The Int8 represented as a Number |
|
|
77
77
|
|
|
78
78
|
### Int8.**fromUint8**
|
|
79
79
|
|
|
@@ -90,15 +90,15 @@ Converts a Uint8 to an Int8.
|
|
|
90
90
|
|
|
91
91
|
Parameters:
|
|
92
92
|
|
|
93
|
-
|param|type|description|
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
| param | type | description |
|
|
94
|
+
| -------- | ------- | -------------------- |
|
|
95
|
+
| `number` | `Uint8` | The value to convert |
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
98
|
|
|
99
|
-
|type|description|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
| type | description |
|
|
100
|
+
| ------ | -------------------------------- |
|
|
101
|
+
| `Int8` | The Uint8 represented as an Int8 |
|
|
102
102
|
|
|
103
103
|
Examples:
|
|
104
104
|
|
|
@@ -121,15 +121,15 @@ Increments the value by one.
|
|
|
121
121
|
|
|
122
122
|
Parameters:
|
|
123
123
|
|
|
124
|
-
|param|type|description|
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
| param | type | description |
|
|
125
|
+
| ------- | ------ | ---------------------- |
|
|
126
|
+
| `value` | `Int8` | The value to increment |
|
|
127
127
|
|
|
128
128
|
Returns:
|
|
129
129
|
|
|
130
|
-
|type|description|
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
| type | description |
|
|
131
|
+
| ------ | --------------------- |
|
|
132
|
+
| `Int8` | The incremented value |
|
|
133
133
|
|
|
134
134
|
Examples:
|
|
135
135
|
|
|
@@ -156,15 +156,15 @@ Decrements the value by one.
|
|
|
156
156
|
|
|
157
157
|
Parameters:
|
|
158
158
|
|
|
159
|
-
|param|type|description|
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
| param | type | description |
|
|
160
|
+
| ------- | ------ | ---------------------- |
|
|
161
|
+
| `value` | `Int8` | The value to decrement |
|
|
162
162
|
|
|
163
163
|
Returns:
|
|
164
164
|
|
|
165
|
-
|type|description|
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
| type | description |
|
|
166
|
+
| ------ | --------------------- |
|
|
167
|
+
| `Int8` | The decremented value |
|
|
168
168
|
|
|
169
169
|
Examples:
|
|
170
170
|
|
|
@@ -191,16 +191,16 @@ Computes the sum of its operands.
|
|
|
191
191
|
|
|
192
192
|
Parameters:
|
|
193
193
|
|
|
194
|
-
|param|type|description|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
| param | type | description |
|
|
195
|
+
| ----- | ------ | ------------------ |
|
|
196
|
+
| `x` | `Int8` | The first operand |
|
|
197
|
+
| `y` | `Int8` | The second operand |
|
|
198
198
|
|
|
199
199
|
Returns:
|
|
200
200
|
|
|
201
|
-
|type|description|
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
| type | description |
|
|
202
|
+
| ------ | --------------------------- |
|
|
203
|
+
| `Int8` | The sum of the two operands |
|
|
204
204
|
|
|
205
205
|
Examples:
|
|
206
206
|
|
|
@@ -224,16 +224,16 @@ Computes the difference of its operands.
|
|
|
224
224
|
|
|
225
225
|
Parameters:
|
|
226
226
|
|
|
227
|
-
|param|type|description|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
| param | type | description |
|
|
228
|
+
| ----- | ------ | ------------------ |
|
|
229
|
+
| `x` | `Int8` | The first operand |
|
|
230
|
+
| `y` | `Int8` | The second operand |
|
|
231
231
|
|
|
232
232
|
Returns:
|
|
233
233
|
|
|
234
|
-
|type|description|
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
| type | description |
|
|
235
|
+
| ------ | ---------------------------------- |
|
|
236
|
+
| `Int8` | The difference of the two operands |
|
|
237
237
|
|
|
238
238
|
Examples:
|
|
239
239
|
|
|
@@ -257,16 +257,16 @@ Computes the product of its operands.
|
|
|
257
257
|
|
|
258
258
|
Parameters:
|
|
259
259
|
|
|
260
|
-
|param|type|description|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
| param | type | description |
|
|
261
|
+
| ----- | ------ | ------------------ |
|
|
262
|
+
| `x` | `Int8` | The first operand |
|
|
263
|
+
| `y` | `Int8` | The second operand |
|
|
264
264
|
|
|
265
265
|
Returns:
|
|
266
266
|
|
|
267
|
-
|type|description|
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
| type | description |
|
|
268
|
+
| ------ | ------------------------------- |
|
|
269
|
+
| `Int8` | The product of the two operands |
|
|
270
270
|
|
|
271
271
|
Examples:
|
|
272
272
|
|
|
@@ -290,16 +290,16 @@ Computes the quotient of its operands using signed division.
|
|
|
290
290
|
|
|
291
291
|
Parameters:
|
|
292
292
|
|
|
293
|
-
|param|type|description|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
| param | type | description |
|
|
294
|
+
| ----- | ------ | ------------------ |
|
|
295
|
+
| `x` | `Int8` | The first operand |
|
|
296
|
+
| `y` | `Int8` | The second operand |
|
|
297
297
|
|
|
298
298
|
Returns:
|
|
299
299
|
|
|
300
|
-
|type|description|
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
| type | description |
|
|
301
|
+
| ------ | ---------------------------- |
|
|
302
|
+
| `Int8` | The quotient of its operands |
|
|
303
303
|
|
|
304
304
|
Examples:
|
|
305
305
|
|
|
@@ -323,16 +323,16 @@ Computes the remainder of the division of its operands using signed division.
|
|
|
323
323
|
|
|
324
324
|
Parameters:
|
|
325
325
|
|
|
326
|
-
|param|type|description|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
| param | type | description |
|
|
327
|
+
| ----- | ------ | ------------------ |
|
|
328
|
+
| `x` | `Int8` | The first operand |
|
|
329
|
+
| `y` | `Int8` | The second operand |
|
|
330
330
|
|
|
331
331
|
Returns:
|
|
332
332
|
|
|
333
|
-
|type|description|
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
| type | description |
|
|
334
|
+
| ------ | ----------------------------- |
|
|
335
|
+
| `Int8` | The remainder of its operands |
|
|
336
336
|
|
|
337
337
|
Examples:
|
|
338
338
|
|
|
@@ -356,16 +356,16 @@ The result will have the sign of the second operand.
|
|
|
356
356
|
|
|
357
357
|
Parameters:
|
|
358
358
|
|
|
359
|
-
|param|type|description|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
359
|
+
| param | type | description |
|
|
360
|
+
| ----- | ------ | ------------------ |
|
|
361
|
+
| `x` | `Int8` | The first operand |
|
|
362
|
+
| `y` | `Int8` | The second operand |
|
|
363
363
|
|
|
364
364
|
Returns:
|
|
365
365
|
|
|
366
|
-
|type|description|
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
| type | description |
|
|
367
|
+
| ------ | --------------------------- |
|
|
368
|
+
| `Int8` | The modulus of its operands |
|
|
369
369
|
|
|
370
370
|
Throws:
|
|
371
371
|
|
|
@@ -395,16 +395,16 @@ Shifts the bits of the value left by the given number of bits.
|
|
|
395
395
|
|
|
396
396
|
Parameters:
|
|
397
397
|
|
|
398
|
-
|param|type|description|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
398
|
+
| param | type | description |
|
|
399
|
+
| -------- | ------ | ------------------------------ |
|
|
400
|
+
| `value` | `Int8` | The value to shift |
|
|
401
|
+
| `amount` | `Int8` | The number of bits to shift by |
|
|
402
402
|
|
|
403
403
|
Returns:
|
|
404
404
|
|
|
405
|
-
|type|description|
|
|
406
|
-
|
|
407
|
-
|
|
405
|
+
| type | description |
|
|
406
|
+
| ------ | ----------------- |
|
|
407
|
+
| `Int8` | The shifted value |
|
|
408
408
|
|
|
409
409
|
Examples:
|
|
410
410
|
|
|
@@ -428,16 +428,16 @@ Shifts the bits of the value right by the given number of bits, preserving the s
|
|
|
428
428
|
|
|
429
429
|
Parameters:
|
|
430
430
|
|
|
431
|
-
|param|type|description|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
431
|
+
| param | type | description |
|
|
432
|
+
| -------- | ------ | ---------------------- |
|
|
433
|
+
| `value` | `Int8` | The value to shift |
|
|
434
|
+
| `amount` | `Int8` | The amount to shift by |
|
|
435
435
|
|
|
436
436
|
Returns:
|
|
437
437
|
|
|
438
|
-
|type|description|
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
| type | description |
|
|
439
|
+
| ------ | ----------------- |
|
|
440
|
+
| `Int8` | The shifted value |
|
|
441
441
|
|
|
442
442
|
Examples:
|
|
443
443
|
|
|
@@ -461,16 +461,16 @@ Checks if the first value is equal to the second value.
|
|
|
461
461
|
|
|
462
462
|
Parameters:
|
|
463
463
|
|
|
464
|
-
|param|type|description|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
464
|
+
| param | type | description |
|
|
465
|
+
| ----- | ------ | ---------------- |
|
|
466
|
+
| `x` | `Int8` | The first value |
|
|
467
|
+
| `y` | `Int8` | The second value |
|
|
468
468
|
|
|
469
469
|
Returns:
|
|
470
470
|
|
|
471
|
-
|type|description|
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
| type | description |
|
|
472
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
473
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
474
474
|
|
|
475
475
|
Examples:
|
|
476
476
|
|
|
@@ -494,16 +494,16 @@ Checks if the first value is not equal to the second value.
|
|
|
494
494
|
|
|
495
495
|
Parameters:
|
|
496
496
|
|
|
497
|
-
|param|type|description|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
| param | type | description |
|
|
498
|
+
| ----- | ------ | ---------------- |
|
|
499
|
+
| `x` | `Int8` | The first value |
|
|
500
|
+
| `y` | `Int8` | The second value |
|
|
501
501
|
|
|
502
502
|
Returns:
|
|
503
503
|
|
|
504
|
-
|type|description|
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
| type | description |
|
|
505
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
506
|
+
| `Bool` | `true` if the first value is not equal to the second value or `false` otherwise |
|
|
507
507
|
|
|
508
508
|
Examples:
|
|
509
509
|
|
|
@@ -527,16 +527,16 @@ Checks if the first value is less than the second value.
|
|
|
527
527
|
|
|
528
528
|
Parameters:
|
|
529
529
|
|
|
530
|
-
|param|type|description|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
530
|
+
| param | type | description |
|
|
531
|
+
| ----- | ------ | ---------------- |
|
|
532
|
+
| `x` | `Int8` | The first value |
|
|
533
|
+
| `y` | `Int8` | The second value |
|
|
534
534
|
|
|
535
535
|
Returns:
|
|
536
536
|
|
|
537
|
-
|type|description|
|
|
538
|
-
|
|
539
|
-
|
|
537
|
+
| type | description |
|
|
538
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
539
|
+
| `Bool` | `true` if the first value is less than the second value or `false` otherwise |
|
|
540
540
|
|
|
541
541
|
Examples:
|
|
542
542
|
|
|
@@ -560,16 +560,16 @@ Checks if the first value is greater than the second value.
|
|
|
560
560
|
|
|
561
561
|
Parameters:
|
|
562
562
|
|
|
563
|
-
|param|type|description|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
563
|
+
| param | type | description |
|
|
564
|
+
| ----- | ------ | ---------------- |
|
|
565
|
+
| `x` | `Int8` | The first value |
|
|
566
|
+
| `y` | `Int8` | The second value |
|
|
567
567
|
|
|
568
568
|
Returns:
|
|
569
569
|
|
|
570
|
-
|type|description|
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
| type | description |
|
|
571
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
572
|
+
| `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
|
|
573
573
|
|
|
574
574
|
Examples:
|
|
575
575
|
|
|
@@ -593,16 +593,16 @@ Checks if the first value is less than or equal to the second value.
|
|
|
593
593
|
|
|
594
594
|
Parameters:
|
|
595
595
|
|
|
596
|
-
|param|type|description|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
596
|
+
| param | type | description |
|
|
597
|
+
| ----- | ------ | ---------------- |
|
|
598
|
+
| `x` | `Int8` | The first value |
|
|
599
|
+
| `y` | `Int8` | The second value |
|
|
600
600
|
|
|
601
601
|
Returns:
|
|
602
602
|
|
|
603
|
-
|type|description|
|
|
604
|
-
|
|
605
|
-
|
|
603
|
+
| type | description |
|
|
604
|
+
| ------ | ---------------------------------------------------------------------------------------- |
|
|
605
|
+
| `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
|
|
606
606
|
|
|
607
607
|
Examples:
|
|
608
608
|
|
|
@@ -631,16 +631,16 @@ Checks if the first value is greater than or equal to the second value.
|
|
|
631
631
|
|
|
632
632
|
Parameters:
|
|
633
633
|
|
|
634
|
-
|param|type|description|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
634
|
+
| param | type | description |
|
|
635
|
+
| ----- | ------ | ---------------- |
|
|
636
|
+
| `x` | `Int8` | The first value |
|
|
637
|
+
| `y` | `Int8` | The second value |
|
|
638
638
|
|
|
639
639
|
Returns:
|
|
640
640
|
|
|
641
|
-
|type|description|
|
|
642
|
-
|
|
643
|
-
|
|
641
|
+
| type | description |
|
|
642
|
+
| ------ | ------------------------------------------------------------------------------------------- |
|
|
643
|
+
| `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
|
|
644
644
|
|
|
645
645
|
Examples:
|
|
646
646
|
|
|
@@ -669,15 +669,15 @@ Computes the bitwise NOT of the given value.
|
|
|
669
669
|
|
|
670
670
|
Parameters:
|
|
671
671
|
|
|
672
|
-
|param|type|description|
|
|
673
|
-
|
|
674
|
-
|
|
672
|
+
| param | type | description |
|
|
673
|
+
| ------- | ------ | --------------- |
|
|
674
|
+
| `value` | `Int8` | The given value |
|
|
675
675
|
|
|
676
676
|
Returns:
|
|
677
677
|
|
|
678
|
-
|type|description|
|
|
679
|
-
|
|
680
|
-
|
|
678
|
+
| type | description |
|
|
679
|
+
| ------ | ----------------------------------------------- |
|
|
680
|
+
| `Int8` | Containing the inverted bits of the given value |
|
|
681
681
|
|
|
682
682
|
Examples:
|
|
683
683
|
|
|
@@ -700,16 +700,16 @@ Computes the bitwise AND (`&`) on the given operands.
|
|
|
700
700
|
|
|
701
701
|
Parameters:
|
|
702
702
|
|
|
703
|
-
|param|type|description|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
703
|
+
| param | type | description |
|
|
704
|
+
| ----- | ------ | ------------------ |
|
|
705
|
+
| `x` | `Int8` | The first operand |
|
|
706
|
+
| `y` | `Int8` | The second operand |
|
|
707
707
|
|
|
708
708
|
Returns:
|
|
709
709
|
|
|
710
|
-
|type|description|
|
|
711
|
-
|
|
712
|
-
|
|
710
|
+
| type | description |
|
|
711
|
+
| ------ | ----------------------------------------------------------------------------------------------- |
|
|
712
|
+
| `Int8` | Containing a `1` in each bit position for which the corresponding bits of both operands are `1` |
|
|
713
713
|
|
|
714
714
|
Examples:
|
|
715
715
|
|
|
@@ -733,16 +733,16 @@ Computes the bitwise OR (`|`) on the given operands.
|
|
|
733
733
|
|
|
734
734
|
Parameters:
|
|
735
735
|
|
|
736
|
-
|param|type|description|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
736
|
+
| param | type | description |
|
|
737
|
+
| ----- | ------ | ------------------ |
|
|
738
|
+
| `x` | `Int8` | The first operand |
|
|
739
|
+
| `y` | `Int8` | The second operand |
|
|
740
740
|
|
|
741
741
|
Returns:
|
|
742
742
|
|
|
743
|
-
|type|description|
|
|
744
|
-
|
|
745
|
-
|
|
743
|
+
| type | description |
|
|
744
|
+
| ------ | --------------------------------------------------------------------------------------------------------- |
|
|
745
|
+
| `Int8` | Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1` |
|
|
746
746
|
|
|
747
747
|
Examples:
|
|
748
748
|
|
|
@@ -766,16 +766,16 @@ Computes the bitwise XOR (`^`) on the given operands.
|
|
|
766
766
|
|
|
767
767
|
Parameters:
|
|
768
768
|
|
|
769
|
-
|param|type|description|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
769
|
+
| param | type | description |
|
|
770
|
+
| ----- | ------ | ------------------ |
|
|
771
|
+
| `x` | `Int8` | The first operand |
|
|
772
|
+
| `y` | `Int8` | The second operand |
|
|
773
773
|
|
|
774
774
|
Returns:
|
|
775
775
|
|
|
776
|
-
|type|description|
|
|
777
|
-
|
|
778
|
-
|
|
776
|
+
| type | description |
|
|
777
|
+
| ------ | -------------------------------------------------------------------------------------------------------------- |
|
|
778
|
+
| `Int8` | Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1` |
|
|
779
779
|
|
|
780
780
|
Examples:
|
|
781
781
|
|