2020-09-30 19:22:48 +09:00
|
|
|
use std::str;
|
|
|
|
|
2020-11-25 18:42:14 +09:00
|
|
|
use napi::{CallContext, JsArrayBuffer, JsNumber, JsObject, Result};
|
2020-09-30 19:22:48 +09:00
|
|
|
|
|
|
|
#[js_function(1)]
|
|
|
|
pub fn get_arraybuffer_length(ctx: CallContext) -> Result<JsNumber> {
|
|
|
|
let buffer = ctx.get::<JsArrayBuffer>(0)?.into_value()?;
|
|
|
|
ctx.env.create_uint32((&buffer).len() as u32)
|
|
|
|
}
|
|
|
|
|
2020-11-25 18:42:14 +09:00
|
|
|
pub fn register_js(exports: &mut JsObject) -> Result<()> {
|
|
|
|
exports.create_named_method("getArraybufferLength", get_arraybuffer_length)?;
|
2020-09-30 19:22:48 +09:00
|
|
|
Ok(())
|
|
|
|
}
|