Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tmp-promise

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tmp-promise

The tmp package with promises support and disposers.

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is tmp-promise?

The tmp-promise npm package provides a simple and intuitive way to create temporary files and directories in a Node.js environment with promise-based asynchronous control flow. It is a wrapper around the 'tmp' package, offering a promise-based API instead of a callback-based one, which can be more convenient when using async/await syntax.

What are tmp-promise's main functionalities?

Create a temporary file

This feature allows you to create a temporary file. The 'file' method returns a promise that resolves with an object containing the path to the file and a cleanup function to delete the file when you're done with it.

const tmp = require('tmp-promise');

(async () => {
  const file = await tmp.file();
  console.log('File path:', file.path);
  await file.cleanup();
})();

Create a temporary directory

This feature allows you to create a temporary directory. The 'dir' method returns a promise that resolves with an object containing the path to the directory and a cleanup function to remove the directory when no longer needed.

const tmp = require('tmp-promise');

(async () => {
  const dir = await tmp.dir();
  console.log('Directory path:', dir.path);
  await dir.cleanup();
})();

Custom options for file/directory creation

This feature allows you to specify custom options such as file prefix, postfix, and other options supported by the 'tmp' package when creating a temporary file or directory.

const tmp = require('tmp-promise');

(async () => {
  const fileWithOpts = await tmp.file({ prefix: 'myPrefix_', postfix: '.txt' });
  console.log('File path with options:', fileWithOpts.path);
  await fileWithOpts.cleanup();
})();

Other packages similar to tmp-promise

Keywords

FAQs

Package last updated on 06 Nov 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