Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new get_or_undefined method for [JsValue] #1492

Merged
merged 5 commits into from
Sep 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement trait JsArgs for [JsValue]
  • Loading branch information
jedel1043 committed Aug 27, 2021
commit 10e80524e3903a35d831a839936b61f7fea15b67
6 changes: 6 additions & 0 deletions boa/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,9 @@ pub fn init(context: &mut Context) {
pub(crate) trait JsArgs {
fn get_or_undefined(&self, index: usize) -> JsValue;
}

impl JsArgs for [JsValue] {
fn get_or_undefined(&self, index: usize) -> JsValue {
self.get(index).cloned().unwrap_or_default()
}
}