guilmour 4d48d7b520 Version 0.1 | 6 rokov pred | |
---|---|---|
.. | ||
index.js | 6 rokov pred | |
license | 6 rokov pred | |
readme.md | 6 rokov pred |
Get an unused filename by appending a number if it exists:
file.txt
→file (1).txt
Useful for safely writing, copying, moving files without overwriting existing files.
$ npm install --save unused-filename
.
├── rainbow (1).txt
├── rainbow.txt
└── unicorn.txt
const unusedFilename = require('unused-filename');
unusedFilename('rainbow.txt').then(filename => {
console.log(filename);
//=> 'rainbow (2).txt'
});
Returns a Promise<string>
.
Returns a string
.
Type: string
MIT © Sindre Sorhus