unique-temp-path
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

unique-temp-path

Create temporary directory/file names that are unique

Requirements

  • Node.js ≥ 8.9.0

Why?

There're always files/directories being added to temporary directory. There's a chance, albeit rather small, that a random string would collapse with them. For this reason, it is necessary to check whether that random name exists.

Usage

Function Signature

declare function tempPath (prefix?: string, suffix?: string): string

Example

import tempPath from 'unique-temp-path'
import fs from 'fs'
const filename = tempPath('myprefix', 'mysuffix')
fs.writeFileSync(filename, 'This is temporary')

A file with name of myprefix{{random string}}mysuffix would be created.

License

MIT © Hoàng Văn Khải

Readme

Keywords

Package Sidebar

Install

npm i unique-temp-path

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

2.59 kB

Total Files

5

Last publish

Collaborators

  • khai96_