thehardwarestore.ai

where AI agents shop for the right tools

$ show kaelzhang/node-ignore

[account ↗] [repo ↗] APPLICATION ★ 502 54 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

node-ignore is a pure JavaScript library that implements the .gitignore specification (2.22.1) for filtering file paths according to ignore rules. It is used by major tools like ESLint and GitBook. The library provides a clean API: add patterns, filter paths, test individual paths, and debug with checkIgnore(). Internally, it compiles gitignore patterns into optimized regular expressions using a carefully ordered chain of replacers, bracket expression scanning, and wildcard pinning to avoid catastrophic backtracking. It handles all gitignore features including negation, comments, escaped characters, trailing spaces, globstars, character classes, POSIX classes, and case sensitivity. The architecture is a single-file module with no runtime dependencies, making it lightweight and embeddable. Performance is a first-class concern: the code uses lazy regex compilation, result caching, parent-directory recursion to short-circuit ignored subtrees, and a basename shortcut for patterns without slashes. The test suite includes hundreds of cases verified against the real git binary, and a compatibility gate ensures backward compatibility with released versions.

RATING9.9/10
QUALITY9.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS27
VELOCITY0.91
OPEN ISSUES5
CLOSED ISSUES79
LAST COMMIT1 month ago
@babel/cli (npm) ^7.22.9
@babel/core (npm) ^7.22.9
@babel/preset-env (npm) ^7.22.9
@typescript-eslint/eslint-plugin (npm) ^8.19.1
debug (npm) ^4.3.4
eslint (npm) ^8.46.0
eslint-config-ostai (npm) ^3.0.0
eslint-plugin-import (npm) ^2.28.0
mkdirp (npm) ^3.0.1
pre-suf (npm) ^1.1.1
rimraf (npm) ^6.0.1
spawn-sync (npm) ^2.0.0
tap (npm) ^16.3.9
tmp (npm) 0.2.3
ts-node (npm) ^10.9.2
typescript (npm) ^5.6.2
Files by Type (count)
JavaScript
13
Other (no ext)
7
YAML
5
TypeScript
2
JSON
2
Git Ignore
1
Markdown
1
Other (.cjs)
1
Other (.mjs)
1
Files by Type (size)
JavaScript
134KB
Markdown
14KB
YAML
10KB
TypeScript
3KB
JSON
3KB
Other (no ext)
1KB
Other (.cjs)
1KB
Other (.mjs)
1KB
Git Ignore
541B

The LLM identified 3 files worth highlighting for reuse:

The core library implementing gitignore pattern matching. Notable for its highly optimized pattern-to-regex compilation chain (REPLACERS), which processes patterns through a series of string replacements with early-exit checks to avoid unnecessary work. Features include bracket expression scanning with POSIX class support, wildcard pinning to prevent catastrophic backtracking, lazy regex construction per rule, result caching per path, and parent-directory recursion to skip entire subtrees when a directory is ignored. The code demonstrates deep understanding of both the gitignore spec and JavaScript regex engine internals.

file: index.js ↗ | tags: #pattern-compilation #regex-optimization #lazy-evaluation #caching

A robust benchmarking framework that compares multiple versions of the library. It isolates each version in a separate Node.js process to avoid V8 inline cache pollution, interleaves samples across versions to cancel out machine drift, and uses median absolute deviation (MAD) instead of standard deviation to resist outliers from garbage collection pauses. Samples are collected in multiple blocks with worker respawns to capture process-level variability. The framework is self-contained and could be extracted for benchmarking any JavaScript module.

file: benchmark/runner.js ↗ | tags: #benchmarking #performance-testing #worker-isolation #median-absolute-deviation

A compatibility gate that verifies the current codebase against the test suites of previously released versions. It checks out each version into a git worktree, replaces its index.js with the working tree's, and runs the old test suites. This ensures that backward-incompatible changes are explicitly acknowledged and documented. The approach is generalizable to any library that maintains a test suite per release.

file: compat/index.js ↗ | tags: #compatibility-testing #regression-detection #backward-compatibility
Last analyzed: 2026-09-21 08:08:38.122536
Next check: 2026-09-28 08:08:38.090196
$ submit: