@grain/stdlib 0.6.4 → 0.6.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.
package/string.md CHANGED
@@ -911,6 +911,114 @@ Examples:
911
911
  String.forEachCodePointi((codepoint, index) => print((codepoint, index)), "Hello world")
912
912
  ```
913
913
 
914
+ ### String.**forEachChar**
915
+
916
+ <details disabled>
917
+ <summary tabindex="-1">Added in <code>0.6.5</code></summary>
918
+ No other changes yet.
919
+ </details>
920
+
921
+ ```grain
922
+ forEachChar : (fn: (Char => Void), str: String) => Void
923
+ ```
924
+
925
+ Iterates over Unicode characters in a string.
926
+
927
+ Parameters:
928
+
929
+ |param|type|description|
930
+ |-----|----|-----------|
931
+ |`fn`|`Char => Void`|The iterator function|
932
+ |`str`|`String`|The string to iterate|
933
+
934
+ Examples:
935
+
936
+ ```grain
937
+ String.forEachChar(print, "Hello world")
938
+ ```
939
+
940
+ ### String.**forEachChari**
941
+
942
+ <details disabled>
943
+ <summary tabindex="-1">Added in <code>0.6.5</code></summary>
944
+ No other changes yet.
945
+ </details>
946
+
947
+ ```grain
948
+ forEachChari : (fn: ((Char, Number) => Void), str: String) => Void
949
+ ```
950
+
951
+ Iterates over Unicode characters in a string. This is the same as
952
+ `forEachChar`, but provides the characters's index in the string
953
+ as the second argument to the iterator function.
954
+
955
+ Parameters:
956
+
957
+ |param|type|description|
958
+ |-----|----|-----------|
959
+ |`fn`|`(Char, Number) => Void`|The iterator function|
960
+ |`str`|`String`|The string to iterate|
961
+
962
+ Examples:
963
+
964
+ ```grain
965
+ String.forEachChari((char, index) => print((char, index)), "Hello world")
966
+ ```
967
+
968
+ ### String.**map**
969
+
970
+ <details disabled>
971
+ <summary tabindex="-1">Added in <code>0.6.5</code></summary>
972
+ No other changes yet.
973
+ </details>
974
+
975
+ ```grain
976
+ map : (fn: (Char => Char), str: String) => String
977
+ ```
978
+
979
+ Builds a new string by mapping Unicode characters.
980
+
981
+ Parameters:
982
+
983
+ |param|type|description|
984
+ |-----|----|-----------|
985
+ |`fn`|`Char => Char`|The mapping function|
986
+ |`str`|`String`|The string to map|
987
+
988
+ Examples:
989
+
990
+ ```grain
991
+ assert String.map((c) => 'a', "Hello world") == "aaaaaaaaaaa"
992
+ ```
993
+
994
+ ### String.**mapi**
995
+
996
+ <details disabled>
997
+ <summary tabindex="-1">Added in <code>0.6.5</code></summary>
998
+ No other changes yet.
999
+ </details>
1000
+
1001
+ ```grain
1002
+ mapi : (fn: ((Char, Number) => Char), str: String) => String
1003
+ ```
1004
+
1005
+ Builds a new string by mapping Unicode characters. This is the same as
1006
+ `mapChar`, but provides the characters's index in the string
1007
+ as the second argument to the mapping function.
1008
+
1009
+ Parameters:
1010
+
1011
+ |param|type|description|
1012
+ |-----|----|-----------|
1013
+ |`fn`|`(Char, Number) => Char`|The mapping function|
1014
+ |`str`|`String`|The string to map|
1015
+
1016
+ Examples:
1017
+
1018
+ ```grain
1019
+ assert String.mapi((char, index) => String.charAt(0, toString(index)), "Hello world") == "01234567891"
1020
+ ```
1021
+
914
1022
  ### String.**trimStart**
915
1023
 
916
1024
  <details disabled>
package/wasi/file.gr CHANGED
@@ -760,6 +760,8 @@ provide let fdWrite = (fd: FileDescriptor, data: Bytes) => {
760
760
  return Err(Wasi.SystemError(tagSimpleNumber(err)))
761
761
  }
762
762
 
763
+ ignore(data)
764
+
763
765
  nwritten = WasmI32.load(nwritten, 0n)
764
766
  Memory.free(iovs)
765
767
  return Ok(tagSimpleNumber(nwritten))
@@ -797,6 +799,9 @@ provide let fdPwrite = (fd: FileDescriptor, data: Bytes, offset: Int64) => {
797
799
  return Err(Wasi.SystemError(tagSimpleNumber(err)))
798
800
  }
799
801
 
802
+ ignore(data)
803
+ ignore(offset)
804
+
800
805
  nwritten = WasmI32.load(nwritten, 0n)
801
806
  Memory.free(iovs)
802
807
  return Ok(tagSimpleNumber(nwritten))