mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
bake: csr, streaming ssr, serve integration, safer jsvalue functions, &more (#14900)
Co-authored-by: paperdave <paperdave@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -691,6 +691,7 @@ pub const String = extern struct {
|
||||
try self.toZigString().format(fmt, opts, writer);
|
||||
}
|
||||
|
||||
/// Deprecated: use `fromJS2` to handle errors explicitly
|
||||
pub fn fromJS(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) String {
|
||||
JSC.markBinding(@src());
|
||||
|
||||
@@ -702,6 +703,16 @@ pub const String = extern struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fromJS2(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) bun.JSError!String {
|
||||
var out: String = String.dead;
|
||||
if (BunString__fromJS(globalObject, value, &out)) {
|
||||
bun.assert(out.tag != .Dead);
|
||||
return out;
|
||||
} else {
|
||||
return globalObject.jsErrorFromCPP();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fromJSRef(value: bun.JSC.JSValue, globalObject: *JSC.JSGlobalObject) String {
|
||||
JSC.markBinding(@src());
|
||||
|
||||
@@ -1331,6 +1342,11 @@ pub const String = extern struct {
|
||||
const width = str.visibleWidth(false);
|
||||
return JSC.jsNumber(width);
|
||||
}
|
||||
|
||||
// TODO: move ZigString.Slice here
|
||||
/// A UTF-8 encoded slice tied to the lifetime of a `bun.String`
|
||||
/// Must call `.deinit` to release memory
|
||||
pub const Slice = ZigString.Slice;
|
||||
};
|
||||
|
||||
pub const SliceWithUnderlyingString = struct {
|
||||
|
||||
Reference in New Issue
Block a user