# short-id

> Short ID string generation

Latest version **0.1.0-1** (published 2012-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install short-id
pnpm add short-id
yarn add short-id
bun add short-id
```

## 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-1 |
| Published | 2012-09-30 |
| First published | 2012-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | James Brumond |
| Maintainers | k |
| Keywords | id, unique, generation |

## Links

- npm: https://www.npmjs.com/package/short-id
- Repository: https://github.com/UmbraEngineering/short-id
- npm.io page: https://npm.io/package/short-id

## Dependencies (2)

- [sechash](https://npm.io/package/sechash.md) ~0.2.1
- [merge-recursive](https://npm.io/package/merge-recursive.md) 0.0.3

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

- 0.1.0-1 (latest) — 2012-09-30
- 0.1.0 — 2012-08-28
- 0.0.0 — 2012-08-11

## README

# short-id

Self-contained short-life ID generating module

_Not guarenteed to be unique outside of a single instance of the module._

## Install

```bash
$ npm install short-id
```

## Usage

```javascript
var ids = require('short-id');

ids.generate();  // "aeaf15"
ids.generate();  // "1d0449"

ids.store('foo');  // "8dbd46"
ids.fetch('8dbd46');  // 'foo'

ids.invalidate('8dbd46');
ids.fetch('8dbd46');  // undefined
```

### ids.generate ( void )

Generates a new ID string and returns it.

### ids.invalidate ( String key )

Invalidates the given id key, removing any data stored with it and recycling it.

### ids.store ( mixed value )

Generates a new key and stores a value under that key.

### ids.fetch ( String key )

Looks up a value stored under the given key.

### ids.fetchAndInvalidate ( String key )

The equivilent of calling `fetch` and then `invalidate`. Returns the stored value.

### ids.configure ( Object conf )

Changes configuration values.

```javascript
// Call to configure shown with the default values
ids.configure({
	length: 6,          // The length of the id strings to generate
	algorithm: 'sha1',  // The hashing algoritm to use in generating keys
	salt: Math.random   // A salt value or function
});
```

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