Socket
Socket
Sign inDemoInstall

emp

Package Overview
Dependencies
12
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    emp

Check and empty a directory


Version published
Maintainers
1
Install size
174 kB
Created

Readme

Source

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 } = require('emp')

// async version
emp(dirPath).then()
// sync version
empSync(dirPath)

/**
 * Check if a dir is empty
 */

const { isEmpty, isEmptySync } = require('emp')

// async version
isEmpty(dirPath).then(result => {})
// sync version
isEmptySync(dirPath) // true or false

API Documentation

A little bit setup for demonstration:

const { emp, empSync, isEmpty, isEmptySync } = require('emp')
const dirPath = 'path/to/folder'
Empty a directory
// async
emp(path, removeDir).then()
// sync
empSync(path, removeDir)

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 to false(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
isEmpty(path).then(result => {})
// sync
isEmptySync(path) // 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

Keywords

FAQs

Last updated on 06 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc