Cheatsheet collection for go, rust, python, shell and javascript.


Javascript: Walk directory recursively.

const fs = require("fs");
const path = require("path");

async function* walk(dir) {
    for await (const d of await fs.promises.opendir(dir)) {
        const entry = path.join(dir, d.name);
        if (d.isDirectory()) yield* walk(entry);
        else if (d.isFile()) yield entry;

// Then, use it with a simple async for loop
async function main() {
    const dir = "."
    for await (const p of walk(dir))