diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/string.gleam | 4 | ||||
-rw-r--r-- | src/gleam_stdlib.mjs | 7 |
2 files changed, 1 insertions, 10 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam index 00d58ad..a87b343 100644 --- a/src/gleam/string.gleam +++ b/src/gleam/string.gleam @@ -608,9 +608,8 @@ fn padding(size: Int, pad_string: String) -> String { /// // -> "hats" /// ``` /// -@external(javascript, "../gleam_stdlib.mjs", "trim") pub fn trim(string: String) -> String { - erl_trim(string, Both) + string |> trim_start |> trim_end } @external(erlang, "string", "trim") @@ -619,7 +618,6 @@ fn erl_trim(a: String, b: Direction) -> String type Direction { Leading Trailing - Both } /// Removes whitespace on the left of a `String`. diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs index dc57c9c..4f804f7 100644 --- a/src/gleam_stdlib.mjs +++ b/src/gleam_stdlib.mjs @@ -307,13 +307,6 @@ const unicode_whitespaces = [ const trim_start_regex = new RegExp(`^[${unicode_whitespaces}]*`); const trim_end_regex = new RegExp(`[${unicode_whitespaces}]*$`); -const trim_regex = new RegExp( - `^[${unicode_whitespaces}]*(.*?)[${unicode_whitespaces}]*$`, -); - -export function trim(string) { - return string.match(trim_regex)[1]; -} export function trim_start(string) { return string.replace(trim_start_regex, ""); |