Merge pull request #888 from trheyi/main

Add optional options handling in objectCall.run method
This commit is contained in:
Max 2025-03-03 18:14:29 +08:00 committed by GitHub
commit 7164eddaba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -202,9 +202,12 @@ func (obj *objectCall) run(info *v8go.FunctionCallbackInfo) *v8go.Value {
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to get the options: %s", err.Error()))
}
err = bridge.Unmarshal(jsOptions, &options)
if err != nil {
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error()))
// Check if the options is undefined
if !jsOptions.IsUndefined() {
err = bridge.Unmarshal(jsOptions, &options)
if err != nil {
return bridge.JsException(info.Context(), fmt.Sprintf("Failed to unmarshal the options: %s", err.Error()))
}
}
}