[oden] Native IO module

This commit is contained in:
John Doty 2023-06-30 06:28:04 -07:00
parent f7ed78ce3b
commit 4959adc7e6
3 changed files with 20 additions and 1 deletions

View file

@ -71,7 +71,12 @@ impl IoImpl {
self.thread_pool.execute(Box::new(move || {
// TODO: Actually read the path.
let path = path;
promise.resolve(move |ctx: &ContextRef| ctx.new_string(&path));
let result = std::fs::read(path);
promise.resolve(move |ctx: &ContextRef| match result {
Ok(v) => ctx.new_array_buffer(v),
Err(err) => Err(err.into()),
});
}));
Ok(value)