# get-duplicate-name

> Obtain the corresponding name when duplicating an element of a list

Latest version **1.0.1** (published 2023-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-duplicate-name
pnpm add get-duplicate-name
yarn add get-duplicate-name
bun add get-duplicate-name
```

## 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 | 1.0.1 |
| Published | 2023-07-04 |
| First published | 2023-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Redradix |
| Maintainers | redradix |

## Links

- npm: https://www.npmjs.com/package/get-duplicate-name
- Repository: https://github.com/redradix/get-duplicate-name
- Homepage: https://github.com/redradix/get-duplicate-name#readme
- Issues: https://github.com/redradix/get-duplicate-name/issues
- npm.io page: https://npm.io/package/get-duplicate-name

## Recent versions

- 1.0.1 (latest) — 2023-07-04
- 1.0.0 — 2023-07-04

## README

<!--
SPDX-FileCopyrightText: 2023 Redradix - development@redradix.com

SPDX-License-Identifier: MIT
-->

# get-duplicate-name

Returns the corresponding name when duplicating an element of a list of elements. The result will be a string with the original name, the string provided to identify a duplicate (e.g. "Copy") and, if duplicates already exist, a number in brackets starting with 2. Example: "Element Copy (4)".

## Installation

```
npm install --save get-duplicate-name
```

or

```
yarn add get-duplicate-name
```

## Usage

```js
import getDuplicateName from 'get-duplicate-name'
// or const getDuplicateName = require('get-duplicate-name')

const elements = [
  { name: 'Element' },
  { name: 'Element Copy' },
  { name: 'Element Copy (1)' },
  { name: 'Element Copy (2)' },
  { name: 'Element Copy (3)' },
]
const duplicateString = 'Copy'

const result = getDuplicateName(elements, elements[2].name, duplicateString)
// 'Element Copy (4)'
```

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