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:
Jarred Sumner
2024-01-15 17:56:02 -08:00
committed by GitHub
parent 407f42718c
commit e5421c56b1
32 changed files with 687 additions and 64 deletions

View File

@@ -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..]);
}
};