MCPcopy Create free account
hub / github.com/awslabs/llrt / arraybuffer_inspect

Function arraybuffer_inspect

llrt_core/src/builtins_inspect.rs:103–125  ·  view source on GitHub ↗
(ctx: Ctx<'js>, this: This<Object<'js>>)

Source from the content-addressed store, hash-verified

101}
102
103fn arraybuffer_inspect<'js>(ctx: Ctx<'js>, this: This<Object<'js>>) -> Result<Object<'js>> {
104 let primordials = BasePrimordials::get(&ctx)?;
105 let obj = Object::new(ctx.clone())?;
106
107 let byte_length: usize = this.get("byteLength")?;
108 let uint8_view: Object = primordials
109 .constructor_uint8array
110 .construct((this.0.clone(),))?;
111
112 let mut bytes = String::from("<");
113 for i in 0..byte_length.min(8) {
114 if i > 0 {
115 bytes.push(' ');
116 }
117 let byte: u8 = uint8_view.get(i as u32)?;
118 bytes.push_str(&format!("{:02x}", byte));
119 }
120 bytes.push('>');
121
122 obj.set("uint8Contents", bytes)?;
123 obj.set("byteLength", byte_length)?;
124 Ok(obj)
125}

Callers

nothing calls this directly

Calls 6

getFunction · 0.85
fromFunction · 0.85
pushMethod · 0.80
cloneMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected