Détail du package

unique-temp-path

khai96_23MIT0.1.3

Create temporary directory/file names that are unique

temp, unique

readme

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