Skip to content

Commit 08ad68a

Browse files
committed
feat: Implement Promise.finally method and refactor Promise module
- Add js_promise.rs module, separating Promise code from core.rs - Implement Promise.prototype.finally method with callback execution - Fix parser to allow reserved keywords as property names (support obj.finally() syntax) - Improve error handling with new JSError::Throw variant - Unify evaluate_script function, remove evaluate_script_async - Add Promise.finally test case - Fix function call references in async tests - Improve Promise rejection error message formatting
1 parent a2ebbd5 commit 08ad68a

File tree

9 files changed

+735
-728
lines changed

9 files changed

+735
-728
lines changed

src/core.rs

Lines changed: 86 additions & 425 deletions
Large diffs are not rendered by default.

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub enum JSError {
2424
#[error("Runtime error: {message}")]
2525
RuntimeError { message: String },
2626

27+
#[error("Thrown value: {value:?}")]
28+
Throw { value: crate::core::Value },
29+
2730
#[error("std::io error: {0}")]
2831
IoError(#[from] std::io::Error),
2932
}

src/js_class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub(crate) fn evaluate_new(env: &JSObjectDataPtr, constructor: &Expr, args: &[Ex
162162
return handle_string_constructor(args, env);
163163
}
164164
"Promise" => {
165-
return crate::js_function::handle_promise_constructor(args, env);
165+
return crate::js_promise::handle_promise_constructor(args, env);
166166
}
167167
_ => {
168168
log::warn!("evaluate_new - constructor is not an object or closure: Function({func_name})",);

src/js_function.rs

Lines changed: 19 additions & 289 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)