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

temp-write

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temp-write - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

18

index.js

@@ -7,2 +7,3 @@ 'use strict';

var uuid = require('uuid');
var pify = require('pify');
var TMP_DIR = osTmpdir();

@@ -14,15 +15,12 @@

module.exports = function (str, filepath, cb) {
if (typeof filepath === 'function') {
cb = filepath;
filepath = null;
}
module.exports = function (str, filepath) {
var fullpath = tempfile(filepath);
mkdirp(path.dirname(fullpath), function (err) {
fs.writeFile(fullpath, str, function (err) {
cb(err, fullpath);
return pify(mkdirp)(path.dirname(fullpath))
.then(function () {
return pify(fs.writeFile)(fullpath, str);
})
.then(function () {
return fullpath;
});
});
};

@@ -29,0 +27,0 @@

{
"name": "temp-write",
"version": "1.1.2",
"version": "2.0.0",
"description": "Write string/buffer to a random temp file",

@@ -10,3 +10,3 @@ "license": "MIT",

"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
"url": "sindresorhus.com"
},

@@ -17,3 +17,3 @@ "engines": {

"scripts": {
"test": "mocha"
"test": "xo && ava"
},

@@ -42,7 +42,14 @@ "files": [

"os-tmpdir": "^1.0.0",
"pify": "^2.2.0",
"uuid": "^2.0.1"
},
"devDependencies": {
"mocha": "*"
"ava": "*",
"xo": "*"
},
"xo": {
"ignores": [
"test.js"
]
}
}

@@ -8,3 +8,3 @@ # temp-write [![Build Status](https://travis-ci.org/sindresorhus/temp-write.svg?branch=master)](https://travis-ci.org/sindresorhus/temp-write)

```sh
```
$ npm install --save temp-write

@@ -17,17 +17,17 @@ ```

```js
var fs = require('fs');
var tempWrite = require('temp-write');
const fs = require('fs');
const tempWrite = require('temp-write');
var filepath = tempWrite.sync('unicorn');
//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b
const filepath = tempWrite.sync('unicorn');
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b'
fs.readFileSync(filepath, 'utf8');
//=> unicorn
//=> 'unicorn'
tempWrite.sync('unicorn', 'pony.png');
//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png'
tempWrite.sync('unicorn', 'rainbow/cake/pony.png');
//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png
//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png'
```

@@ -38,7 +38,12 @@

### tempWrite(input, [filepath], callback)
### tempWrite(input, [filepath])
Returns a promise that resolves to the filepath of the temp file.
### tempWrite.sync(input, [filepath])
Returns the filepath of the temp file.
#### input
*Required*
Type: `string`, `buffer`

@@ -53,15 +58,10 @@

#### callback(err, filepath)
*Required*
Type: `function`
## Related
### tempWrite.sync(input)
- [tempfile](https://github.com/sindresorhus/tempfile) - Get a random temp file path
Type: `string`, `buffer`
Returns: the filepath
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
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