New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emp

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emp

Check and empty a directory

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 06 Apr 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc