@grain/stdlib 0.6.5 → 0.7.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.
- package/CHANGELOG.md +64 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +123 -77
- package/bigint.md +30 -30
- package/buffer.gr +20 -53
- package/buffer.md +47 -47
- package/bytes.gr +111 -35
- package/bytes.md +111 -32
- package/char.gr +201 -99
- package/char.md +361 -34
- package/exception.gr +11 -11
- package/exception.md +26 -1
- package/float32.gr +327 -3
- package/float32.md +606 -19
- package/float64.gr +320 -3
- package/float64.md +606 -19
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +102 -14
- package/int16.md +23 -23
- package/int32.gr +25 -4
- package/int32.md +65 -30
- package/int64.gr +26 -1
- package/int64.md +65 -30
- package/int8.md +23 -23
- package/json.gr +366 -51
- package/json.md +418 -2
- package/list.gr +387 -49
- package/list.md +492 -69
- package/map.gr +20 -12
- package/map.md +44 -38
- package/marshal.gr +41 -40
- package/marshal.md +2 -2
- package/number.gr +159 -30
- package/number.md +215 -38
- package/option.md +21 -21
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +103 -12
- package/pervasives.gr +2 -2
- package/pervasives.md +37 -37
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +19 -19
- package/queue.gr +183 -29
- package/queue.md +296 -40
- package/random.md +6 -6
- package/range.gr +4 -4
- package/range.md +6 -6
- package/rational.md +16 -16
- package/regex.gr +52 -51
- package/regex.md +11 -11
- package/result.md +16 -16
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +8 -8
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +1 -1
- package/runtime/dataStructures.md +33 -33
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +1 -1
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +4 -4
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +79 -73
- package/runtime/string.gr +37 -105
- package/runtime/string.md +3 -9
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +13 -13
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +138 -138
- package/set.gr +18 -11
- package/set.md +42 -36
- package/stack.gr +171 -2
- package/stack.md +297 -15
- package/string.gr +352 -557
- package/string.md +77 -34
- package/uint16.gr +81 -0
- package/uint16.md +183 -22
- package/uint32.gr +25 -4
- package/uint32.md +63 -28
- package/uint64.gr +25 -5
- package/uint64.md +63 -28
- package/uint8.gr +81 -0
- package/uint8.md +183 -22
- package/uri.gr +57 -53
- package/uri.md +11 -12
- package/wasi/file.gr +67 -59
- package/wasi/file.md +39 -39
- package/wasi/process.md +5 -5
- package/wasi/random.md +3 -3
- package/wasi/time.md +4 -4
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/string.md
CHANGED
|
@@ -51,7 +51,7 @@ No other changes yet.
|
|
|
51
51
|
</details>
|
|
52
52
|
|
|
53
53
|
```grain
|
|
54
|
-
concat
|
|
54
|
+
concat: (str1: String, str2: String) => String
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
Concatenate two strings.
|
|
@@ -83,7 +83,7 @@ No other changes yet.
|
|
|
83
83
|
</details>
|
|
84
84
|
|
|
85
85
|
```grain
|
|
86
|
-
length
|
|
86
|
+
length: (string: String) => Number
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Returns the character length of the input string.
|
|
@@ -114,7 +114,7 @@ No other changes yet.
|
|
|
114
114
|
</details>
|
|
115
115
|
|
|
116
116
|
```grain
|
|
117
|
-
byteLength
|
|
117
|
+
byteLength: (string: String) => Number
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
Returns the byte length of the input string.
|
|
@@ -145,7 +145,7 @@ No other changes yet.
|
|
|
145
145
|
</details>
|
|
146
146
|
|
|
147
147
|
```grain
|
|
148
|
-
isEmpty
|
|
148
|
+
isEmpty: (string: String) => Bool
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
Determines if the string contains no characters.
|
|
@@ -170,7 +170,7 @@ No other changes yet.
|
|
|
170
170
|
</details>
|
|
171
171
|
|
|
172
172
|
```grain
|
|
173
|
-
indexOf
|
|
173
|
+
indexOf: (search: String, string: String) => Option<Number>
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
Finds the first position of a substring in the input string.
|
|
@@ -202,7 +202,7 @@ No other changes yet.
|
|
|
202
202
|
</details>
|
|
203
203
|
|
|
204
204
|
```grain
|
|
205
|
-
lastIndexOf
|
|
205
|
+
lastIndexOf: (search: String, string: String) => Option<Number>
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
Finds the last position of a substring in the input string.
|
|
@@ -234,7 +234,7 @@ No other changes yet.
|
|
|
234
234
|
</details>
|
|
235
235
|
|
|
236
236
|
```grain
|
|
237
|
-
charCodeAt
|
|
237
|
+
charCodeAt: (position: Number, string: String) => Number
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
Get the Unicode code point at the position in the input string.
|
|
@@ -276,7 +276,7 @@ No other changes yet.
|
|
|
276
276
|
</details>
|
|
277
277
|
|
|
278
278
|
```grain
|
|
279
|
-
charAt
|
|
279
|
+
charAt: (position: Number, string: String) => Char
|
|
280
280
|
```
|
|
281
281
|
|
|
282
282
|
Get the character at the position in the input string.
|
|
@@ -318,7 +318,7 @@ No other changes yet.
|
|
|
318
318
|
</details>
|
|
319
319
|
|
|
320
320
|
```grain
|
|
321
|
-
explode
|
|
321
|
+
explode: (string: String) => Array<Char>
|
|
322
322
|
```
|
|
323
323
|
|
|
324
324
|
Split a string into its Unicode characters.
|
|
@@ -355,7 +355,7 @@ No other changes yet.
|
|
|
355
355
|
</details>
|
|
356
356
|
|
|
357
357
|
```grain
|
|
358
|
-
implode
|
|
358
|
+
implode: (arr: Array<Char>) => String
|
|
359
359
|
```
|
|
360
360
|
|
|
361
361
|
Create a string from an array of characters.
|
|
@@ -386,7 +386,7 @@ No other changes yet.
|
|
|
386
386
|
</details>
|
|
387
387
|
|
|
388
388
|
```grain
|
|
389
|
-
reverse
|
|
389
|
+
reverse: (string: String) => String
|
|
390
390
|
```
|
|
391
391
|
|
|
392
392
|
Create a string that is the given string reversed.
|
|
@@ -412,7 +412,7 @@ String.reverse("olleH") == "Hello"
|
|
|
412
412
|
### String.**split**
|
|
413
413
|
|
|
414
414
|
```grain
|
|
415
|
-
split
|
|
415
|
+
split: (separator: String, string: String) => Array<String>
|
|
416
416
|
```
|
|
417
417
|
|
|
418
418
|
Split a string by the given separator.
|
|
@@ -457,7 +457,7 @@ String.split(" ", "Hello world") == [> "Hello", "world"]
|
|
|
457
457
|
</details>
|
|
458
458
|
|
|
459
459
|
```grain
|
|
460
|
-
slice
|
|
460
|
+
slice: (start: Number, ?end: Number, string: String) => String
|
|
461
461
|
```
|
|
462
462
|
|
|
463
463
|
Get a portion of a string.
|
|
@@ -507,7 +507,7 @@ No other changes yet.
|
|
|
507
507
|
</details>
|
|
508
508
|
|
|
509
509
|
```grain
|
|
510
|
-
contains
|
|
510
|
+
contains: (search: String, string: String) => Bool
|
|
511
511
|
```
|
|
512
512
|
|
|
513
513
|
Check if a string contains a substring.
|
|
@@ -539,7 +539,7 @@ No other changes yet.
|
|
|
539
539
|
</details>
|
|
540
540
|
|
|
541
541
|
```grain
|
|
542
|
-
startsWith
|
|
542
|
+
startsWith: (search: String, string: String) => Bool
|
|
543
543
|
```
|
|
544
544
|
|
|
545
545
|
Check if a string begins with another string.
|
|
@@ -571,7 +571,7 @@ No other changes yet.
|
|
|
571
571
|
</details>
|
|
572
572
|
|
|
573
573
|
```grain
|
|
574
|
-
endsWith
|
|
574
|
+
endsWith: (search: String, string: String) => Bool
|
|
575
575
|
```
|
|
576
576
|
|
|
577
577
|
Check if a string ends with another string.
|
|
@@ -603,7 +603,7 @@ No other changes yet.
|
|
|
603
603
|
</details>
|
|
604
604
|
|
|
605
605
|
```grain
|
|
606
|
-
replaceFirst
|
|
606
|
+
replaceFirst:
|
|
607
607
|
(searchPattern: String, replacement: String, string: String) => String
|
|
608
608
|
```
|
|
609
609
|
|
|
@@ -637,7 +637,7 @@ No other changes yet.
|
|
|
637
637
|
</details>
|
|
638
638
|
|
|
639
639
|
```grain
|
|
640
|
-
replaceLast
|
|
640
|
+
replaceLast:
|
|
641
641
|
(searchPattern: String, replacement: String, string: String) => String
|
|
642
642
|
```
|
|
643
643
|
|
|
@@ -671,7 +671,7 @@ No other changes yet.
|
|
|
671
671
|
</details>
|
|
672
672
|
|
|
673
673
|
```grain
|
|
674
|
-
replaceAll
|
|
674
|
+
replaceAll:
|
|
675
675
|
(searchPattern: String, replacement: String, string: String) => String
|
|
676
676
|
```
|
|
677
677
|
|
|
@@ -712,7 +712,7 @@ String.replaceAll("🌾", "🌎", "Hello 🌾🌾") == "Hello 🌎🌎"
|
|
|
712
712
|
</details>
|
|
713
713
|
|
|
714
714
|
```grain
|
|
715
|
-
encodeAt
|
|
715
|
+
encodeAt:
|
|
716
716
|
(string: String, encoding: Encoding, dest: Bytes, destPos: Number,
|
|
717
717
|
?includeBom: Bool) => Bytes
|
|
718
718
|
```
|
|
@@ -757,7 +757,7 @@ Throws:
|
|
|
757
757
|
</details>
|
|
758
758
|
|
|
759
759
|
```grain
|
|
760
|
-
encode
|
|
760
|
+
encode: (string: String, encoding: Encoding, ?includeBom: Bool) => Bytes
|
|
761
761
|
```
|
|
762
762
|
|
|
763
763
|
Encodes the given string using the given encoding scheme.
|
|
@@ -791,7 +791,7 @@ Returns:
|
|
|
791
791
|
</details>
|
|
792
792
|
|
|
793
793
|
```grain
|
|
794
|
-
decodeRange
|
|
794
|
+
decodeRange:
|
|
795
795
|
(bytes: Bytes, encoding: Encoding, start: Number, size: Number,
|
|
796
796
|
?keepBom: Bool) => String
|
|
797
797
|
```
|
|
@@ -838,7 +838,7 @@ Throws:
|
|
|
838
838
|
</details>
|
|
839
839
|
|
|
840
840
|
```grain
|
|
841
|
-
decode
|
|
841
|
+
decode: (bytes: Bytes, encoding: Encoding, ?keepBom: Bool) => String
|
|
842
842
|
```
|
|
843
843
|
|
|
844
844
|
Decodes the given byte sequence into a string using the given encoding scheme.
|
|
@@ -865,7 +865,7 @@ No other changes yet.
|
|
|
865
865
|
</details>
|
|
866
866
|
|
|
867
867
|
```grain
|
|
868
|
-
forEachCodePoint
|
|
868
|
+
forEachCodePoint: (fn: (Number => Void), str: String) => Void
|
|
869
869
|
```
|
|
870
870
|
|
|
871
871
|
Iterates over Unicode code points in a string.
|
|
@@ -891,7 +891,7 @@ No other changes yet.
|
|
|
891
891
|
</details>
|
|
892
892
|
|
|
893
893
|
```grain
|
|
894
|
-
forEachCodePointi
|
|
894
|
+
forEachCodePointi: (fn: ((Number, Number) => Void), str: String) => Void
|
|
895
895
|
```
|
|
896
896
|
|
|
897
897
|
Iterates over Unicode code points in a string. This is the same as
|
|
@@ -919,7 +919,7 @@ No other changes yet.
|
|
|
919
919
|
</details>
|
|
920
920
|
|
|
921
921
|
```grain
|
|
922
|
-
forEachChar
|
|
922
|
+
forEachChar: (fn: (Char => Void), str: String) => Void
|
|
923
923
|
```
|
|
924
924
|
|
|
925
925
|
Iterates over Unicode characters in a string.
|
|
@@ -945,7 +945,7 @@ No other changes yet.
|
|
|
945
945
|
</details>
|
|
946
946
|
|
|
947
947
|
```grain
|
|
948
|
-
forEachChari
|
|
948
|
+
forEachChari: (fn: ((Char, Number) => Void), str: String) => Void
|
|
949
949
|
```
|
|
950
950
|
|
|
951
951
|
Iterates over Unicode characters in a string. This is the same as
|
|
@@ -973,7 +973,7 @@ No other changes yet.
|
|
|
973
973
|
</details>
|
|
974
974
|
|
|
975
975
|
```grain
|
|
976
|
-
map
|
|
976
|
+
map: (fn: (Char => Char), str: String) => String
|
|
977
977
|
```
|
|
978
978
|
|
|
979
979
|
Builds a new string by mapping Unicode characters.
|
|
@@ -999,7 +999,7 @@ No other changes yet.
|
|
|
999
999
|
</details>
|
|
1000
1000
|
|
|
1001
1001
|
```grain
|
|
1002
|
-
mapi
|
|
1002
|
+
mapi: (fn: ((Char, Number) => Char), str: String) => String
|
|
1003
1003
|
```
|
|
1004
1004
|
|
|
1005
1005
|
Builds a new string by mapping Unicode characters. This is the same as
|
|
@@ -1027,7 +1027,7 @@ No other changes yet.
|
|
|
1027
1027
|
</details>
|
|
1028
1028
|
|
|
1029
1029
|
```grain
|
|
1030
|
-
trimStart
|
|
1030
|
+
trimStart: (string: String) => String
|
|
1031
1031
|
```
|
|
1032
1032
|
|
|
1033
1033
|
Trims the beginning of a string—removing any leading whitespace characters.
|
|
@@ -1058,7 +1058,7 @@ No other changes yet.
|
|
|
1058
1058
|
</details>
|
|
1059
1059
|
|
|
1060
1060
|
```grain
|
|
1061
|
-
trimEnd
|
|
1061
|
+
trimEnd: (string: String) => String
|
|
1062
1062
|
```
|
|
1063
1063
|
|
|
1064
1064
|
Trims the end of a string—removing any trailing whitespace characters.
|
|
@@ -1089,7 +1089,7 @@ No other changes yet.
|
|
|
1089
1089
|
</details>
|
|
1090
1090
|
|
|
1091
1091
|
```grain
|
|
1092
|
-
trim
|
|
1092
|
+
trim: (string: String) => String
|
|
1093
1093
|
```
|
|
1094
1094
|
|
|
1095
1095
|
Trims a string—removing all leading and trailing whitespace characters.
|
|
@@ -1120,7 +1120,7 @@ No other changes yet.
|
|
|
1120
1120
|
</details>
|
|
1121
1121
|
|
|
1122
1122
|
```grain
|
|
1123
|
-
toAsciiLowercase
|
|
1123
|
+
toAsciiLowercase: (string: String) => String
|
|
1124
1124
|
```
|
|
1125
1125
|
|
|
1126
1126
|
Converts all ASCII uppercase characters in the string to lowercase.
|
|
@@ -1151,7 +1151,7 @@ No other changes yet.
|
|
|
1151
1151
|
</details>
|
|
1152
1152
|
|
|
1153
1153
|
```grain
|
|
1154
|
-
toAsciiUppercase
|
|
1154
|
+
toAsciiUppercase: (string: String) => String
|
|
1155
1155
|
```
|
|
1156
1156
|
|
|
1157
1157
|
Converts all ASCII lowercase characters in the string to uppercase.
|
|
@@ -1174,3 +1174,46 @@ Examples:
|
|
|
1174
1174
|
assert String.toAsciiUppercase("aBc123") == "ABC123"
|
|
1175
1175
|
```
|
|
1176
1176
|
|
|
1177
|
+
### String.**repeat**
|
|
1178
|
+
|
|
1179
|
+
<details disabled>
|
|
1180
|
+
<summary tabindex="-1">Added in <code>0.6.7</code></summary>
|
|
1181
|
+
No other changes yet.
|
|
1182
|
+
</details>
|
|
1183
|
+
|
|
1184
|
+
```grain
|
|
1185
|
+
repeat: (count: Number, string: String) => String
|
|
1186
|
+
```
|
|
1187
|
+
|
|
1188
|
+
Produces a new string by repeating a substring a given number of times.
|
|
1189
|
+
|
|
1190
|
+
Parameters:
|
|
1191
|
+
|
|
1192
|
+
|param|type|description|
|
|
1193
|
+
|-----|----|-----------|
|
|
1194
|
+
|`count`|`Number`|The number of times to repeat the string|
|
|
1195
|
+
|`string`|`String`|The string to repeat|
|
|
1196
|
+
|
|
1197
|
+
Returns:
|
|
1198
|
+
|
|
1199
|
+
|type|description|
|
|
1200
|
+
|----|-----------|
|
|
1201
|
+
|`String`|A string containing the repeated input string|
|
|
1202
|
+
|
|
1203
|
+
Throws:
|
|
1204
|
+
|
|
1205
|
+
`InvalidArgument(String)`
|
|
1206
|
+
|
|
1207
|
+
* When the `count` is not an integer
|
|
1208
|
+
* When the `count` is negative
|
|
1209
|
+
|
|
1210
|
+
Examples:
|
|
1211
|
+
|
|
1212
|
+
```grain
|
|
1213
|
+
assert String.repeat(5, "=") == "====="
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
```grain
|
|
1217
|
+
assert String.repeat(0, ".") == ""
|
|
1218
|
+
```
|
|
1219
|
+
|
package/uint16.gr
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Utilities for working with the Uint16 type.
|
|
3
3
|
* @example from "uint16" include Uint16
|
|
4
4
|
*
|
|
5
|
+
* @example 1uS
|
|
6
|
+
* @example 10uS
|
|
7
|
+
*
|
|
5
8
|
* @since v0.6.0
|
|
6
9
|
*/
|
|
7
10
|
module Uint16
|
|
@@ -33,6 +36,9 @@ provide { fromNumber, toNumber }
|
|
|
33
36
|
* @param number: The value to convert
|
|
34
37
|
* @returns The Int16 represented as a Uint16
|
|
35
38
|
*
|
|
39
|
+
* @example Uint16.fromInt16(1uS) == 1uS
|
|
40
|
+
* @example Uint16.fromInt16(-1uS) == 65535uS
|
|
41
|
+
*
|
|
36
42
|
* @since v0.6.0
|
|
37
43
|
*/
|
|
38
44
|
@unsafe
|
|
@@ -49,6 +55,8 @@ provide let fromInt16 = (number: Int16) => {
|
|
|
49
55
|
* @param value: The value to increment
|
|
50
56
|
* @returns The incremented value
|
|
51
57
|
*
|
|
58
|
+
* @example Uint16.incr(1uS) == 2uS
|
|
59
|
+
*
|
|
52
60
|
* @since v0.6.0
|
|
53
61
|
*/
|
|
54
62
|
@unsafe
|
|
@@ -65,6 +73,9 @@ provide let incr = (value: Uint16) => {
|
|
|
65
73
|
* @param value: The value to decrement
|
|
66
74
|
* @returns The decremented value
|
|
67
75
|
*
|
|
76
|
+
* @example Uint16.decr(1uS) == 0uS
|
|
77
|
+
* @example Uint16.decr(0uS) == 65535uS
|
|
78
|
+
*
|
|
68
79
|
* @since v0.6.0
|
|
69
80
|
*/
|
|
70
81
|
@unsafe
|
|
@@ -82,6 +93,10 @@ provide let decr = (value: Uint16) => {
|
|
|
82
93
|
* @param y: The second operand
|
|
83
94
|
* @returns The sum of the two operands
|
|
84
95
|
*
|
|
96
|
+
* @example
|
|
97
|
+
* use Uint16.{ (+) }
|
|
98
|
+
* assert 1uS + 1uS == 2uS
|
|
99
|
+
*
|
|
85
100
|
* @since v0.6.0
|
|
86
101
|
*/
|
|
87
102
|
@unsafe
|
|
@@ -103,6 +118,10 @@ provide let (+) = (x: Uint16, y: Uint16) => {
|
|
|
103
118
|
* @param y: The second operand
|
|
104
119
|
* @returns The difference of the two operands
|
|
105
120
|
*
|
|
121
|
+
* @example
|
|
122
|
+
* use Uint16.{ (-) }
|
|
123
|
+
* assert 2uS - 1uS == 1uS
|
|
124
|
+
*
|
|
106
125
|
* @since v0.6.0
|
|
107
126
|
*/
|
|
108
127
|
@unsafe
|
|
@@ -121,6 +140,10 @@ provide let (-) = (x: Uint16, y: Uint16) => {
|
|
|
121
140
|
* @param y: The second operand
|
|
122
141
|
* @returns The product of the two operands
|
|
123
142
|
*
|
|
143
|
+
* @example
|
|
144
|
+
* use Uint16.{ (*) }
|
|
145
|
+
* assert 2uS * 2uS == 4uS
|
|
146
|
+
*
|
|
124
147
|
* @since v0.6.0
|
|
125
148
|
*/
|
|
126
149
|
@unsafe
|
|
@@ -138,6 +161,10 @@ provide let (*) = (x: Uint16, y: Uint16) => {
|
|
|
138
161
|
* @param y: The second operand
|
|
139
162
|
* @returns The quotient of its operands
|
|
140
163
|
*
|
|
164
|
+
* @example
|
|
165
|
+
* use Uint16.{ (/) }
|
|
166
|
+
* assert 5uS / 2uS == 2uS
|
|
167
|
+
*
|
|
141
168
|
* @since v0.6.0
|
|
142
169
|
*/
|
|
143
170
|
@unsafe
|
|
@@ -155,6 +182,8 @@ provide let (/) = (x: Uint16, y: Uint16) => {
|
|
|
155
182
|
* @param y: The second operand
|
|
156
183
|
* @returns The remainder of its operands
|
|
157
184
|
*
|
|
185
|
+
* @example Uint16.rem(5uS, 2uS) == 1uS
|
|
186
|
+
*
|
|
158
187
|
* @since v0.6.0
|
|
159
188
|
*/
|
|
160
189
|
@unsafe
|
|
@@ -172,6 +201,10 @@ provide let rem = (x: Uint16, y: Uint16) => {
|
|
|
172
201
|
* @param amount: The number of bits to shift by
|
|
173
202
|
* @returns The shifted value
|
|
174
203
|
*
|
|
204
|
+
* @example
|
|
205
|
+
* use Uint16.{ (<<) }
|
|
206
|
+
* assert (5uS << 1uS) == 10uS
|
|
207
|
+
*
|
|
175
208
|
* @since v0.6.0
|
|
176
209
|
*/
|
|
177
210
|
@unsafe
|
|
@@ -191,6 +224,10 @@ provide let (<<) = (value: Uint16, amount: Uint16) => {
|
|
|
191
224
|
* @param amount: The amount to shift by
|
|
192
225
|
* @returns The shifted value
|
|
193
226
|
*
|
|
227
|
+
* @example
|
|
228
|
+
* use Uint16.{ (>>>) }
|
|
229
|
+
* assert (5uS >>> 1uS) == 2uS
|
|
230
|
+
*
|
|
194
231
|
* @since v0.6.0
|
|
195
232
|
*/
|
|
196
233
|
@unsafe
|
|
@@ -210,6 +247,10 @@ provide let (>>>) = (value: Uint16, amount: Uint16) => {
|
|
|
210
247
|
* @param y: The second value
|
|
211
248
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
212
249
|
*
|
|
250
|
+
* @example
|
|
251
|
+
* use Uint16.{ (==) }
|
|
252
|
+
* assert 1uS == 1uS
|
|
253
|
+
*
|
|
213
254
|
* @since v0.6.0
|
|
214
255
|
*/
|
|
215
256
|
@unsafe
|
|
@@ -226,6 +267,10 @@ provide let (==) = (x: Uint16, y: Uint16) => {
|
|
|
226
267
|
* @param y: The second value
|
|
227
268
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
228
269
|
*
|
|
270
|
+
* @example
|
|
271
|
+
* use Uint16.{ (!=) }
|
|
272
|
+
* assert 1uS != 3uS
|
|
273
|
+
*
|
|
229
274
|
* @since v0.6.0
|
|
230
275
|
*/
|
|
231
276
|
@unsafe
|
|
@@ -242,6 +287,10 @@ provide let (!=) = (x: Uint16, y: Uint16) => {
|
|
|
242
287
|
* @param y: The second value
|
|
243
288
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
244
289
|
*
|
|
290
|
+
* @example
|
|
291
|
+
* use Uint16.{ (<) }
|
|
292
|
+
* assert 1uS < 5uS
|
|
293
|
+
*
|
|
245
294
|
* @since v0.6.0
|
|
246
295
|
*/
|
|
247
296
|
@unsafe
|
|
@@ -258,6 +307,10 @@ provide let (<) = (x: Uint16, y: Uint16) => {
|
|
|
258
307
|
* @param y: The second value
|
|
259
308
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
260
309
|
*
|
|
310
|
+
* @example
|
|
311
|
+
* use Uint16.{ (>) }
|
|
312
|
+
* assert 4uS > 2uS
|
|
313
|
+
*
|
|
261
314
|
* @since v0.6.0
|
|
262
315
|
*/
|
|
263
316
|
@unsafe
|
|
@@ -274,6 +327,13 @@ provide let (>) = (x: Uint16, y: Uint16) => {
|
|
|
274
327
|
* @param y: The second value
|
|
275
328
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
276
329
|
*
|
|
330
|
+
* @example
|
|
331
|
+
* use Uint16.{ (<=) }
|
|
332
|
+
* assert 1uS <= 2uS
|
|
333
|
+
* @example
|
|
334
|
+
* use Uint16.{ (<=) }
|
|
335
|
+
* assert 1uS <= 1uS
|
|
336
|
+
*
|
|
277
337
|
* @since v0.6.0
|
|
278
338
|
*/
|
|
279
339
|
@unsafe
|
|
@@ -290,6 +350,13 @@ provide let (<=) = (x: Uint16, y: Uint16) => {
|
|
|
290
350
|
* @param y: The second value
|
|
291
351
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
292
352
|
*
|
|
353
|
+
* @example
|
|
354
|
+
* use Uint16.{ (>=) }
|
|
355
|
+
* assert 3uS >= 2uS
|
|
356
|
+
* @example
|
|
357
|
+
* use Uint16.{ (>=) }
|
|
358
|
+
* assert 1uS >= 1uS
|
|
359
|
+
*
|
|
293
360
|
* @since v0.6.0
|
|
294
361
|
*/
|
|
295
362
|
@unsafe
|
|
@@ -305,6 +372,8 @@ provide let (>=) = (x: Uint16, y: Uint16) => {
|
|
|
305
372
|
* @param value: The given value
|
|
306
373
|
* @returns Containing the inverted bits of the given value
|
|
307
374
|
*
|
|
375
|
+
* @example Uint16.lnot(5uS) == 65530uS
|
|
376
|
+
*
|
|
308
377
|
* @since v0.6.0
|
|
309
378
|
*/
|
|
310
379
|
@unsafe
|
|
@@ -320,6 +389,10 @@ provide let lnot = (value: Uint16) => {
|
|
|
320
389
|
* @param y: The second operand
|
|
321
390
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
322
391
|
*
|
|
392
|
+
* @example
|
|
393
|
+
* use Uint16.{ (&) }
|
|
394
|
+
* assert (3uS & 4uS) == 0uS
|
|
395
|
+
*
|
|
323
396
|
* @since v0.6.0
|
|
324
397
|
*/
|
|
325
398
|
@unsafe
|
|
@@ -338,6 +411,10 @@ provide let (&) = (x: Uint16, y: Uint16) => {
|
|
|
338
411
|
* @param y: The second operand
|
|
339
412
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
340
413
|
*
|
|
414
|
+
* @example
|
|
415
|
+
* use Uint16.{ (|) }
|
|
416
|
+
* assert (3uS | 4uS) == 7uS
|
|
417
|
+
*
|
|
341
418
|
* @since v0.6.0
|
|
342
419
|
*/
|
|
343
420
|
@unsafe
|
|
@@ -356,6 +433,10 @@ provide let (|) = (x: Uint16, y: Uint16) => {
|
|
|
356
433
|
* @param y: The second operand
|
|
357
434
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
358
435
|
*
|
|
436
|
+
* @example
|
|
437
|
+
* use Uint16.{ (^) }
|
|
438
|
+
* assert (3uS ^ 5uS) == 6uS
|
|
439
|
+
*
|
|
359
440
|
* @since v0.6.0
|
|
360
441
|
*/
|
|
361
442
|
@unsafe
|