Socket
Socket
Sign inDemoInstall

create-temp-file

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

create-temp-file

Creates a temporary file, returns a write stream, a path, and cleanup functions


Version published
Maintainers
1
Created
Source

create-temp-file

A tiny node module that creates a temporary file, returns a write stream, a path, and cleanup functions

Build Status

example

var createTempFile = require('create-temp-file')

var ws = createTempFile()
process.stdin.pipe(ws)

process.on('exit', ws.cleanupSync)

api

var createTempFile = require('create-temp-file')

var ws = createTempFile([extension])

You can set the file extension for the temp file, or don't set 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. Like fs.unlink
  • ws.cleanupSync deletes the temporary file synchronously. Like fs.unlinkSync

If an error occurs in ws.cleanup() or ws.cleanupSync(), the error will be emitted. Catch any errors like this:

ws.on('error', function (e) {
	throw e
})

install

With npm do:

npm install create-temp-file

license

VOL

Keywords

FAQs

Package last updated on 22 Oct 2018

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