# nodupes

> Prevent duplicate names by appending an incremented suffix.

Latest version **0.1.0** (published 2013-11-11) · 0 weekly downloads

## Install

```sh
npm install nodupes
pnpm add nodupes
yarn add nodupes
bun add nodupes
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2013-11-11 |
| First published | 2013-11-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pierre Bertet |
| Maintainers | bpierre |

## Links

- npm: https://www.npmjs.com/package/nodupes
- Repository: https://github.com/bpierre/nodupes
- Issues: https://github.com/bpierre/nodupes/issues
- npm.io page: https://npm.io/package/nodupes

## Recent versions

- 0.1.0 (latest) — 2013-11-11
- 0.0.0 — 2013-11-11

## README

# nodupes

Prevent duplicate names by appending an incremented suffix.

## Examples

### example/nodupes.js

```javascript
var nodupes = require('nodupes')();
var names = ['name', 'name', 'othername', 'name', 'othername'];
names.forEach(function(name) {
  console.log( nodupes(name) );
});
```

Output:

```shell
$ node example/nodupes.js
name
name-2
othername
name-3
othername-2
```

## Usage

```javascript
var nodupes = require('nodupes');
```

### var nd = nodupes(options)

Call `nodupes()` to get a new nodupes function, with its own index and options.

Options:

```javascript
var options = {
  names: {},           // Load a pre-existing names index (see `nd.getNames()`).
  suffixFirst: false,  // Add a suffix on the first appearance of a name.
  separator: '-'       // Change the suffix separator.
};
```

### nd('name')

Returns the name with an appended suffix if needed.

### nd.getNames()

Returns the names index that you can pass to `nodupes()` with `options.names`.

## Installation

```shell
$ npm install nodupes
```

## License

[MIT](http://pierre.mit-license.org/)

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