get-node-modules-rust
v1.0.1
Published
fast search node_modules dir, power by Rust dylib
Downloads
6
Readme
Walk thougn the Given Dir by Rust crate(readir)
Why
- f.f.f.f..f.f..ff...f.ff.f..fast
Use
const files = require('get-node-modules-rust').find('./');
Demo
npm run start
see Result
[ './node_modules' ]
cost time: 0.043 ms
- 3.5G ~ 2ms
Build
- Rust, lib.rs with
libc
cargo build --release
cp dylib into the dir named in package.json
and index.js
cp target/release/libfind_files.dylib ./rust-dylib
- Node, index.js with
node-ffi
var lib = ffi.Library(path.join(__dirname, './rust-dylib/libget_dir'), {
get_dir: ['char *', ['string']],
free_memory: ['void', ['char *']]
});