feat(napi): implement create_array

This commit is contained in:
LongYinan 2020-10-21 15:17:06 +08:00
parent 5025ffa791
commit e559908b76
No known key found for this signature in database
GPG key ID: A3FFE134A3E20881

View file

@ -215,6 +215,12 @@ impl Env {
Ok(JsObject::from_raw_unchecked(self.0, raw_value)) Ok(JsObject::from_raw_unchecked(self.0, raw_value))
} }
pub fn create_array(&self) -> Result<JsObject> {
let mut raw_value = ptr::null_mut();
check_status(unsafe { sys::napi_create_array(self.0, &mut raw_value) })?;
Ok(JsObject::from_raw_unchecked(self.0, raw_value))
}
pub fn create_array_with_length(&self, length: usize) -> Result<JsObject> { pub fn create_array_with_length(&self, length: usize) -> Result<JsObject> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
check_status(unsafe { check_status(unsafe {