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

Method evaluate

modules/llrt_buffer/src/lib.rs:35–55  ·  view source on GitHub ↗
(ctx: &Ctx<'js>, exports: &Exports<'js>)

Source from the content-addressed store, hash-verified

33 Ok(())
34 }
35
36 fn evaluate<'js>(ctx: &Ctx<'js>, exports: &Exports<'js>) -> Result<()> {
37 let globals = ctx.globals();
38 let buf: Constructor = globals.get(stringify!(Buffer))?;
39
40 let constants = Object::new(ctx.clone())?;
41 constants.set("MAX_LENGTH", u32::MAX)?; // For QuickJS
42 constants.set("MAX_STRING_LENGTH", (1 << 30) - 1)?; // For QuickJS
43
44 let atob: Function = ctx.globals().get("atob")?;
45 let btoa: Function = ctx.globals().get("btoa")?;
46
47 export_default(ctx, exports, |default| {
48 default.set(stringify!(Buffer), buf)?;
49 default.set("atob", atob.into_js(ctx)?)?;
50 default.set("btoa", btoa.into_js(ctx)?)?;
51 default.set("constants", constants)?;
52 Ok(())
53 })?;
54
55 Ok(())
56 }
57}
58

Callers

nothing calls this directly

Calls 5

export_defaultFunction · 0.85
getMethod · 0.45
cloneMethod · 0.45
setMethod · 0.45
into_jsMethod · 0.45

Tested by

no test coverage detected