refactor(file): improve file.ts code structure #574
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #547
Applied changes based on Issue #547.
I’ve refactored src/file/file.ts to improve readability, modularity, and performance while preserving all existing behavior. Key changes include:
1. Streaming-based hashing
Replaced the in‑memory
fs.readFile
approach with a streaming hash, greatly reducing peak memory usage for large files:【F:src/file/file.ts†L22-L37】
2. Consolidated and cleaned up JSDoc
Removed multiple redundant/empty doc‑blocks and standardized the remaining comments with clear parameter and return annotations:
【F:src/file/file.ts†L39-L47】
【F:src/file/file.ts†L48-L56】
【F:src/file/file.ts†L95-L104】
3. Simplified globbing & ignore logic
Kept using
ignore
for .gitignore semantics, but consolidated the default and workspace.gitignore
rules in one place, then applied them directly to the fast‑glob result:【F:src/file/file.ts†L60-L64】
4. Batch‑based concurrency for hashing
Replaced the manual worker‑loop with a simpler batching pattern that processes up to N files in parallel (where N = CPU count):
【F:src/file/file.ts†L67-L94】
These focused changes remove noise, streamline the flow, and boost performance for large workspaces. Let me know if you’d like any further tweaks!