Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zebrajaeger/filewalker
https://github.com/zebrajaeger/filewalker
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zebrajaeger/filewalker
- Owner: zebrajaeger
- License: isc
- Created: 2020-08-29T06:08:31.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-13T08:52:24.000Z (about 4 years ago)
- Last Synced: 2024-10-12T22:41:55.910Z (24 days ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Filewalker
Simple synchron filewalker for node and local filesystem.
## Install
```bash
npm install --save @zebrajaeger/filewalker
```
```bash
yarn add @zebrajaeger/filewalker
```## Examples
### Basic
```javascript
const {FileWalker} = require('@zebrajaeger/filewalker');// create instance
const fileWalker = new FileWalker('/media/l/Seagate');// start (returns Promise so we call '.then()')
fileWalker.walk((f) => console.log('File', f), (d)=> console.log('Directory', d)).then();
```returns i.E.
```bash
[...]Directory { abs: '/media/l/Seagate/Seagate', rel: 'Seagate' }
Directory {
abs: '/media/l/Seagate/Seagate/Registration',
rel: 'Seagate/Registration'
}
File {
abs: '/media/l/Seagate/Seagate/Registration/SerialNumber.xml',
rel: 'Seagate/Registration/SerialNumber.xml'
}[...]
```### Start deeper but get the relative path to root directory.
```javascript
const {FileWalker} = require('@zebrajaeger/filewalker');const fileWalker = new FileWalker('/media/l/Seagate');
fileWalker.walk(
(f) => console.log('File', f),
(d)=> console.log('Directory', d),
{relStart: 'Seagate'}).then();
```returns i.E.
```bash```
## Example with files and directories
```javascript
const {FileWalker} = require('@zebrajaeger/filewalker');walkSync(
'.',
(file) => console.log('File:', file),
(dir) => console.log('Directory:', dir)
).then();
```## Example files only
```javascript
const {FileWalker} = require('@zebrajaeger/filewalker');walkSync(
'.',
(file) => console.log('File:', file)
).then();
```## Example directories only
```javascript
const {FileWalker} = require('@zebrajaeger/filewalker');walkSync(
'.',
null,
(dir) => console.log('Directory:', dir)
).then();
```