407 private links
Note: "The key insight is that loading massive files into memory all at once is rarely a good idea, even when technically possible."
- Read the whole file and call it a day with
fs.readFile - Read by byte chunks with file handles and buffers
- (preferred) Use stream
The streams handle the bytes and UTF-8 encoding automatically. Each state can be defined with a callback: error, data, end.
Use appropriate buffer sizes for streams. Default is 64kB. The highWaterMark can adjust it though.
When to use streams: large files, real time data processing, memory is limited, composability, unknown file sizes.
When to use file handles: precise control.
When to use fs/promises: known small files. readFileSync() and writeFileSync() are acceptable for cli tools and scripts, but forbidden for web servers and concurrent apps.
Prefer Promise.all or Promise.allSettled to leverage concurrency.
Handle specific errors. Always. await handle.close() or stream.on('error', () => stream.destroy()). Another solution is await pipeline(source, transform, destinationl)
How a rewrite in Rust is beneficial to read many files? Because it avoids allocation.
Note the program was written once in JS then in Rust.
https://youtu.be/LB8KwiiUGy0?t=525
NPM started as a bash script. It's a MVP approach that succeeded.
It seems to be the best package manager as it also includes a way to manage node versions.
It avoid to rely on both npm and nvm for example.
Find unused dependencies: npx depcheck
Or install the package and run the command.
There is also npm-check that checks for outdated, incorrect, and unused dependencies.
Authentication middleware framework
Ok so you can write Rust for Node applications ? :D
Okay so these guys built a WebAssembly based virtual machine to run x86 binaries. SO you can run ANY type of programs in the browser !
An faster alternative to nvm !
Pour les projets perso 💚