Package Exports
- create-temp-file
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-temp-file) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
create-temp-file
Creates a temporary file, returns a write stream, a path, and cleanup functions
example
var createFile = require('create-temp-file')()
var ws = createFile()
process.stdin.pipe(ws)
process.on('exit', ws.cleanupSync)
api
var CreateTempFile = require('create-temp-file')
var createFile = CreateTempFile([pathGenerator])
pathGenerator
is a function that returns a path. Defaults to tempfile
.
var ws = createFile([opts])
opts
is an object that is passed into pathGenerator
. By default, you can pass in an extension; e.g. '.png'
.
ws
is a write stream to the new temporary file with the following properties:
ws.path
is the absolute path to the temporary file. E.g.'/tmp/b285e724-226c-11e5-9981-82bd40254040.png'
ws.cleanup([cb])
deletes the temporary file. Likefs.unlink
.ws.cleanupSync
deletes the temporary file synchronously. Likefs.unlinkSync
.
If an error occurs in ws.cleanup()
or ws.cleanupSync()
, the error will be emitted.
install
With npm do:
npm install create-temp-file