guilmour 4d48d7b520 Version 0.1 | 6 tahun lalu | |
---|---|---|
.. | ||
index.js | 6 tahun lalu | |
license | 6 tahun lalu | |
readme.md | 6 tahun lalu |
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