Unique file name with streams support
npm install fsu

Unique filenames with streams support
Checking if a file exists before opening is an anti-pattern that leaves you vulnerable to race conditions: another process can remove the file between the calls to fs.exists() and fs.open(). This functions doesn't use fs.exists functionality. If file doesn't exist this will work like usual fs module methods
npm install fsu``js
const fsu = require('fsu');
const { fd, path } = await fsu.openUnique("text{_###}.txt");
`
`js
const fsu = require('fsu');
const path = await fsu.writeFileUnique("text{_###}.txt", "test");
`
`js`
const fsu = require('fsu');
let stream = fsu.createWriteStreamUnique("text{_###}.txt");
property that contains a new pathforce path creation
Add force = true to options, and it will recursively create directories if they are not exist.pattern
You must use {#} pattern in filename and path. All # characters will be change with counter for existing files. Number of # means padding for unique counter. With no pattern in the filename works as usual 'fs' module.If we run second example several times filenames will be
`
text.txt
text_001.txt
text_002.txt
``
License: MIT