JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1943
  • Score
    100M100P100Q127044F
  • License MIT

Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.

Package Exports

  • disposable-directory
  • disposable-directory/package
  • disposable-directory/package.json
  • disposable-directory/public/disposableDirectory.js
  • disposable-directory/public/index.js
  • disposable-directory/public/index.mjs

Readme

disposable-directory

npm version CI status

Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.

Setup

To install from npm run:

npm install disposable-directory

Support

  • Linux, macOS.
  • Node.js ^10.17.0 || ^12.0.0 || >= 13.7.0.

API

Table of contents

function disposableDirectory

Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.

Parameter Type Description
callback Function A sync or async callback that receives the temporary directory path.

Returns: Promise<void> — Resolves once the callback is done and the disposable directory is deleted.

Examples

Ways to import.

import { disposableDirectory } from 'disposable-directory';
import disposableDirectory from 'disposable-directory/public/disposableDirectory.js';

Ways to require.

const { disposableDirectory } = require('disposable-directory');
const disposableDirectory = require('disposable-directory/public/disposableDirectory');

How to use a disposable directory.

const { disposableDirectory } = require('disposable-directory');

disposableDirectory(async (directoryPath) => {
  // Use the directory here.
})
  .then(() => {
    // The directory is gone.
  })
  .catch(() => {
    // The directory is gone.
  });