# ideal-filename

> Gets the ideal filename according to the given one.

Latest version **0.2.0** (published 2023-06-03) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-06-03 |
| First published | 2018-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | A-yon Lee |
| Maintainers | ayonli |
| Keywords | filename, auto-increment |

## Links

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

## Recent versions

- 0.2.0 (latest) — 2023-06-03
- 0.1.3 — 2019-07-18
- 0.1.2 — 2018-05-23
- 0.1.1 — 2018-05-04
- 0.1.0 — 2018-05-03

## README

# Ideal-Filename

**Gets the ideal filename according to the given one.**

## API

- `idealFilename(filename: string, extname:? string): Promise<string>`
    - `filename` The original filename.
    - `extname` Sets a specified extension name.
- `idealFilename(filename: string, callback: (err: Error, filename: string) => void): void;`
- `idealFilename(filename: string, extname: string, callback: (err: Error, filename: string) => void): void`

This function will check if the given filename already exists, if not, the 
given filename will be returned, otherwise increase the filename with a number 
appended to the basename (before `extname`).

It's better to always pass the `filename` an absolute path, and the separators
will always be converted to platform-specific ones.

## Example

```javascript
import idealFilename from "ideal-filename";

idealFilename("index.js").then(filename => {
    console.log(filename); // => index (1).js
});

// Or
(async() => {
    var filename = await idealFilename("index.js");
    console.log(filename);
})();

// Or 
idealFilename("index.js", filename => {
    console.log(filename);
});
```

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