feat(napi): implement detach arraybuffer
This commit is contained in:
parent
ef51a882c6
commit
1dc9974c19
2 changed files with 16 additions and 2 deletions
|
@ -223,5 +223,5 @@ yarn test
|
|||
| [napi_is_typedarray](https://nodejs.org/api/n-api.html#n_api_napi_is_typedarray) | 1 | v8.0.0 | ✅ |
|
||||
| [napi_is_dataview](https://nodejs.org/api/n-api.html#n_api_napi_is_dataview) | 1 | v8.3.0 | ✅ |
|
||||
| [napi_strict_equals](https://nodejs.org/api/n-api.html#n_api_napi_strict_equals) | 1 | v8.0.0 | ✅ |
|
||||
| [napi_detach_arraybuffer](https://nodejs.org/api/n-api.html#n_api_napi_detach_arraybuffer) | 7 | v13.3.0 | ⛔️ |
|
||||
| [napi_is_detached_arraybuffer](https://nodejs.org/api/n-api.html#n_api_napi_is_detached_arraybuffer) | 7 | v13.3.0 | ⛔️ |
|
||||
| [napi_detach_arraybuffer](https://nodejs.org/api/n-api.html#n_api_napi_detach_arraybuffer) | 7 | v13.3.0 | ✅ |
|
||||
| [napi_is_detached_arraybuffer](https://nodejs.org/api/n-api.html#n_api_napi_is_detached_arraybuffer) | 7 | v13.3.0 | ✅ |
|
||||
|
|
|
@ -100,6 +100,20 @@ impl From<TypedArrayType> for sys::napi_typedarray_type {
|
|||
}
|
||||
|
||||
impl JsArrayBuffer {
|
||||
#[cfg(napi7)]
|
||||
pub fn detach(self) -> Result<()> {
|
||||
check_status(unsafe { sys::napi_detach_arraybuffer(self.0.env, self.0.value) })
|
||||
}
|
||||
|
||||
#[cfg(napi7)]
|
||||
pub fn is_detached(&self) -> Result<bool> {
|
||||
let mut is_detached = false;
|
||||
check_status(unsafe {
|
||||
sys::napi_is_detached_arraybuffer(self.0.env, self.0.value, &mut is_detached)
|
||||
})?;
|
||||
Ok(is_detached)
|
||||
}
|
||||
|
||||
pub fn into_value(self) -> Result<JsArrayBufferValue> {
|
||||
let mut data = ptr::null_mut();
|
||||
let mut len: u64 = 0;
|
||||
|
|
Loading…
Reference in a new issue