emp
Remove all the stuff inside a directory Synchronously or Asynchronously
Installation
npm install emp
Usage
const dirPath = 'path/to/folder' /** * Removes everything inside the folder */ const empSync emp = // async version// sync version /** * Check if a dir is empty */ const isEmpty isEmptySync = // async version// sync version // true or false
API Documentation
A little bit setup for demonstration:
const emp empSync isEmpty isEmptySync = const dirPath = 'path/to/folder'
Empty a directory
// async// sync
where
- path is the location of the directory
- removeDir is a
Boolean
flag tells whether you want to remove the current directory or just to empty its content, default tofalse
(not to remove)
If there's nothing at the given path, nothing happens(No error will be thrown)
Check if a directory is empty
// async// sync // returns true or false
where
- path is the location of the directory
Result is either true
or false
. If the path is not a directory, error will be thrown