create-mendix-widget-gleam 2.0.14 → 2.0.16

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 (203) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -1
  3. package/src/index.mjs +32 -12
  4. package/template/gleam.toml +1 -1
  5. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache +0 -0
  6. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache_inline +0 -0
  7. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@command.cache_meta +0 -0
  8. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache +0 -0
  9. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache_inline +0 -0
  10. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@cursor.cache_meta +0 -0
  11. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache +0 -0
  12. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache_inline +0 -0
  13. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@event.cache_meta +0 -0
  14. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache +0 -0
  15. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache_inline +0 -0
  16. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@internal@consts.cache_meta +0 -0
  17. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache +0 -0
  18. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache_inline +0 -0
  19. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@stdout.cache_meta +0 -0
  20. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache +0 -0
  21. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache_inline +0 -0
  22. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@style.cache_meta +0 -0
  23. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache +0 -0
  24. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache_inline +0 -0
  25. package/tui/build/dev/javascript/etch/_gleam_artefacts/etch@terminal.cache_meta +0 -0
  26. package/tui/build/dev/javascript/etch/etch/command.mjs +479 -0
  27. package/tui/build/dev/javascript/etch/etch/cursor.mjs +164 -0
  28. package/tui/build/dev/javascript/etch/etch/event.mjs +2399 -0
  29. package/tui/build/dev/javascript/etch/etch/internal/consts.mjs +3 -0
  30. package/tui/build/dev/javascript/etch/etch/stdout.mjs +375 -0
  31. package/tui/build/dev/javascript/etch/etch/style.mjs +741 -0
  32. package/tui/build/dev/javascript/etch/etch/terminal.mjs +137 -0
  33. package/tui/build/dev/javascript/etch/gleam.mjs +1 -0
  34. package/tui/build/dev/javascript/etch/input/event_ffi.erl +73 -0
  35. package/tui/build/dev/javascript/etch/input/input_ffi.mjs +192 -0
  36. package/tui/build/dev/javascript/etch/input/signal_handler.erl +33 -0
  37. package/tui/build/dev/javascript/etch/terminal/terminal_ffi.erl +22 -0
  38. package/tui/build/dev/javascript/etch/terminal/terminal_ffi.mjs +37 -0
  39. package/tui/build/dev/javascript/etch/terminal/tty_state.erl +29 -0
  40. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache +0 -0
  41. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache_inline +0 -0
  42. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@application.cache_meta +0 -0
  43. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache +0 -0
  44. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache_inline +0 -0
  45. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@atom.cache_meta +0 -0
  46. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache +0 -0
  47. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache_inline +0 -0
  48. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@charlist.cache_meta +0 -0
  49. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache +0 -0
  50. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache_inline +0 -0
  51. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@node.cache_meta +0 -0
  52. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache +0 -0
  53. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache_inline +0 -0
  54. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@port.cache_meta +0 -0
  55. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache +0 -0
  56. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache_inline +0 -0
  57. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@process.cache_meta +0 -0
  58. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache +0 -0
  59. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache_inline +0 -0
  60. package/tui/build/dev/javascript/gleam_erlang/_gleam_artefacts/gleam@erlang@reference.cache_meta +0 -0
  61. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/application.mjs +38 -0
  62. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/atom.mjs +2 -0
  63. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/charlist.mjs +1 -0
  64. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/node.mjs +12 -0
  65. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/port.mjs +1 -0
  66. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/process.mjs +161 -0
  67. package/tui/build/dev/javascript/gleam_erlang/gleam/erlang/reference.mjs +1 -0
  68. package/tui/build/dev/javascript/gleam_erlang/gleam.mjs +1 -0
  69. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@application.erl +43 -0
  70. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@atom.erl +94 -0
  71. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@charlist.erl +42 -0
  72. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@node.erl +80 -0
  73. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@port.erl +8 -0
  74. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@process.erl +868 -0
  75. package/tui/build/dev/javascript/gleam_erlang/gleam@erlang@reference.erl +21 -0
  76. package/tui/build/dev/javascript/gleam_erlang/gleam_erlang_ffi.erl +164 -0
  77. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache +0 -0
  78. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache_inline +0 -0
  79. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@array.cache_meta +0 -0
  80. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache +0 -0
  81. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache_inline +0 -0
  82. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@promise.cache_meta +0 -0
  83. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache +0 -0
  84. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache_inline +0 -0
  85. package/tui/build/dev/javascript/gleam_javascript/_gleam_artefacts/gleam@javascript@symbol.cache_meta +0 -0
  86. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/array.mjs +24 -0
  87. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/promise.mjs +105 -0
  88. package/tui/build/dev/javascript/gleam_javascript/gleam/javascript/symbol.mjs +7 -0
  89. package/tui/build/dev/javascript/gleam_javascript/gleam.mjs +1 -0
  90. package/tui/build/dev/javascript/gleam_javascript/gleam_javascript_ffi.mjs +133 -0
  91. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache +0 -0
  92. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_inline +0 -0
  93. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bit_array.cache_meta +0 -0
  94. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache +0 -0
  95. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_inline +0 -0
  96. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bool.cache_meta +0 -0
  97. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache +0 -0
  98. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_inline +0 -0
  99. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@bytes_tree.cache_meta +0 -0
  100. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache +0 -0
  101. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_inline +0 -0
  102. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dict.cache_meta +0 -0
  103. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache +0 -0
  104. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_inline +0 -0
  105. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic.cache_meta +0 -0
  106. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache +0 -0
  107. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_inline +0 -0
  108. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@dynamic@decode.cache_meta +0 -0
  109. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache +0 -0
  110. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_inline +0 -0
  111. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@float.cache_meta +0 -0
  112. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache +0 -0
  113. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_inline +0 -0
  114. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@function.cache_meta +0 -0
  115. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache +0 -0
  116. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_inline +0 -0
  117. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@int.cache_meta +0 -0
  118. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache +0 -0
  119. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_inline +0 -0
  120. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@io.cache_meta +0 -0
  121. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache +0 -0
  122. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_inline +0 -0
  123. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@list.cache_meta +0 -0
  124. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache +0 -0
  125. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_inline +0 -0
  126. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@option.cache_meta +0 -0
  127. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache +0 -0
  128. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_inline +0 -0
  129. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@order.cache_meta +0 -0
  130. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache +0 -0
  131. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_inline +0 -0
  132. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@pair.cache_meta +0 -0
  133. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache +0 -0
  134. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_inline +0 -0
  135. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@result.cache_meta +0 -0
  136. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache +0 -0
  137. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_inline +0 -0
  138. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@set.cache_meta +0 -0
  139. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache +0 -0
  140. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_inline +0 -0
  141. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string.cache_meta +0 -0
  142. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache +0 -0
  143. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_inline +0 -0
  144. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@string_tree.cache_meta +0 -0
  145. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache +0 -0
  146. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_inline +0 -0
  147. package/tui/build/dev/javascript/gleam_stdlib/_gleam_artefacts/gleam@uri.cache_meta +0 -0
  148. package/tui/build/dev/javascript/gleam_stdlib/dict.mjs +710 -0
  149. package/tui/build/dev/javascript/gleam_stdlib/gleam/bit_array.mjs +286 -0
  150. package/tui/build/dev/javascript/gleam_stdlib/gleam/bool.mjs +295 -0
  151. package/tui/build/dev/javascript/gleam_stdlib/gleam/bytes_tree.mjs +225 -0
  152. package/tui/build/dev/javascript/gleam_stdlib/gleam/dict.mjs +455 -0
  153. package/tui/build/dev/javascript/gleam_stdlib/gleam/dynamic/decode.mjs +993 -0
  154. package/tui/build/dev/javascript/gleam_stdlib/gleam/dynamic.mjs +35 -0
  155. package/tui/build/dev/javascript/gleam_stdlib/gleam/float.mjs +528 -0
  156. package/tui/build/dev/javascript/gleam_stdlib/gleam/function.mjs +6 -0
  157. package/tui/build/dev/javascript/gleam_stdlib/gleam/int.mjs +764 -0
  158. package/tui/build/dev/javascript/gleam_stdlib/gleam/io.mjs +8 -0
  159. package/tui/build/dev/javascript/gleam_stdlib/gleam/list.mjs +3063 -0
  160. package/tui/build/dev/javascript/gleam_stdlib/gleam/option.mjs +386 -0
  161. package/tui/build/dev/javascript/gleam_stdlib/gleam/order.mjs +166 -0
  162. package/tui/build/dev/javascript/gleam_stdlib/gleam/pair.mjs +96 -0
  163. package/tui/build/dev/javascript/gleam_stdlib/gleam/result.mjs +448 -0
  164. package/tui/build/dev/javascript/gleam_stdlib/gleam/set.mjs +413 -0
  165. package/tui/build/dev/javascript/gleam_stdlib/gleam/string.mjs +695 -0
  166. package/tui/build/dev/javascript/gleam_stdlib/gleam/string_tree.mjs +128 -0
  167. package/tui/build/dev/javascript/gleam_stdlib/gleam/uri.mjs +1151 -0
  168. package/tui/build/dev/javascript/gleam_stdlib/gleam.mjs +1 -0
  169. package/tui/build/dev/javascript/gleam_stdlib/gleam@bit_array.erl +347 -0
  170. package/tui/build/dev/javascript/gleam_stdlib/gleam@bool.erl +334 -0
  171. package/tui/build/dev/javascript/gleam_stdlib/gleam@bytes_tree.erl +211 -0
  172. package/tui/build/dev/javascript/gleam_stdlib/gleam@dict.erl +513 -0
  173. package/tui/build/dev/javascript/gleam_stdlib/gleam@dynamic.erl +105 -0
  174. package/tui/build/dev/javascript/gleam_stdlib/gleam@dynamic@decode.erl +1114 -0
  175. package/tui/build/dev/javascript/gleam_stdlib/gleam@float.erl +711 -0
  176. package/tui/build/dev/javascript/gleam_stdlib/gleam@function.erl +18 -0
  177. package/tui/build/dev/javascript/gleam_stdlib/gleam@int.erl +972 -0
  178. package/tui/build/dev/javascript/gleam_stdlib/gleam@io.erl +76 -0
  179. package/tui/build/dev/javascript/gleam_stdlib/gleam@list.erl +2735 -0
  180. package/tui/build/dev/javascript/gleam_stdlib/gleam@option.erl +381 -0
  181. package/tui/build/dev/javascript/gleam_stdlib/gleam@order.erl +188 -0
  182. package/tui/build/dev/javascript/gleam_stdlib/gleam@pair.erl +104 -0
  183. package/tui/build/dev/javascript/gleam_stdlib/gleam@result.erl +500 -0
  184. package/tui/build/dev/javascript/gleam_stdlib/gleam@set.erl +430 -0
  185. package/tui/build/dev/javascript/gleam_stdlib/gleam@string.erl +964 -0
  186. package/tui/build/dev/javascript/gleam_stdlib/gleam@string_tree.erl +202 -0
  187. package/tui/build/dev/javascript/gleam_stdlib/gleam@uri.erl +1042 -0
  188. package/tui/build/dev/javascript/gleam_stdlib/gleam_stdlib.erl +534 -0
  189. package/tui/build/dev/javascript/gleam_stdlib/gleam_stdlib.mjs +1133 -0
  190. package/tui/build/dev/javascript/gleam_version +1 -0
  191. package/tui/build/dev/javascript/prelude.mjs +1575 -0
  192. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache +0 -0
  193. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_inline +0 -0
  194. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_meta +0 -0
  195. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui.cache_warnings +0 -0
  196. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache +0 -0
  197. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_inline +0 -0
  198. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_meta +0 -0
  199. package/tui/build/dev/javascript/tui/_gleam_artefacts/tui@prompt.cache_warnings +0 -0
  200. package/tui/build/dev/javascript/tui/gleam.mjs +1 -0
  201. package/tui/build/dev/javascript/tui/tui/prompt.mjs +521 -0
  202. package/tui/build/dev/javascript/tui/tui.mjs +334 -0
  203. package/tui/build/dev/javascript/tui/tui_ffi.mjs +32 -0
@@ -0,0 +1,695 @@
1
+ import {
2
+ Ok,
3
+ Error,
4
+ Empty as $Empty,
5
+ prepend as listPrepend,
6
+ CustomType as $CustomType,
7
+ remainderInt,
8
+ divideInt,
9
+ } from "../gleam.mjs";
10
+ import * as $list from "../gleam/list.mjs";
11
+ import * as $option from "../gleam/option.mjs";
12
+ import { None, Some } from "../gleam/option.mjs";
13
+ import * as $order from "../gleam/order.mjs";
14
+ import * as $string_tree from "../gleam/string_tree.mjs";
15
+ import {
16
+ string_length as length,
17
+ lowercase,
18
+ uppercase,
19
+ less_than,
20
+ string_grapheme_slice as grapheme_slice,
21
+ string_byte_slice as unsafe_byte_slice,
22
+ crop_string as crop,
23
+ contains_string as contains,
24
+ starts_with,
25
+ ends_with,
26
+ split_once,
27
+ trim_start,
28
+ trim_end,
29
+ pop_grapheme,
30
+ graphemes as to_graphemes,
31
+ codepoint as unsafe_int_to_utf_codepoint,
32
+ string_to_codepoint_integer_list,
33
+ utf_codepoint_list_to_string as from_utf_codepoints,
34
+ utf_codepoint_to_int,
35
+ inspect as do_inspect,
36
+ byte_size,
37
+ } from "../gleam_stdlib.mjs";
38
+
39
+ export {
40
+ byte_size,
41
+ contains,
42
+ crop,
43
+ ends_with,
44
+ from_utf_codepoints,
45
+ length,
46
+ lowercase,
47
+ pop_grapheme,
48
+ split_once,
49
+ starts_with,
50
+ to_graphemes,
51
+ trim_end,
52
+ trim_start,
53
+ uppercase,
54
+ utf_codepoint_to_int,
55
+ };
56
+
57
+ class Leading extends $CustomType {}
58
+
59
+ class Trailing extends $CustomType {}
60
+
61
+ /**
62
+ * Determines if a `String` is empty.
63
+ *
64
+ * ## Examples
65
+ *
66
+ * ```gleam
67
+ * assert is_empty("")
68
+ * ```
69
+ *
70
+ * ```gleam
71
+ * assert !is_empty("the world")
72
+ * ```
73
+ */
74
+ export function is_empty(str) {
75
+ return str === "";
76
+ }
77
+
78
+ /**
79
+ * Reverses a `String`.
80
+ *
81
+ * This function has to iterate across the whole `String` so it runs in linear
82
+ * time. Avoid using this in a loop.
83
+ *
84
+ * ## Examples
85
+ *
86
+ * ```gleam
87
+ * assert reverse("stressed") == "desserts"
88
+ * ```
89
+ */
90
+ export function reverse(string) {
91
+ let _pipe = string;
92
+ let _pipe$1 = $string_tree.from_string(_pipe);
93
+ let _pipe$2 = $string_tree.reverse(_pipe$1);
94
+ return $string_tree.to_string(_pipe$2);
95
+ }
96
+
97
+ /**
98
+ * Creates a new `String` by replacing all occurrences of a given substring.
99
+ *
100
+ * ## Examples
101
+ *
102
+ * ```gleam
103
+ * assert replace("www.example.com", each: ".", with: "-") == "www-example-com"
104
+ * ```
105
+ *
106
+ * ```gleam
107
+ * assert replace("a,b,c,d,e", each: ",", with: "/") == "a/b/c/d/e"
108
+ * ```
109
+ */
110
+ export function replace(string, pattern, substitute) {
111
+ let _pipe = string;
112
+ let _pipe$1 = $string_tree.from_string(_pipe);
113
+ let _pipe$2 = $string_tree.replace(_pipe$1, pattern, substitute);
114
+ return $string_tree.to_string(_pipe$2);
115
+ }
116
+
117
+ /**
118
+ * Compares two `String`s to see which is "larger" by comparing their graphemes.
119
+ *
120
+ * This does not compare the size or length of the given `String`s.
121
+ *
122
+ * ## Examples
123
+ *
124
+ * ```gleam
125
+ * import gleam/order
126
+ *
127
+ * assert compare("Anthony", "Anthony") == order.Eq
128
+ * ```
129
+ *
130
+ * ```gleam
131
+ * import gleam/order
132
+ *
133
+ * assert compare("A", "B") == order.Lt
134
+ * ```
135
+ */
136
+ export function compare(a, b) {
137
+ let $ = a === b;
138
+ if ($) {
139
+ return new $order.Eq();
140
+ } else {
141
+ let $1 = less_than(a, b);
142
+ if ($1) {
143
+ return new $order.Lt();
144
+ } else {
145
+ return new $order.Gt();
146
+ }
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Takes a substring given a start grapheme index and a length. Negative indexes
152
+ * are taken starting from the *end* of the string.
153
+ *
154
+ * This function runs in linear time with the size of the index and the
155
+ * length. Negative indexes are linear with the size of the input string in
156
+ * addition to the other costs.
157
+ *
158
+ * ## Examples
159
+ *
160
+ * ```gleam
161
+ * assert slice(from: "gleam", at_index: 1, length: 2) == "le"
162
+ * ```
163
+ *
164
+ * ```gleam
165
+ * assert slice(from: "gleam", at_index: 1, length: 10) == "leam"
166
+ * ```
167
+ *
168
+ * ```gleam
169
+ * assert slice(from: "gleam", at_index: 10, length: 3) == ""
170
+ * ```
171
+ *
172
+ * ```gleam
173
+ * assert slice(from: "gleam", at_index: -2, length: 2) == "am"
174
+ * ```
175
+ *
176
+ * ```gleam
177
+ * assert slice(from: "gleam", at_index: -12, length: 2) == ""
178
+ * ```
179
+ */
180
+ export function slice(string, idx, len) {
181
+ let $ = len <= 0;
182
+ if ($) {
183
+ return "";
184
+ } else {
185
+ let $1 = idx < 0;
186
+ if ($1) {
187
+ let translated_idx = length(string) + idx;
188
+ let $2 = translated_idx < 0;
189
+ if ($2) {
190
+ return "";
191
+ } else {
192
+ return grapheme_slice(string, translated_idx, len);
193
+ }
194
+ } else {
195
+ return grapheme_slice(string, idx, len);
196
+ }
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Drops *n* graphemes from the end of a `String`.
202
+ *
203
+ * This function traverses the full string, so it runs in linear time with the
204
+ * size of the string. Avoid using this in a loop.
205
+ *
206
+ * ## Examples
207
+ *
208
+ * ```gleam
209
+ * assert drop_end(from: "Cigarette Smoking Man", up_to: 2)
210
+ * == "Cigarette Smoking M"
211
+ * ```
212
+ */
213
+ export function drop_end(string, num_graphemes) {
214
+ let $ = num_graphemes <= 0;
215
+ if ($) {
216
+ return string;
217
+ } else {
218
+ return slice(string, 0, length(string) - num_graphemes);
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Creates a new `String` by joining two `String`s together.
224
+ *
225
+ * This function typically copies both `String`s and runs in linear time, but
226
+ * the exact behaviour will depend on how the runtime you are using optimises
227
+ * your code. Benchmark and profile your code if you need to understand its
228
+ * performance better.
229
+ *
230
+ * If you are joining together large string and want to avoid copying any data
231
+ * you may want to investigate using the [`string_tree`](../gleam/string_tree.html)
232
+ * module.
233
+ *
234
+ * ## Examples
235
+ *
236
+ * ```gleam
237
+ * assert append(to: "butter", suffix: "fly") == "butterfly"
238
+ * ```
239
+ */
240
+ export function append(first, second) {
241
+ return first + second;
242
+ }
243
+
244
+ function concat_loop(loop$strings, loop$accumulator) {
245
+ while (true) {
246
+ let strings = loop$strings;
247
+ let accumulator = loop$accumulator;
248
+ if (strings instanceof $Empty) {
249
+ return accumulator;
250
+ } else {
251
+ let string = strings.head;
252
+ let strings$1 = strings.tail;
253
+ loop$strings = strings$1;
254
+ loop$accumulator = accumulator + string;
255
+ }
256
+ }
257
+ }
258
+
259
+ /**
260
+ * Creates a new `String` by joining many `String`s together.
261
+ *
262
+ * This function copies all the `String`s and runs in linear time.
263
+ *
264
+ * ## Examples
265
+ *
266
+ * ```gleam
267
+ * assert concat(["never", "the", "less"]) == "nevertheless"
268
+ * ```
269
+ */
270
+ export function concat(strings) {
271
+ return concat_loop(strings, "");
272
+ }
273
+
274
+ function repeat_loop(loop$times, loop$doubling_acc, loop$acc) {
275
+ while (true) {
276
+ let times = loop$times;
277
+ let doubling_acc = loop$doubling_acc;
278
+ let acc = loop$acc;
279
+ let _block;
280
+ let $ = times % 2;
281
+ if ($ === 0) {
282
+ _block = acc;
283
+ } else {
284
+ _block = acc + doubling_acc;
285
+ }
286
+ let acc$1 = _block;
287
+ let times$1 = globalThis.Math.trunc(times / 2);
288
+ let $1 = times$1 <= 0;
289
+ if ($1) {
290
+ return acc$1;
291
+ } else {
292
+ loop$times = times$1;
293
+ loop$doubling_acc = doubling_acc + doubling_acc;
294
+ loop$acc = acc$1;
295
+ }
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Creates a new `String` by repeating a `String` a given number of times.
301
+ *
302
+ * This function runs in loglinear time.
303
+ *
304
+ * ## Examples
305
+ *
306
+ * ```gleam
307
+ * assert repeat("ha", times: 3) == "hahaha"
308
+ * ```
309
+ */
310
+ export function repeat(string, times) {
311
+ let $ = times <= 0;
312
+ if ($) {
313
+ return "";
314
+ } else {
315
+ return repeat_loop(times, string, "");
316
+ }
317
+ }
318
+
319
+ function join_loop(loop$strings, loop$separator, loop$accumulator) {
320
+ while (true) {
321
+ let strings = loop$strings;
322
+ let separator = loop$separator;
323
+ let accumulator = loop$accumulator;
324
+ if (strings instanceof $Empty) {
325
+ return accumulator;
326
+ } else {
327
+ let string = strings.head;
328
+ let strings$1 = strings.tail;
329
+ loop$strings = strings$1;
330
+ loop$separator = separator;
331
+ loop$accumulator = (accumulator + separator) + string;
332
+ }
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Joins many `String`s together with a given separator.
338
+ *
339
+ * This function runs in linear time.
340
+ *
341
+ * ## Examples
342
+ *
343
+ * ```gleam
344
+ * assert join(["home","evan","Desktop"], with: "/") == "home/evan/Desktop"
345
+ * ```
346
+ */
347
+ export function join(strings, separator) {
348
+ if (strings instanceof $Empty) {
349
+ return "";
350
+ } else {
351
+ let first$1 = strings.head;
352
+ let rest = strings.tail;
353
+ return join_loop(rest, separator, first$1);
354
+ }
355
+ }
356
+
357
+ function padding(size, pad_string) {
358
+ let pad_string_length = length(pad_string);
359
+ let num_pads = divideInt(size, pad_string_length);
360
+ let extra = remainderInt(size, pad_string_length);
361
+ return repeat(pad_string, num_pads) + slice(pad_string, 0, extra);
362
+ }
363
+
364
+ /**
365
+ * Pads the start of a `String` until it has a given length.
366
+ *
367
+ * ## Examples
368
+ *
369
+ * ```gleam
370
+ * assert pad_start("121", to: 5, with: ".") == "..121"
371
+ * ```
372
+ *
373
+ * ```gleam
374
+ * assert pad_start("121", to: 3, with: ".") == "121"
375
+ * ```
376
+ *
377
+ * ```gleam
378
+ * assert pad_start("121", to: 2, with: ".") == "121"
379
+ * ```
380
+ */
381
+ export function pad_start(string, desired_length, pad_string) {
382
+ let current_length = length(string);
383
+ let to_pad_length = desired_length - current_length;
384
+ let $ = to_pad_length <= 0;
385
+ if ($) {
386
+ return string;
387
+ } else {
388
+ return padding(to_pad_length, pad_string) + string;
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Pads the end of a `String` until it has a given length.
394
+ *
395
+ * ## Examples
396
+ *
397
+ * ```gleam
398
+ * assert pad_end("123", to: 5, with: ".") == "123.."
399
+ * ```
400
+ *
401
+ * ```gleam
402
+ * assert pad_end("123", to: 3, with: ".") == "123"
403
+ * ```
404
+ *
405
+ * ```gleam
406
+ * assert pad_end("123", to: 2, with: ".") == "123"
407
+ * ```
408
+ */
409
+ export function pad_end(string, desired_length, pad_string) {
410
+ let current_length = length(string);
411
+ let to_pad_length = desired_length - current_length;
412
+ let $ = to_pad_length <= 0;
413
+ if ($) {
414
+ return string;
415
+ } else {
416
+ return string + padding(to_pad_length, pad_string);
417
+ }
418
+ }
419
+
420
+ /**
421
+ * Removes whitespace on both sides of a `String`.
422
+ *
423
+ * Whitespace in this function is the set of nonbreakable whitespace
424
+ * codepoints, defined as Pattern_White_Space in [Unicode Standard Annex #31][1].
425
+ *
426
+ * [1]: https://unicode.org/reports/tr31/
427
+ *
428
+ * ## Examples
429
+ *
430
+ * ```gleam
431
+ * assert trim(" hats \n") == "hats"
432
+ * ```
433
+ */
434
+ export function trim(string) {
435
+ let _pipe = string;
436
+ let _pipe$1 = trim_start(_pipe);
437
+ return trim_end(_pipe$1);
438
+ }
439
+
440
+ function to_graphemes_loop(loop$string, loop$acc) {
441
+ while (true) {
442
+ let string = loop$string;
443
+ let acc = loop$acc;
444
+ let $ = pop_grapheme(string);
445
+ if ($ instanceof Ok) {
446
+ let grapheme = $[0][0];
447
+ let rest = $[0][1];
448
+ loop$string = rest;
449
+ loop$acc = listPrepend(grapheme, acc);
450
+ } else {
451
+ return acc;
452
+ }
453
+ }
454
+ }
455
+
456
+ /**
457
+ * Creates a list of `String`s by splitting a given string on a given substring.
458
+ *
459
+ * ## Examples
460
+ *
461
+ * ```gleam
462
+ * assert split("home/gleam/desktop/", on: "/")
463
+ * == ["home", "gleam", "desktop", ""]
464
+ * ```
465
+ */
466
+ export function split(x, substring) {
467
+ if (substring === "") {
468
+ return to_graphemes(x);
469
+ } else {
470
+ let _pipe = x;
471
+ let _pipe$1 = $string_tree.from_string(_pipe);
472
+ let _pipe$2 = $string_tree.split(_pipe$1, substring);
473
+ return $list.map(_pipe$2, $string_tree.to_string);
474
+ }
475
+ }
476
+
477
+ function do_to_utf_codepoints(string) {
478
+ let _pipe = string;
479
+ let _pipe$1 = string_to_codepoint_integer_list(_pipe);
480
+ return $list.map(_pipe$1, unsafe_int_to_utf_codepoint);
481
+ }
482
+
483
+ /**
484
+ * Converts a `String` to a `List` of `UtfCodepoint`.
485
+ *
486
+ * See <https://en.wikipedia.org/wiki/Code_point> and
487
+ * <https://en.wikipedia.org/wiki/Unicode#Codespace_and_Code_Points> for an
488
+ * explanation on code points.
489
+ *
490
+ * ## Examples
491
+ *
492
+ * ```gleam
493
+ * assert "a" |> to_utf_codepoints == [UtfCodepoint(97)]
494
+ * ```
495
+ *
496
+ * ```gleam
497
+ * // Semantically the same as:
498
+ * // ["🏳", "️", "‍", "🌈"] or:
499
+ * // [waving_white_flag, variant_selector_16, zero_width_joiner, rainbow]
500
+ * assert "🏳️‍🌈" |> to_utf_codepoints
501
+ * == [
502
+ * UtfCodepoint(127987),
503
+ * UtfCodepoint(65039),
504
+ * UtfCodepoint(8205),
505
+ * UtfCodepoint(127752),
506
+ * ]
507
+ * ```
508
+ */
509
+ export function to_utf_codepoints(string) {
510
+ return do_to_utf_codepoints(string);
511
+ }
512
+
513
+ /**
514
+ * Converts an integer to a `UtfCodepoint`.
515
+ *
516
+ * Returns an `Error` if the integer does not represent a valid UTF codepoint.
517
+ */
518
+ export function utf_codepoint(value) {
519
+ let i = value;
520
+ if (i > 1_114_111) {
521
+ return new Error(undefined);
522
+ } else {
523
+ let i = value;
524
+ if ((i >= 55_296) && (i <= 57_343)) {
525
+ return new Error(undefined);
526
+ } else {
527
+ let i = value;
528
+ if (i < 0) {
529
+ return new Error(undefined);
530
+ } else {
531
+ let i = value;
532
+ return new Ok(unsafe_int_to_utf_codepoint(i));
533
+ }
534
+ }
535
+ }
536
+ }
537
+
538
+ /**
539
+ * Converts a `String` into `Option(String)` where an empty `String` becomes
540
+ * `None`.
541
+ *
542
+ * ## Examples
543
+ *
544
+ * ```gleam
545
+ * assert to_option("") == None
546
+ * ```
547
+ *
548
+ * ```gleam
549
+ * assert to_option("hats") == Some("hats")
550
+ * ```
551
+ */
552
+ export function to_option(string) {
553
+ if (string === "") {
554
+ return new None();
555
+ } else {
556
+ return new Some(string);
557
+ }
558
+ }
559
+
560
+ /**
561
+ * Returns the first grapheme cluster in a given `String` and wraps it in a
562
+ * `Result(String, Nil)`. If the `String` is empty, it returns `Error(Nil)`.
563
+ * Otherwise, it returns `Ok(String)`.
564
+ *
565
+ * ## Examples
566
+ *
567
+ * ```gleam
568
+ * assert first("") == Error(Nil)
569
+ * ```
570
+ *
571
+ * ```gleam
572
+ * assert first("icecream") == Ok("i")
573
+ * ```
574
+ */
575
+ export function first(string) {
576
+ let $ = pop_grapheme(string);
577
+ if ($ instanceof Ok) {
578
+ let first$1 = $[0][0];
579
+ return new Ok(first$1);
580
+ } else {
581
+ return $;
582
+ }
583
+ }
584
+
585
+ /**
586
+ * Returns the last grapheme cluster in a given `String` and wraps it in a
587
+ * `Result(String, Nil)`. If the `String` is empty, it returns `Error(Nil)`.
588
+ * Otherwise, it returns `Ok(String)`.
589
+ *
590
+ * This function traverses the full string, so it runs in linear time with the
591
+ * length of the string. Avoid using this in a loop.
592
+ *
593
+ * ## Examples
594
+ *
595
+ * ```gleam
596
+ * assert last("") == Error(Nil)
597
+ * ```
598
+ *
599
+ * ```gleam
600
+ * assert last("icecream") == Ok("m")
601
+ * ```
602
+ */
603
+ export function last(string) {
604
+ let $ = pop_grapheme(string);
605
+ if ($ instanceof Ok) {
606
+ let $1 = $[0][1];
607
+ if ($1 === "") {
608
+ let first$1 = $[0][0];
609
+ return new Ok(first$1);
610
+ } else {
611
+ let rest = $1;
612
+ return new Ok(slice(rest, -1, 1));
613
+ }
614
+ } else {
615
+ return $;
616
+ }
617
+ }
618
+
619
+ /**
620
+ * Creates a new `String` with the first grapheme in the input `String`
621
+ * converted to uppercase and the remaining graphemes to lowercase.
622
+ *
623
+ * ## Examples
624
+ *
625
+ * ```gleam
626
+ * assert capitalise("mamouna") == "Mamouna"
627
+ * ```
628
+ */
629
+ export function capitalise(string) {
630
+ let $ = pop_grapheme(string);
631
+ if ($ instanceof Ok) {
632
+ let first$1 = $[0][0];
633
+ let rest = $[0][1];
634
+ return append(uppercase(first$1), lowercase(rest));
635
+ } else {
636
+ return "";
637
+ }
638
+ }
639
+
640
+ /**
641
+ * Returns a `String` representation of a term in Gleam syntax.
642
+ *
643
+ * This may be occasionally useful for quick-and-dirty printing of values in
644
+ * scripts. For error reporting and other uses prefer constructing strings by
645
+ * pattern matching on the values.
646
+ *
647
+ * ## Limitations
648
+ *
649
+ * The output format of this function is not stable and could change at any
650
+ * time. The output is not suitable for parsing.
651
+ *
652
+ * This function works using runtime reflection, so the output may not be
653
+ * perfectly accurate for data structures where the runtime structure doesn't
654
+ * hold enough information to determine the original syntax. For example,
655
+ * tuples with an Erlang atom in the first position will be mistaken for Gleam
656
+ * records.
657
+ *
658
+ * ## Security and safety
659
+ *
660
+ * There is no limit to how large the strings that this function can produce.
661
+ * Be careful not to call this function with large data structures or you
662
+ * could use very large amounts of memory, potentially causing runtime
663
+ * problems.
664
+ */
665
+ export function inspect(term) {
666
+ let _pipe = term;
667
+ let _pipe$1 = do_inspect(_pipe);
668
+ return $string_tree.to_string(_pipe$1);
669
+ }
670
+
671
+ /**
672
+ * Drops *n* graphemes from the start of a `String`.
673
+ *
674
+ * This function runs in linear time with the number of graphemes to drop.
675
+ *
676
+ * ## Examples
677
+ *
678
+ * ```gleam
679
+ * assert drop_start(from: "The Lone Gunmen", up_to: 2) == "e Lone Gunmen"
680
+ * ```
681
+ */
682
+ export function drop_start(string, num_graphemes) {
683
+ let $ = num_graphemes <= 0;
684
+ if ($) {
685
+ return string;
686
+ } else {
687
+ let prefix = grapheme_slice(string, 0, num_graphemes);
688
+ let prefix_size = byte_size(prefix);
689
+ return unsafe_byte_slice(
690
+ string,
691
+ prefix_size,
692
+ byte_size(string) - prefix_size,
693
+ );
694
+ }
695
+ }