Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scrwdrv/recurdir
recurdir is a lightweight package written in typescript that allows you to make/remove directories easily.
https://github.com/scrwdrv/recurdir
directory filesystem javascript node promise recursive typescript
Last synced: about 1 month ago
JSON representation
recurdir is a lightweight package written in typescript that allows you to make/remove directories easily.
- Host: GitHub
- URL: https://github.com/scrwdrv/recurdir
- Owner: scrwdrv
- License: mit
- Created: 2019-12-22T08:09:52.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T05:23:57.000Z (almost 5 years ago)
- Last Synced: 2024-09-23T12:38:35.857Z (about 2 months ago)
- Topics: directory, filesystem, javascript, node, promise, recursive, typescript
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# recurdir
recurdir is a lightweight package written in typescript that allows you to make/remove directories easily.
## Installation
```sh
npm i recurdir
```## Usage
### rm/mk dir
```js
import * as recurdir from 'recurdir';
//or const recurdir = require('recurdir');//make directory
recurdir.mk('./path/to/dir', (err) => {
if (err) console.log(err)
else console.log('done')
});//remove multiple directories
recurdir.rm(['./path/to/dir', './path/to/dir2'], (err) => {
if (err) console.log(err)
else console.log('done')
});//make multiple directories with promise
recurdir.mk(['./path/to/dir', './path/to/dir2']).then(() => {
console.log('done!')
}).catch((err) => {
console.log(err)
});
```
### stats
```js
recurdir.stats('./node_modules', (err, stats) => {
if (err) return console.log(err);
console.log(stats);
/* output:
{
'@types': {
node: {
'zlib.d.ts': [Stats],
'worker_threads.d.ts': [Stats],
'vm.d.ts': [Stats],
'v8.d.ts': [Stats],
.
.
.
'assert.d.ts': [Stats],
'ts3.2': [Object]
}
}
}
*/
});
```#### With Formatter
```js
recurdir.stats('./node_modules', (err, stats) => {
if (err) return console.log(err);
console.log(stats);
/* output:
{
'@types': {
node: {
'worker_threads.d.ts': 7325,
'zlib.d.ts': 12182,
'vm.d.ts': 4542,
'v8.d.ts': 6927,
.
.
.
'assert.d.ts': 2660,
'ts3.2': [Object]
}
}
}
*/
}, (stats) => {
return stats.size;
});
```