{"library":"readdir-glob","title":"readdir-glob: Streaming Recursive Directory Reader with Glob Filtering","description":"readdir-glob provides a memory-efficient, recursive file system directory reader with a streaming API, designed as an alternative to `node-glob` for scenarios requiring constant memory usage regardless of the file system size or the number of matched files. It leverages the `minimatch` library for glob pattern filtering. The current stable version is `3.0.0`, which requires Node.js 18 or later. The library ships with TypeScript types since v2.0.0 and supports both CommonJS and ESM. Its primary differentiator is its low, constant memory footprint, making it suitable for processing very large file systems where other glob libraries might exhaust memory. Releases appear to be driven by Node.js version updates and dependency security patches, with major versions aligning with Node.js LTS cycles.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install readdir-glob"],"cli":null},"imports":["import readdirGlob from 'readdir-glob';","const readdirGlob = require('readdir-glob');","import type { ReaddirGlobOptions, Match } from 'readdir-glob';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import readdirGlob from 'readdir-glob';\nimport path from 'path';\n\nconst rootDir = process.env.ROOT_DIR ?? '.'; // Specify a root directory or use current\nconst globber = readdirGlob(rootDir, { pattern: '**/*.js', ignore: 'node_modules/**', stat: true });\n\nconsole.log(`Searching for .js files in '${rootDir}' (excluding node_modules)...`);\n\nglobber.on('match', match => {\n    // match.relative: relative path of the matched file\n    // match.absolute: absolute path of the matched file\n    // match.stat: stat of the matched file (only if stat:true option is used)\n    console.log(`Found: ${match.relative} (Absolute: ${match.absolute})`);\n});\n\nglobber.on('error', err => {\n    console.error('Fatal error during globbing:', err);\n});\n\nglobber.on('end', () => {\n    console.log('File search completed.');\n});\n\n// Example of pausing and resuming the search\nsetTimeout(() => {\n  if (!globber.paused) {\n    globber.pause();\n    console.log('Search paused for 2 seconds.');\n    setTimeout(() => {\n      globber.resume();\n      console.log('Search resumed.');\n    }, 2000);\n  }\n}, 1000);\n","lang":"typescript","description":"This quickstart demonstrates how to initialize `readdir-glob` to find all `.js` files recursively within a specified root directory, excluding `node_modules`, and streaming the results. It also shows basic error handling and how to use the `pause` and `resume` methods.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}