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

tmp

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tmp - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

4

package.json
{
"name": "tmp",
"version": "0.0.9",
"version": "0.0.10",
"description": "Temporary file and directory creator",

@@ -33,3 +33,3 @@ "author": "KARASZI István <github@spam.raszi.hu> (http://raszi.hu/)",

"engines": {
"node": "0.4.10"
"node": ">=0.4.10"
},

@@ -36,0 +36,0 @@

@@ -24,21 +24,31 @@ # Tmp

var tmp = require('tmp');
Simple temporary file creation, the file will be unlinked on process exit.
tmp.file(function _tempFileCreated(err, path, fd) {
if (err) throw err;
```javascript
var tmp = require('tmp');
console.log("File: ", path);
console.log("Filedescriptor: ", fd);
});
tmp.file(function _tempFileCreated(err, path, fd) {
if (err) throw err;
console.log("File: ", path);
console.log("Filedescriptor: ", fd);
});
```
### Directory creation
var tmp = require('tmp');
Simple temporary directory creation, it will be removed on process exit.
tmp.dir(function _tempDirCreated(err, path) {
if (err) throw err;
If the directory still contains items on process exit, then it won't be removed.
console.log("Dir: ", path);
});
```javascript
var tmp = require('tmp');
tmp.dir(function _tempDirCreated(err, path) {
if (err) throw err;
console.log("Dir: ", path);
});
```
## Advanced usage

@@ -48,28 +58,44 @@

var tmp = require('tmp');
Creates a file with mode `0644`, prefix will be `prefix-` and postfix will be `.txt`.
tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) {
if (err) throw err;
```javascript
var tmp = require('tmp');
console.log("File: ", path);
console.log("Filedescriptor: ", fd);
});
tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) {
if (err) throw err;
console.log("File: ", path);
console.log("Filedescriptor: ", fd);
});
```
### Directory creation
tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) {
if (err) throw err;
Creates a directory with mode `0755`, prefix will be `myTmpDir_`.
console.log("Dir: ", path);
});
```javascript
var tmp = require('tmp');
tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) {
if (err) throw err;
console.log("Dir: ", path);
});
```
### mkstemps like
tmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) {
iff (err) throw err;
Creates a new temporary directory with mode `0700` and filename like `/tmp/tmp-nk2J1u`.
console.log("Dir: ", path);
});
```javascript
var tmp = require('tmp');
tmp.dir({ template: '/tmp/tmp-XXXXXX' }, function _tempDirCreated(err, path) {
if (err) throw err;
console.log("Dir: ", path);
});
```
## Options

@@ -80,3 +106,3 @@

* `mode`: the file mode to create with it fallbacks to `0600` on file creation and `0700` on directory creation
* `prefix`: the optional prefix, fallback to `tmp-` if not provided
* `prefix`: the optional prefix, fallbacks to `tmp-` if not provided
* `postfix`: the optional postfix, fallbacks to `.tmp` on file creation

@@ -83,0 +109,0 @@ * `template`: [`mkstemps`][3] like filename template, no default

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