🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

temp

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
n

temp

Temporary files and directories

0.9.4
latest
100

Supply Chain Security

100

Vulnerability

99

Quality

79

Maintenance

100

License

Version published
Weekly downloads
7.2M
6.63%
Maintainers
2
Weekly downloads
 
Created
Issues
7

What is temp?

The 'temp' npm package is designed to handle temporary files and directories in a Node.js environment. It provides utilities to create, manage, and clean up temporary files and directories, ensuring that they are properly removed when no longer needed.

What are temp's main functionalities?

Creating a Temporary File

This feature allows you to create a temporary file with a specified prefix. The callback provides information about the file, including its path and file descriptor.

const temp = require('temp');
temp.open('myprefix', function(err, info) {
  if (!err) {
    console.log('File: ', info.path);
    console.log('File descriptor: ', info.fd);
  }
});

Creating a Temporary Directory

This feature allows you to create a temporary directory with a specified prefix. The callback provides the path to the created directory.

const temp = require('temp');
temp.mkdir('myprefix', function(err, dirPath) {
  if (!err) {
    console.log('Directory: ', dirPath);
  }
});

Automatic Cleanup

This feature enables automatic cleanup of temporary files and directories when the process exits. By calling `temp.track()`, you ensure that all temporary files and directories are removed when they are no longer needed.

const temp = require('temp');
temp.track();
temp.open('myprefix', function(err, info) {
  if (!err) {
    console.log('File: ', info.path);
    console.log('File descriptor: ', info.fd);
  }
});

Other packages similar to temp

FAQs

Package last updated on 10 Nov 2020

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