# create-temp-file

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

Latest version **2.0.0** (published 2018-10-22) · VOL license · 0 weekly downloads

## Install

```sh
npm install create-temp-file
pnpm add create-temp-file
yarn add create-temp-file
bun add create-temp-file
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-10-22 |
| First published | 2014-12-26 |
| Weekly downloads | 0 |
| License | VOL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Joseph Dykstra |
| Maintainers | artskydj |
| Keywords | stream, temp, tmp, write |

## Links

- npm: https://www.npmjs.com/package/create-temp-file
- Repository: https://github.com/ArtskydJ/create-temp-file
- Issues: https://github.com/ArtskydJ/create-temp-file/issues
- npm.io page: https://npm.io/package/create-temp-file

## Dependencies (1)

- [tempfile](https://npm.io/package/tempfile.md) ^1.1.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-10-22
- 1.0.0 — 2015-07-10
- 0.4.2 — 2015-07-10
- 0.4.1 — 2015-07-09
- 0.4.0 — 2015-07-09
- 0.3.1 — 2015-07-04
- 0.3.0 — 2015-07-04
- 0.2.2 — 2015-07-02
- 0.2.1 — 2015-07-02
- 0.2.0 — 2015-07-02
- 0.1.3 — 2015-05-20
- 0.1.2 — 2015-05-18
- 0.1.1 — 2015-01-26
- 0.1.0 — 2014-12-26

## README

create-temp-file
================

> A tiny node module that creates a temporary file, returns a write stream, a path, and cleanup functions

[![Build Status](https://travis-ci.org/ArtskydJ/create-temp-file.svg)](https://travis-ci.org/ArtskydJ/create-temp-file)

# example

```js
var createTempFile = require('create-temp-file')

var ws = createTempFile()
process.stdin.pipe(ws)

process.on('exit', ws.cleanupSync)
```

# api

```js
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](https://nodejs.org/api/fs.html#fs_class_fs_writestream) 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`](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback)
- `ws.cleanupSync` deletes the temporary file synchronously. Like [`fs.unlinkSync`](https://nodejs.org/api/fs.html#fs_fs_unlinksync_path)

If an error occurs in `ws.cleanup()` or `ws.cleanupSync()`, the error will be emitted. Catch any errors like this:

```js
ws.on('error', function (e) {
	throw e
})
```

# install

With [npm](https://nodejs.org/en/download/) do:

    npm install create-temp-file

# license

[VOL](http://veryopenlicense.com/)

---
_Source: https://npm.io/package/create-temp-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
