mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 20:09:04 +00:00
feat: Support import db from './my.db' with {type: "sqlite"} (#8178)
* Support SQLite imports * Docs * Update executables.md * Update loaders.md * Update js_parser.zig * Update loaders.md * Update CMakeLists.txt * Update Module.ts * JSC got rid of `$trunc`? --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -5637,3 +5637,22 @@ pub fn visibleUTF16Width(input: []const u16) usize {
|
||||
pub fn visibleLatin1Width(input: []const u8) usize {
|
||||
return visibleASCIIWidth(input);
|
||||
}
|
||||
|
||||
pub const QuoteEscapeFormat = struct {
|
||||
data: []const u8,
|
||||
|
||||
pub fn format(self: QuoteEscapeFormat, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
var i: usize = 0;
|
||||
while (std.mem.indexOfAnyPos(u8, self.data, i, "\"\n\\")) |j| : (i = j + 1) {
|
||||
try writer.writeAll(self.data[i..j]);
|
||||
try writer.writeAll(switch (self.data[j]) {
|
||||
'"' => "\\\"",
|
||||
'\n' => "\\n",
|
||||
'\\' => "\\\\",
|
||||
else => unreachable,
|
||||
});
|
||||
}
|
||||
if (i == self.data.len) return;
|
||||
try writer.writeAll(self.data[i..]);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user