node-rs icon indicating copy to clipboard operation
node-rs copied to clipboard

Add @napi-rs/glob package

Open mohsen1 opened this issue 3 years ago • 4 comments
trafficstars

This is a very rough draft for adding a new package that wraps Rust's glob crate. I'm aiming to teach myself Rust and NAPI stuff by doing this. You don't have to review it right now but if you have any helpful comments I would greatly appreciate it!

Fixes: https://github.com/napi-rs/node-rs/issues/605

TODO

  • [x] Benchmark
  • [ ] Default export https://github.com/napi-rs/napi-rs/issues/1046

mohsen1 avatar Jan 20 '22 02:01 mohsen1

@Brooooooklyn thank you for your responses

Question: is there a way of making this async? In the Rust land it is a sync operation but it can take some time so it would be ideal to unlock the Node.JS event loop while doing work.

mohsen1 avatar Jan 23 '22 17:01 mohsen1

https://napi.rs/docs/concepts/async-task

Brooooooklyn avatar Jan 24 '22 01:01 Brooooooklyn

@Brooooooklyn Added some bench and mine is slower! Any ideas where we can improve the performance on this?

  "glob":
    14 120 ops/s, ±1.43%   | fastest

  "@napi-rs/glob":
    12 553 ops/s, ±0.19%   | slowest, 11.1% slower

Note: this is for the sync operation. I'm still having bugs in the async version

mohsen1 avatar Jan 24 '22 17:01 mohsen1

Fixed the async API and benchmark code. Of course napi would be faster!

Screen Shot 2022-01-30 at 1 27 29 PM

mohsen1 avatar Jan 30 '22 16:01 mohsen1