Package Exports
- disposable-directory
- disposable-directory/disposableDirectory.mjs
- disposable-directory/package.json
Readme
disposable-directory
Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.
Installation
To install with npm, run:
npm install disposable-directoryRequirements
- Operating system:
- Linux
- macOS
- Node.js:
^12.22.0 || ^14.17.0 || >= 16.0.0
API
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 |
DisposableDirectoryCallback | 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/disposableDirectory.mjs";
How to use a disposable directory.
disposableDirectory(async (directoryPath) => { // Use the directory here. }) .then(() => { // The directory is gone. }) .catch(() => { // The directory is gone. });
type DisposableDirectoryCallback
A sync or async callback that receives the temporary directory path.
Type: Function
| Parameter | Type | Description |
|---|---|---|
tempDirPath |
string | Temporary directory path. |
Returns: void | Promise<void>