# new-filename

> Generating a new filename like 'basename (1).ext' like normal application

Latest version **2.0.1** (published 2019-08-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install new-filename
pnpm add new-filename
yarn add new-filename
bun add new-filename
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2019-08-16 |
| First published | 2017-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alphakevin |
| Maintainers | alphakevin |
| Keywords | new, filename, unique, untitled, sequence |

## Links

- npm: https://www.npmjs.com/package/new-filename
- Repository: https://github.com/alphakevin/new-filename
- Homepage: https://github.com/alphakevin/new-filename#readme
- Issues: https://github.com/alphakevin/new-filename/issues
- npm.io page: https://npm.io/package/new-filename

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2019-08-16
- 2.0.0 — 2019-01-14
- 1.0.1 — 2017-12-11

## README

# new-filename

Generating a new filename like 'basename (1).ext' without conflicting with existing ones.

## Install

```bash
npm install new-filename
# or
yarn add new-filename
```

## Usage

```typescript
/**
 * 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
 */
getNewFilename(list: string[]]), name: string): string
```

### Example

```javascript
import getNewFilename from 'new-filename';

const newName = getNewFilename([
  'untitled.txt',
  'untitled (2).txt',
  'file3.txt',
  'file4.java',
], 'untitled.txt');

console.log(newName);
// => 'untitled (3).txt'
```

## Tests

```bash
npm test
```
## Similar Packages

[unused-filename](https://github.com/sindresorhus/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).

---
_Source: https://npm.io/package/new-filename · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
