pub struct JsArray(/* private fields */);
Implementations§
Source§impl JsArray
impl JsArray
Sourcepub fn new(env: NapiEnv, length: usize) -> NapiResult<JsArray>
pub fn new(env: NapiEnv, length: usize) -> NapiResult<JsArray>
This API returns a Node-API value corresponding to a JavaScript Array type. The Array’s length property is set to the passed-in length parameter. However, the underlying buffer is not guaranteed to be pre-allocated by the VM when the array is created. That behavior is left to the underlying VM implementation. If the buffer must be a contiguous block of memory that can be directly read and/or written via C, consider using napi_create_external_arraybuffer.
JavaScript arrays are described in Section 22.1 of the ECMAScript Language Specification.
Sourcepub fn empty(env: NapiEnv) -> NapiResult<JsArray>
pub fn empty(env: NapiEnv) -> NapiResult<JsArray>
This API returns a Node-API value corresponding to a JavaScript Array type. JavaScript arrays are described in Section 22.1 of the ECMAScript Language Specification.
Sourcepub fn len(&self) -> NapiResult<u32>
pub fn len(&self) -> NapiResult<u32>
This API returns the length of an array. Array length is described in Section 22.1.4.1 of the ECMAScript Language Specification.
Sourcepub fn is_empty(&self) -> NapiResult<bool>
pub fn is_empty(&self) -> NapiResult<bool>
This array is empty.
Sourcepub fn get(&self, index: u32) -> NapiResult<JsValue>
pub fn get(&self, index: u32) -> NapiResult<JsValue>
Get element at index
Sourcepub fn set(&mut self, index: u32, value: impl NapiValueT) -> NapiResult<()>
pub fn set(&mut self, index: u32, value: impl NapiValueT) -> NapiResult<()>
Set element at index
Trait Implementations§
Source§impl NapiValueCheck for JsArray
impl NapiValueCheck for JsArray
Source§fn check(&self) -> NapiResult<bool>
fn check(&self) -> NapiResult<bool>
This API represents invoking the IsArray operation on the object as defined in Section 7.2.2 of the ECMAScript Language Specification.