MCPcopy Create free account
hub / github.com/Ray-D-Song/lexe / init

Function init

modules/llrt_buffer/src/buffer.rs:707–726  ·  view source on GitHub ↗
(ctx: &Ctx<'js>)

Source from the content-addressed store, hash-verified

705}
706
707pub fn init<'js>(ctx: &Ctx<'js>) -> Result<()> {
708 // Buffer
709 let buffer = ctx.eval::<Object<'js>, &str>(concat!(
710 "class ",
711 stringify!(Buffer),
712 " extends Uint8Array {}\n",
713 stringify!(Buffer),
714 ))?;
715 set_prototype(ctx, buffer)?;
716
717 //init primordials
718 let _ = BufferPrimordials::get(ctx)?;
719
720 // Conversion
721 let globals = ctx.globals();
722 globals.set("atob", Func::from(atob))?;
723 globals.set("btoa", Func::from(btoa))?;
724
725 Ok(())
726}
727
728pub struct BufferModule;
729

Callers 6

test_atobFunction · 0.70
test_atob_invalid_utf8Function · 0.70
test_btoaFunction · 0.70
test_subarrayFunction · 0.70
test_subarray_partialFunction · 0.70

Calls 4

set_prototypeFunction · 0.85
getFunction · 0.85
fromFunction · 0.85
setMethod · 0.45

Tested by 6

test_atobFunction · 0.56
test_atob_invalid_utf8Function · 0.56
test_btoaFunction · 0.56
test_subarrayFunction · 0.56
test_subarray_partialFunction · 0.56