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

Method new

modules/llrt_buffer/src/file.rs:22–49  ·  view source on GitHub ↗
(
        ctx: Ctx<'js>,
        data: Value<'js>,
        filename: Coerced<String>,
        options: Opt<Value<'js>>,
    )

Source from the content-addressed store, hash-verified

20impl<'js> File<'js> {
21 #[qjs(constructor)]
22 fn new(
23 ctx: Ctx<'js>,
24 data: Value<'js>,
25 filename: Coerced<String>,
26 options: Opt<Value<'js>>,
27 ) -> Result<Self> {
28 let mut last_modified = time::now_millis();
29
30 if let Some(ref opts) = options.0 {
31 if opts.is_bool() || opts.is_float() || opts.is_int() || opts.is_string() {
32 return Err(Exception::throw_type(&ctx, "Invalid options"));
33 }
34
35 if let Some(v) = opts.as_object() {
36 if let Some(x) = v.get::<_, Option<Coerced<i64>>>("lastModified")? {
37 last_modified = x.0;
38 }
39 }
40 }
41
42 let blob = Blob::from_parts(ctx, Opt(Some(data)), options)?;
43
44 Ok(Self {
45 blob,
46 filename: filename.0,
47 last_modified,
48 })
49 }
50
51 #[qjs(get)]
52 pub fn size(&self) -> usize {

Callers

nothing calls this directly

Calls 2

now_millisFunction · 0.85
as_objectMethod · 0.80

Tested by

no test coverage detected