create-mendix-widget-gleam 2.0.14 → 2.0.15

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 +22 -7
  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,286 @@
1
+ import { Ok, toList, bitArraySlice, bitArraySliceToInt } from "../gleam.mjs";
2
+ import * as $int from "../gleam/int.mjs";
3
+ import * as $order from "../gleam/order.mjs";
4
+ import * as $string from "../gleam/string.mjs";
5
+ import {
6
+ bit_array_from_string as from_string,
7
+ bit_array_bit_size as bit_size,
8
+ bit_array_byte_size as byte_size,
9
+ bit_array_pad_to_bytes as pad_to_bytes,
10
+ bit_array_slice as slice,
11
+ bit_array_concat as concat,
12
+ base64_encode,
13
+ base64_decode as decode64,
14
+ base16_encode,
15
+ base16_decode,
16
+ bit_array_to_int_and_size,
17
+ bit_array_starts_with as starts_with,
18
+ bit_array_to_string as to_string,
19
+ } from "../gleam_stdlib.mjs";
20
+
21
+ export {
22
+ base16_decode,
23
+ base16_encode,
24
+ base64_encode,
25
+ bit_size,
26
+ byte_size,
27
+ concat,
28
+ from_string,
29
+ pad_to_bytes,
30
+ slice,
31
+ starts_with,
32
+ to_string,
33
+ };
34
+
35
+ /**
36
+ * Creates a new bit array by joining two bit arrays.
37
+ *
38
+ * ## Examples
39
+ *
40
+ * ```gleam
41
+ * assert append(to: from_string("butter"), suffix: from_string("fly"))
42
+ * == from_string("butterfly")
43
+ * ```
44
+ */
45
+ export function append(first, second) {
46
+ return concat(toList([first, second]));
47
+ }
48
+
49
+ /**
50
+ * Decodes a base 64 encoded string into a `BitArray`.
51
+ */
52
+ export function base64_decode(encoded) {
53
+ let _block;
54
+ let $ = byte_size(from_string(encoded)) % 4;
55
+ if ($ === 0) {
56
+ _block = encoded;
57
+ } else {
58
+ let n = $;
59
+ _block = $string.append(encoded, $string.repeat("=", 4 - n));
60
+ }
61
+ let padded = _block;
62
+ return decode64(padded);
63
+ }
64
+
65
+ /**
66
+ * Encodes a `BitArray` into a base 64 encoded string with URL and filename
67
+ * safe alphabet.
68
+ *
69
+ * If the bit array does not contain a whole number of bytes then it is padded
70
+ * with zero bits prior to being encoded.
71
+ */
72
+ export function base64_url_encode(input, padding) {
73
+ let _pipe = input;
74
+ let _pipe$1 = base64_encode(_pipe, padding);
75
+ let _pipe$2 = $string.replace(_pipe$1, "+", "-");
76
+ return $string.replace(_pipe$2, "/", "_");
77
+ }
78
+
79
+ /**
80
+ * Decodes a base 64 encoded string with URL and filename safe alphabet into a
81
+ * `BitArray`.
82
+ */
83
+ export function base64_url_decode(encoded) {
84
+ let _pipe = encoded;
85
+ let _pipe$1 = $string.replace(_pipe, "-", "+");
86
+ let _pipe$2 = $string.replace(_pipe$1, "_", "/");
87
+ return base64_decode(_pipe$2);
88
+ }
89
+
90
+ function inspect_loop(loop$input, loop$accumulator) {
91
+ while (true) {
92
+ let input = loop$input;
93
+ let accumulator = loop$accumulator;
94
+ if (input.bitSize === 0) {
95
+ return accumulator;
96
+ } else if (input.bitSize === 1) {
97
+ let x = bitArraySliceToInt(input, 0, 1, true, false);
98
+ return (accumulator + $int.to_string(x)) + ":size(1)";
99
+ } else if (input.bitSize === 2) {
100
+ let x = bitArraySliceToInt(input, 0, 2, true, false);
101
+ return (accumulator + $int.to_string(x)) + ":size(2)";
102
+ } else if (input.bitSize === 3) {
103
+ let x = bitArraySliceToInt(input, 0, 3, true, false);
104
+ return (accumulator + $int.to_string(x)) + ":size(3)";
105
+ } else if (input.bitSize === 4) {
106
+ let x = bitArraySliceToInt(input, 0, 4, true, false);
107
+ return (accumulator + $int.to_string(x)) + ":size(4)";
108
+ } else if (input.bitSize === 5) {
109
+ let x = bitArraySliceToInt(input, 0, 5, true, false);
110
+ return (accumulator + $int.to_string(x)) + ":size(5)";
111
+ } else if (input.bitSize === 6) {
112
+ let x = bitArraySliceToInt(input, 0, 6, true, false);
113
+ return (accumulator + $int.to_string(x)) + ":size(6)";
114
+ } else if (input.bitSize === 7) {
115
+ let x = bitArraySliceToInt(input, 0, 7, true, false);
116
+ return (accumulator + $int.to_string(x)) + ":size(7)";
117
+ } else if (input.bitSize >= 8) {
118
+ let x = input.byteAt(0);
119
+ let rest = bitArraySlice(input, 8);
120
+ let _block;
121
+ if (rest.bitSize === 0) {
122
+ _block = "";
123
+ } else {
124
+ _block = ", ";
125
+ }
126
+ let suffix = _block;
127
+ let accumulator$1 = (accumulator + $int.to_string(x)) + suffix;
128
+ loop$input = rest;
129
+ loop$accumulator = accumulator$1;
130
+ } else {
131
+ return accumulator;
132
+ }
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Converts a bit array to a string containing the decimal value of each byte.
138
+ *
139
+ * Use this over `string.inspect` when you have a bit array you want printed
140
+ * in the array syntax even if it is valid UTF-8.
141
+ *
142
+ * ## Examples
143
+ *
144
+ * ```gleam
145
+ * assert inspect(<<0, 20, 0x20, 255>>) == "<<0, 20, 32, 255>>"
146
+ * ```
147
+ *
148
+ * ```gleam
149
+ * assert inspect(<<100, 5:3>>) == "<<100, 5:size(3)>>"
150
+ * ```
151
+ */
152
+ export function inspect(input) {
153
+ return inspect_loop(input, "<<") + ">>";
154
+ }
155
+
156
+ /**
157
+ * Compare two bit arrays as sequences of bytes.
158
+ *
159
+ * ## Examples
160
+ *
161
+ * ```gleam
162
+ * assert compare(<<1>>, <<2>>) == Lt
163
+ * ```
164
+ *
165
+ * ```gleam
166
+ * assert compare(<<"AB":utf8>>, <<"AA":utf8>>) == Gt
167
+ * ```
168
+ *
169
+ * ```gleam
170
+ * assert compare(<<1, 2:size(2)>>, with: <<1, 2:size(2)>>) == Eq
171
+ * ```
172
+ */
173
+ export function compare(loop$a, loop$b) {
174
+ while (true) {
175
+ let a = loop$a;
176
+ let b = loop$b;
177
+ if (a.bitSize >= 8) {
178
+ if (b.bitSize >= 8) {
179
+ let first_byte = a.byteAt(0);
180
+ let first_rest = bitArraySlice(a, 8);
181
+ let second_byte = b.byteAt(0);
182
+ let second_rest = bitArraySlice(b, 8);
183
+ let f = first_byte;
184
+ let s = second_byte;
185
+ if (f > s) {
186
+ return new $order.Gt();
187
+ } else {
188
+ let f = first_byte;
189
+ let s = second_byte;
190
+ if (f < s) {
191
+ return new $order.Lt();
192
+ } else {
193
+ loop$a = first_rest;
194
+ loop$b = second_rest;
195
+ }
196
+ }
197
+ } else if (b.bitSize === 0) {
198
+ return new $order.Gt();
199
+ } else {
200
+ let first = a;
201
+ let second = b;
202
+ let $ = bit_array_to_int_and_size(first);
203
+ let $1 = bit_array_to_int_and_size(second);
204
+ let a$1 = $[0];
205
+ let b$1 = $1[0];
206
+ if (a$1 > b$1) {
207
+ return new $order.Gt();
208
+ } else {
209
+ let a$1 = $[0];
210
+ let b$1 = $1[0];
211
+ if (a$1 < b$1) {
212
+ return new $order.Lt();
213
+ } else {
214
+ let size_a = $[1];
215
+ let size_b = $1[1];
216
+ if (size_a > size_b) {
217
+ return new $order.Gt();
218
+ } else {
219
+ let size_a = $[1];
220
+ let size_b = $1[1];
221
+ if (size_a < size_b) {
222
+ return new $order.Lt();
223
+ } else {
224
+ return new $order.Eq();
225
+ }
226
+ }
227
+ }
228
+ }
229
+ }
230
+ } else if (b.bitSize === 0) {
231
+ if (a.bitSize === 0) {
232
+ return new $order.Eq();
233
+ } else {
234
+ return new $order.Gt();
235
+ }
236
+ } else if (a.bitSize === 0) {
237
+ return new $order.Lt();
238
+ } else {
239
+ let first = a;
240
+ let second = b;
241
+ let $ = bit_array_to_int_and_size(first);
242
+ let $1 = bit_array_to_int_and_size(second);
243
+ let a$1 = $[0];
244
+ let b$1 = $1[0];
245
+ if (a$1 > b$1) {
246
+ return new $order.Gt();
247
+ } else {
248
+ let a$1 = $[0];
249
+ let b$1 = $1[0];
250
+ if (a$1 < b$1) {
251
+ return new $order.Lt();
252
+ } else {
253
+ let size_a = $[1];
254
+ let size_b = $1[1];
255
+ if (size_a > size_b) {
256
+ return new $order.Gt();
257
+ } else {
258
+ let size_a = $[1];
259
+ let size_b = $1[1];
260
+ if (size_a < size_b) {
261
+ return new $order.Lt();
262
+ } else {
263
+ return new $order.Eq();
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Tests to see whether a bit array is valid UTF-8.
274
+ */
275
+ export function is_utf8(bits) {
276
+ return is_utf8_loop(bits);
277
+ }
278
+
279
+ function is_utf8_loop(bits) {
280
+ let $ = to_string(bits);
281
+ if ($ instanceof Ok) {
282
+ return true;
283
+ } else {
284
+ return false;
285
+ }
286
+ }
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Returns the and of two bools, but it evaluates both arguments.
3
+ *
4
+ * It's the function equivalent of the `&&` operator.
5
+ * This function is useful in higher order functions or pipes.
6
+ *
7
+ * ## Examples
8
+ *
9
+ * ```gleam
10
+ * assert and(True, True)
11
+ * ```
12
+ *
13
+ * ```gleam
14
+ * assert !and(False, True)
15
+ * ```
16
+ *
17
+ * ```gleam
18
+ * assert !and(False, True)
19
+ * ```
20
+ *
21
+ * ```gleam
22
+ * assert !and(False, False)
23
+ * ```
24
+ */
25
+ export function and(a, b) {
26
+ return a && b;
27
+ }
28
+
29
+ /**
30
+ * Returns the or of two bools, but it evaluates both arguments.
31
+ *
32
+ * It's the function equivalent of the `||` operator.
33
+ * This function is useful in higher order functions or pipes.
34
+ *
35
+ * ## Examples
36
+ *
37
+ * ```gleam
38
+ * assert or(True, True)
39
+ * ```
40
+ *
41
+ * ```gleam
42
+ * assert or(False, True)
43
+ * ```
44
+ *
45
+ * ```gleam
46
+ * assert or(True, False)
47
+ * ```
48
+ *
49
+ * ```gleam
50
+ * assert !or(False, False)
51
+ * ```
52
+ */
53
+ export function or(a, b) {
54
+ return a || b;
55
+ }
56
+
57
+ /**
58
+ * Returns the opposite bool value.
59
+ *
60
+ * This is the same as the `!` or `not` operators in some other languages.
61
+ *
62
+ * ## Examples
63
+ *
64
+ * ```gleam
65
+ * assert !negate(True)
66
+ * ```
67
+ *
68
+ * ```gleam
69
+ * assert negate(False)
70
+ * ```
71
+ */
72
+ export function negate(bool) {
73
+ return !bool;
74
+ }
75
+
76
+ /**
77
+ * Returns the nor of two bools.
78
+ *
79
+ * ## Examples
80
+ *
81
+ * ```gleam
82
+ * assert nor(False, False)
83
+ * ```
84
+ *
85
+ * ```gleam
86
+ * assert !nor(False, True)
87
+ * ```
88
+ *
89
+ * ```gleam
90
+ * assert !nor(True, False)
91
+ * ```
92
+ *
93
+ * ```gleam
94
+ * assert !nor(True, True)
95
+ * ```
96
+ */
97
+ export function nor(a, b) {
98
+ return !(a || b);
99
+ }
100
+
101
+ /**
102
+ * Returns the nand of two bools.
103
+ *
104
+ * ## Examples
105
+ *
106
+ * ```gleam
107
+ * assert nand(False, False)
108
+ * ```
109
+ *
110
+ * ```gleam
111
+ * assert nand(False, True)
112
+ * ```
113
+ *
114
+ * ```gleam
115
+ * assert nand(True, False)
116
+ * ```
117
+ *
118
+ * ```gleam
119
+ * assert !nand(True, True)
120
+ * ```
121
+ */
122
+ export function nand(a, b) {
123
+ return !(a && b);
124
+ }
125
+
126
+ /**
127
+ * Returns the exclusive or of two bools.
128
+ *
129
+ * ## Examples
130
+ *
131
+ * ```gleam
132
+ * assert !exclusive_or(False, False)
133
+ * ```
134
+ *
135
+ * ```gleam
136
+ * assert exclusive_or(False, True)
137
+ * ```
138
+ *
139
+ * ```gleam
140
+ * assert exclusive_or(True, False)
141
+ * ```
142
+ *
143
+ * ```gleam
144
+ * assert !exclusive_or(True, True)
145
+ * ```
146
+ */
147
+ export function exclusive_or(a, b) {
148
+ return a !== b;
149
+ }
150
+
151
+ /**
152
+ * Returns the exclusive nor of two bools.
153
+ *
154
+ * ## Examples
155
+ *
156
+ * ```gleam
157
+ * assert exclusive_nor(False, False)
158
+ * ```
159
+ *
160
+ * ```gleam
161
+ * assert !exclusive_nor(False, True)
162
+ * ```
163
+ *
164
+ * ```gleam
165
+ * assert !exclusive_nor(True, False)
166
+ * ```
167
+ *
168
+ * ```gleam
169
+ * assert exclusive_nor(True, True)
170
+ * ```
171
+ */
172
+ export function exclusive_nor(a, b) {
173
+ return a === b;
174
+ }
175
+
176
+ /**
177
+ * Returns a string representation of the given bool.
178
+ *
179
+ * ## Examples
180
+ *
181
+ * ```gleam
182
+ * assert to_string(True) == "True"
183
+ * ```
184
+ *
185
+ * ```gleam
186
+ * assert to_string(False) == "False"
187
+ * ```
188
+ */
189
+ export function to_string(bool) {
190
+ if (bool) {
191
+ return "True";
192
+ } else {
193
+ return "False";
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Run a callback function if the given bool is `False`, otherwise return a
199
+ * default value.
200
+ *
201
+ * With a `use` expression this function can simulate the early-return pattern
202
+ * found in some other programming languages.
203
+ *
204
+ * In a procedural language:
205
+ *
206
+ * ```js
207
+ * if (predicate) return value;
208
+ * // ...
209
+ * ```
210
+ *
211
+ * In Gleam with a `use` expression:
212
+ *
213
+ * ```gleam
214
+ * use <- guard(when: predicate, return: value)
215
+ * // ...
216
+ * ```
217
+ *
218
+ * Like everything in Gleam `use` is an expression, so it short circuits the
219
+ * current block, not the entire function. As a result you can assign the value
220
+ * to a variable:
221
+ *
222
+ * ```gleam
223
+ * let x = {
224
+ * use <- guard(when: predicate, return: value)
225
+ * // ...
226
+ * }
227
+ * ```
228
+ *
229
+ * Note that unlike in procedural languages the `return` value is evaluated
230
+ * even when the predicate is `False`, so it is advisable not to perform
231
+ * expensive computation nor side-effects there.
232
+ *
233
+ *
234
+ * ## Examples
235
+ *
236
+ * ```gleam
237
+ * let name = ""
238
+ * use <- guard(when: name == "", return: "Welcome!")
239
+ * "Hello, " <> name
240
+ * // -> "Welcome!"
241
+ * ```
242
+ *
243
+ * ```gleam
244
+ * let name = "Kamaka"
245
+ * use <- guard(when: name == "", return: "Welcome!")
246
+ * "Hello, " <> name
247
+ * // -> "Hello, Kamaka"
248
+ * ```
249
+ */
250
+ export function guard(requirement, consequence, alternative) {
251
+ if (requirement) {
252
+ return consequence;
253
+ } else {
254
+ return alternative();
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Runs a callback function if the given bool is `True`, otherwise runs an
260
+ * alternative callback function.
261
+ *
262
+ * Useful when further computation should be delayed regardless of the given
263
+ * bool's value.
264
+ *
265
+ * See [`guard`](#guard) for more info.
266
+ *
267
+ * ## Examples
268
+ *
269
+ * ```gleam
270
+ * let name = "Kamaka"
271
+ * let inquiry = fn() { "How may we address you?" }
272
+ * use <- lazy_guard(when: name == "", return: inquiry)
273
+ * "Hello, " <> name
274
+ * // -> "Hello, Kamaka"
275
+ * ```
276
+ *
277
+ * ```gleam
278
+ * import gleam/int
279
+ *
280
+ * let name = ""
281
+ * let greeting = fn() { "Hello, " <> name }
282
+ * use <- lazy_guard(when: name == "", otherwise: greeting)
283
+ * let number = int.random(99)
284
+ * let name = "User " <> int.to_string(number)
285
+ * "Welcome, " <> name
286
+ * // -> "Welcome, User 54"
287
+ * ```
288
+ */
289
+ export function lazy_guard(requirement, consequence, alternative) {
290
+ if (requirement) {
291
+ return consequence();
292
+ } else {
293
+ return alternative();
294
+ }
295
+ }