https://github.com/beyondjs/finder
A versatile file finder and watcher utility for Node.js applications. This package provides powerful tools for searching, filtering, and monitoring files and directories, including support for configurable finders and collections. Ideal for projects requiring advanced file management and real-time file system monitoring capabilities.
https://github.com/beyondjs/finder
Last synced: about 1 year ago
JSON representation
A versatile file finder and watcher utility for Node.js applications. This package provides powerful tools for searching, filtering, and monitoring files and directories, including support for configurable finders and collections. Ideal for projects requiring advanced file management and real-time file system monitoring capabilities.
- Host: GitHub
- URL: https://github.com/beyondjs/finder
- Owner: beyondjs
- License: mit
- Created: 2022-12-01T13:31:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-31T11:32:38.000Z (over 1 year ago)
- Last Synced: 2025-03-24T17:49:27.201Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @beyond-js/finder
A powerful and flexible file finder utility for Node.js applications.
## Installation
```bash
npm install @beyond-js/finder
```
## Usage
```javascript
const { Finder, ConfigurableFinder, FinderCollection } = require('@beyond-js/finder');
// Basic usage with Finder
const finder = new Finder('/path/to/search', {
includes: ['*.js', 'src/**/*.ts'],
excludes: ['node_modules', 'dist'],
filename: 'config',
extname: ['.json', '.yaml']
});
finder.on('file.change', file => {
console.log('File changed:', file);
});
// Using ConfigurableFinder
const configurableFinder = new ConfigurableFinder(watcherInstance);
configurableFinder.configure('/path/to/search', {
includes: ['**/*.js'],
excludes: ['node_modules']
});
// Using FinderCollection
class MyCollection extends FinderCollection {
constructor(watcher) {
super(watcher, MyItemClass);
}
}
const collection = new MyCollection(watcherInstance);
collection.configure('/path/to/search', {
includes: ['**/*.config.js']
});
collection.ready.then(() => {
for (const [key, item] of collection) {
console.log(key, item);
}
});
```
## API
### Finder
- `constructor(path: string, specs: object)`
- `on(event: string, callback: function)`: Listen for file changes
### ConfigurableFinder
- `constructor(watcher: object)`
- `configure(path: string, specs: object)`: Set up the finder configuration
### FinderCollection
- `constructor(watcher: object, Item: class)`
- `configure(path: string, specs: object)`: Set up the collection configuration
- `ready`: Promise that resolves when the collection is ready
## Features
- Flexible file searching with include/exclude patterns
- File watching capabilities
- Configurable finder for dynamic search configurations
- Collection support for managing groups of found items
- Asynchronous processing with Promise support
## License
MIT © [[BeyondJS](https://beyondjs)]