# incstr

> Increment string or generate sequential string ids

Latest version **1.2.3** (published 2017-11-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2017-11-19 |
| First published | 2017-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | grabantot |
| Maintainers | grabantot |
| Keywords | increment, string, incremental, sequential, id, generator, nextId, incstr, strinc, bruteforce |

## Links

- npm: https://www.npmjs.com/package/incstr
- Repository: https://github.com/grabantot/incstr
- Homepage: https://github.com/grabantot/incstr#readme
- Issues: https://github.com/grabantot/incstr/issues
- npm.io page: https://npm.io/package/incstr

## 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

- 1.2.3 (latest) — 2017-11-19
- 1.2.2 — 2017-11-19
- 1.2.1 — 2017-08-09
- 1.2.0 — 2017-08-09
- 1.1.2 — 2017-07-31
- 1.1.1 — 2017-07-31
- 1.1.0 — 2017-07-31
- 1.0.3 — 2017-07-13
- 1.0.2 — 2017-05-17
- 1.0.1 — 2017-05-13
- 1.0.0 — 2017-05-13

## README

# incstr
Increment strings or generate sequential string ids in node.js or browser

## Usage

### incstr
```
nextStr = incstr(str,
                 [alphabet=incstr.alphabet],
                 [numberlike=incstr.numberlike])
```
- `str` - string to increment;
- `alphabet` - alphabet to use (default `'A..Za..z0..9'`);
- `numberlike` - `'BA'` after `'9'` instead of `'AA'`(default `false`);
- default `alphabet` can be set through `incstr.alphabet`;
- default value for `numberlike` can be set through `incstr.numberlike`;
- works with strings of any length.

### incstr.idGenerator
```
nextId = incstr.idGenerator(options)
id = nextId() // real generator would be too bulky "nextId.next().value"
```
Possible options:
- `options.lastId`;
- `options.alphabet`;
- `options.numberlike`;
- `options.prefix`;
- `options.suffix`.

`lastId` can also be accessed later through `nextId.lastId` property.

Note that `nextId()` is much faster than `incstr()` and safer because it verifies uniqueness of chars in the alphabet.

## Examples
Pass a string to increment using default alphabet:

```
let i = incstr() // "A"
i = incstr(i) // "B"
...
i = incstr(i) // "9"
i = incstr(i) // "AA"
i = incstr(i) // "AB"
```

Pass a string and an alphabet to use:
```
incstr("ccc", "abc") // "aaaa"
incstr("cc", "ab") // throws ('c' is not in alphabet 'ab')
incstr("0", "01") // "1"
incstr("1", "01") // "00", note NOT "10"
incstr("1", "01", true) // "10", numberlike increment
```

Generate ids:

```
const nextId = incstr.idGenerator()
id1 = nextId() // 'A'
id2 = nextId() // 'B'
```

```
const nextId = incstr.idGenerator({alphabet:'ab', prefix:'id_', suffix:''})
nextId() // 'id_a'
nextId() // 'id_b'
nextId() // 'id_aa'
```

```
const nextId = incstr.idGenerator({lastId:'cc', alphabet:'abc', numberlike: true})
id = nextId() // 'baa'
```

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