# @m59/use-tmp-dir

> Takes a function and calls it with a path to a temporary directory.

Latest version **3.0.0** (published 2022-05-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @m59/use-tmp-dir
pnpm add @m59/use-tmp-dir
yarn add @m59/use-tmp-dir
bun add @m59/use-tmp-dir
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-05-22 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=14.13.1 |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Johnny Hauser |
| Maintainers | m59 |
| Keywords | tmp, dir, temporary, directory, path, cleanup, functional |

## Links

- npm: https://www.npmjs.com/package/@m59/use-tmp-dir
- Repository: https://github.com/m59peacemaker/node-use-tmp-dir
- Homepage: https://github.com/m59peacemaker/node-use-tmp-dir#readme
- Issues: https://github.com/m59peacemaker/node-use-tmp-dir/issues
- npm.io page: https://npm.io/package/@m59/use-tmp-dir

## Dependencies (1)

- [@m59/disposer](https://npm.io/package/@m59/disposer.md) ^1.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2022-05-22
- 2.0.0 — 2021-08-03
- 1.0.2 — 2020-07-24
- 1.0.1 — 2020-07-24
- 1.0.0 — 2020-07-21
- 0.1.3 — 2019-06-02
- 0.1.2 — 2019-06-02
- 0.1.1 — 2019-06-02
- 0.1.0 — 2019-05-27

## README

# @m59/use-tmp-dir

Takes a function and calls it with a path to a temporary directory. The temporary directory is removed after the function completes, or if the process exits meanwhile.

```node
import { use_tmp_dir } from '@m59/use-tmp-dir'
```

<!--js
import { use_tmp_dir } from './src/index.js'
-->

```js
import { access, writeFile } from 'node:fs/promises'
import { join as join_path } from 'node:path'

const removed_tmp_dir = await use_tmp_dir(
	async tmp_dir => {
		await writeFile(join_path(tmp_dir, 'some-file.txt'), 'some contents')
		return tmp_dir
	}
)

const error = await access(removed_tmp_dir)
	.catch(error => error)
error.code // => 'ENOENT'
```

---
_Source: https://npm.io/package/@m59/use-tmp-dir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
