mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 13:51:47 +00:00
esmodules work?
Former-commit-id: 5cb5af4416c12518eb195d1b310990fc5c94d6c8
This commit is contained in:
@@ -80,6 +80,30 @@ pub fn endsWithAny(self: string, str: string) bool {
|
||||
|
||||
pub fn lastNonwhitespace(self: string, str: string) bool {}
|
||||
|
||||
pub fn quotedAlloc(allocator: *std.mem.Allocator, self: string) !string {
|
||||
var count: usize = 0;
|
||||
for (self) |char| {
|
||||
count += @boolToInt(char == '"');
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
return allocator.dupe(u8, self);
|
||||
}
|
||||
|
||||
var i: usize = 0;
|
||||
var out = try allocator.alloc(u8, self.len + count);
|
||||
for (self) |char| {
|
||||
if (char == '"') {
|
||||
out[i] = '\\';
|
||||
i += 1;
|
||||
}
|
||||
out[i] = char;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn endsWithAnyComptime(self: string, comptime str: string) bool {
|
||||
if (str.len < 10) {
|
||||
const last = self[self.len - 1];
|
||||
|
||||
Reference in New Issue
Block a user