aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorErik Terpstra <39518+eterps@users.noreply.github.com>2020-05-19 10:19:27 +0200
committerLouis Pilfold <louis@lpil.uk>2020-05-19 14:12:11 +0100
commite5e14239bd6ca6f349b7dd76fb845b60515e3364 (patch)
tree639b29064a64811c7dec064d5881834aac916b35 /src/gleam_stdlib.erl
parentb3407607c4a58efa50239db278d730ef5b503afe (diff)
downloadgleam_stdlib-e5e14239bd6ca6f349b7dd76fb845b60515e3364.tar.gz
gleam_stdlib-e5e14239bd6ca6f349b7dd76fb845b60515e3364.zip
string.pad_left & string.pad_right
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index fbd84da..bbf7630 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -7,7 +7,7 @@
iodata_append/2, iodata_prepend/2, identity/1, decode_int/1,
decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, decode_atom/1,
decode_list/1, decode_field/2, decode_element/2, parse_int/1, parse_float/1, compare_strings/2,
- string_contains/2, string_starts_with/2, string_ends_with/2]).
+ string_contains/2, string_starts_with/2, string_ends_with/2, string_pad/4]).
should_equal(Actual, Expected) -> ?assertEqual(Expected, Actual).
should_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual).
@@ -139,3 +139,6 @@ string_ends_with(String, Suffix) when byte_size(Suffix) > byte_size(String) -> f
string_ends_with(String, Suffix) ->
SuffixSize = byte_size(Suffix),
Suffix == binary_part(String, byte_size(String) - SuffixSize, SuffixSize).
+
+string_pad(String, Length, Dir, PadString) ->
+ unicode:characters_to_binary(string:pad(String, Length, Dir, PadString)).