From c366841b1a12d7b6c9e954bc46f8726429b838f9 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 17 Aug 2022 17:07:59 +0200 Subject: [PATCH 1/2] Add replacement for String.startsWith --- src/replacements/string/_String_startsWith.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/replacements/string/_String_startsWith.js diff --git a/src/replacements/string/_String_startsWith.js b/src/replacements/string/_String_startsWith.js new file mode 100644 index 00000000..f29f57b6 --- /dev/null +++ b/src/replacements/string/_String_startsWith.js @@ -0,0 +1,12 @@ +var _String_startsWith = F2( + function (prefix, str) { + var prefixLength = prefix.length; + var i = -1; + if (str.length < prefixLength) { + return $elm$core$Basics$False; + } + while (++i < prefixLength) { + if (prefix[i] !== str[i]) { return $elm$core$Basics$False; } + } + return $elm$core$Basics$True; + }); \ No newline at end of file From e07c4e76401bf0c315da66daf678bd69fa48f76d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 9 Sep 2022 17:47:27 +0200 Subject: [PATCH 2/2] Use true and false --- src/replacements/string/_String_startsWith.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/replacements/string/_String_startsWith.js b/src/replacements/string/_String_startsWith.js index f29f57b6..db6ef0f1 100644 --- a/src/replacements/string/_String_startsWith.js +++ b/src/replacements/string/_String_startsWith.js @@ -3,10 +3,10 @@ var _String_startsWith = F2( var prefixLength = prefix.length; var i = -1; if (str.length < prefixLength) { - return $elm$core$Basics$False; + return false; } while (++i < prefixLength) { - if (prefix[i] !== str[i]) { return $elm$core$Basics$False; } + if (prefix[i] !== str[i]) { return false; } } - return $elm$core$Basics$True; + return true; }); \ No newline at end of file