JavaScript
You're viewing a free preview. Sign in free to read every script.
Why this exists Two file tasks come up constantly: housekeeping (delete old logs) and analysis (count things in a big log). Node's promise based file API handles the first cleanly, and streams handle the second without…
Files with fs/promises: Log Cleanup and Streaming Large Log Files
Walk a directory tree with an async generator, delete files older than a cutoff with a dry run and safety guards, and process very large log files line by line with readline streams instead of loading them into memory.
Sign in free to read this script, along with the rest of the library.
Sign in free