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

Function test_subarray

modules/llrt_buffer/src/buffer.rs:876–905  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

874
875 let prototype: &Object = &constructor.get(PredefinedAtom::Prototype)?;
876 prototype.set("copy", Func::from(copy))?;
877 prototype.set("subarray", Func::from(subarray))?;
878 prototype.set(PredefinedAtom::ToString, Func::from(to_string))?;
879 prototype.set("write", Func::from(write))?;
880
881 // Set all write and read methods
882 for kind in NumberKind::iter() {
883 for (endian, name, alias) in kind.prototype() {
884 let write_func = Function::new(ctx.clone(), |t, c, v, o| {
885 write_buf(&t, &c, &v, &o, *endian, *kind)
886 })?;
887 let read_func =
888 Function::new(ctx.clone(), |t, c, o| read_buf(&t, &c, &o, *endian, *kind))?;
889 if let Some(alias) = alias {
890 prototype.set(["write", alias].concat(), write_func.clone())?;
891 prototype.set(["read", alias].concat(), read_func.clone())?;
892 }
893 prototype.set(["write", name].concat(), write_func)?;
894 prototype.set(["read", name].concat(), read_func)?;
895 }
896 }
897
898 //not assessable from js
899 prototype.prop(PredefinedAtom::Meta, stringify!(Buffer))?;
900
901 ctx.globals().set(stringify!(Buffer), constructor)?;
902
903 Ok(())
904}
905
906#[cfg(test)]
907mod tests {
908 use llrt_test::{call_test, test_async_with, ModuleEvaluator};

Callers

nothing calls this directly

Calls 5

test_async_withFunction · 0.85
into_bytesMethod · 0.80
initFunction · 0.70
cloneMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected