From e559908b76e72c39bed491e7a1154e55ac8f80cc Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 21 Oct 2020 15:17:06 +0800 Subject: [PATCH] feat(napi): implement create_array --- napi/src/env.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/napi/src/env.rs b/napi/src/env.rs index 7261b32f..5b675c57 100644 --- a/napi/src/env.rs +++ b/napi/src/env.rs @@ -215,6 +215,12 @@ impl Env { Ok(JsObject::from_raw_unchecked(self.0, raw_value)) } + pub fn create_array(&self) -> Result { + 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 { let mut raw_value = ptr::null_mut(); check_status(unsafe {