aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/bindings.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-06-20 00:31:07 -0700
committerGravatar GitHub <noreply@github.com> 2023-06-20 00:31:07 -0700
commit9f301e13c5d8f057e6e9308e23cba7ecc27dab09 (patch)
treeee8990a71359eb589ccb9bd543fa3ac9ff13ead5 /src/bun.js/bindings/bindings.cpp
parentf1b1dbf5cdbd73fc7ca9ef46892530c2cb883d37 (diff)
downloadbun-9f301e13c5d8f057e6e9308e23cba7ecc27dab09.tar.gz
bun-9f301e13c5d8f057e6e9308e23cba7ecc27dab09.tar.zst
bun-9f301e13c5d8f057e6e9308e23cba7ecc27dab09.zip
Cleanup fs.utimesSync (#3363)
* Fix UB in fs.utimesSync when passing a number with an integer greater than i32 * Fix make headers --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r--src/bun.js/bindings/bindings.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 74357f225..2ec1bd902 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -3111,6 +3111,19 @@ int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0)
return JSC::JSValue::decode(JSValue0).asInt32();
}
+CPP_DECL double JSC__JSValue__coerceToDouble(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
+{
+ JSC::JSValue value = JSC::JSValue::decode(JSValue0);
+ auto catchScope = DECLARE_CATCH_SCOPE(arg1->vm());
+ double result = value.toNumber(arg1);
+ if (catchScope.exception()) {
+ result = PNaN;
+ catchScope.clearException();
+ }
+
+ return result;
+}
+
// truncates values larger than int32
int32_t JSC__JSValue__coerceToInt32(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1)
{
@@ -4374,6 +4387,16 @@ extern "C" JSC__JSValue WebCore__AbortSignal__createTimeoutError(const ZigString
return JSC::JSValue::encode(error);
}
+CPP_DECL double JSC__JSValue__getUnixTimestamp(JSC__JSValue timeValue)
+{
+ JSC::JSValue decodedValue = JSC::JSValue::decode(timeValue);
+ JSC::DateInstance* date = JSC::jsDynamicCast<JSC::DateInstance*>(decodedValue);
+ if (!date)
+ return PNaN;
+
+ return date->internalNumber();
+}
+
#pragma mark - WebCore::DOMFormData
CPP_DECL void WebCore__DOMFormData__append(WebCore__DOMFormData* arg0, ZigString* arg1, ZigString* arg2)