guilmour 4d48d7b520 Version 0.1 | 6 роки тому | |
---|---|---|
.. | ||
index.js | 6 роки тому | |
license | 6 роки тому | |
readme.md | 6 роки тому |
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