https://github.com/rumkin/batch-match
File system glob-like router
https://github.com/rumkin/batch-match
Last synced: 8 months ago
JSON representation
File system glob-like router
- Host: GitHub
- URL: https://github.com/rumkin/batch-match
- Owner: rumkin
- Created: 2016-06-07T16:24:48.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-08T07:47:24.000Z (about 10 years ago)
- Last Synced: 2025-06-13T21:46:13.511Z (12 months ago)
- Language: JavaScript
- Homepage: http://npmjs.org/package/batch-match
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Batch Match
Is a file pattern matcher like glob built for routing. It returns path and
wildcard values separately.
##
Install
```
npm i batch-match
```
## Example
For example we want to select each file which ends with `-service.js` and use everything before prefix as name (eg. search, file and task).
Example directory:
```
.
|-- search-service.js
|-- file-service.js
`-- task-service.js
```
Code to find files with routes:
```javascript
const bm = require('batch-match');
bm.search('./*-service.js')
.then(files => {
console.log(files); // -> [['search-service.js', 'search'], ['file-service.js', 'file'], ...]
});
```
## Cli util
There is cli util to find matches and output it to stdio in row mode:
```shell
batch-match '*-service.js'
```
Will output:
```
search-service.js search
file-service.js file
task-service.js task
```