aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-07-01 05:12:15 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-07-01 05:12:15 -0700
commit88aad6aeb19f3d1d73ced59a7a5aaddc2d7408ee (patch)
tree48c5a443c72d4739f154f2e9f63187b49bb78720 /src/string_immutable.zig
parenta8536a73373794dc9748a97f0e4668d6bf708ca1 (diff)
downloadbun-88aad6aeb19f3d1d73ced59a7a5aaddc2d7408ee.tar.gz
bun-88aad6aeb19f3d1d73ced59a7a5aaddc2d7408ee.tar.zst
bun-88aad6aeb19f3d1d73ced59a7a5aaddc2d7408ee.zip
this kind of works, but there is a crash when bundling. I think its missing a Stmt.Data.Store.reset()
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 03382e7a2..b65b142bf 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -367,6 +367,15 @@ pub fn containsNonBmpCodePoint(text: string) bool {
return false;
}
+// this is std.mem.trim except it doesn't forcibly change the slice to be const
+pub fn trim(slice: anytype, values_to_strip: []const u8) @TypeOf(slice) {
+ var begin: usize = 0;
+ var end: usize = slice.len;
+ while (begin < end and std.mem.indexOfScalar(u8, values_to_strip, slice[begin]) != null) : (begin += 1) {}
+ while (end > begin and std.mem.indexOfScalar(u8, values_to_strip, slice[end - 1]) != null) : (end -= 1) {}
+ return slice[begin..end];
+}
+
pub fn containsNonBmpCodePointUTF16(_text: JavascriptString) bool {
const n = _text.len;
if (n > 0) {