new-filename
Generating a new filename like 'basename (1).ext' without conflicting with existing ones.
Install
npm install new-filename# or yarn add new-filename
Usage
/** * Generating a new filename to avoid names in the list by adding sequenced number * @param list - Filenames already in use * @param name - New filenames about to use * @returns Generated new filename */getNewFilenamelist: string], name: string): string
Example
; const newName = ; console;// => 'untitled (3).txt'
Tests
npm test
Similar Packages
unused-filename has the same feature, but it operates on the file system, new-filename
gives you a opportunity to get unused filename independent from platform (e.g. on browser).