# firebase-auto-ids

> Generate random time-based IDs like Firebase

Latest version **1.1.0** (published 2015-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install firebase-auto-ids
pnpm add firebase-auto-ids
yarn add firebase-auto-ids
bun add firebase-auto-ids
```

## 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.1.0 |
| Published | 2015-02-24 |
| First published | 2015-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | firebase, id, auto, timestamp |

## Links

- npm: https://www.npmjs.com/package/firebase-auto-ids
- Repository: https://github.com/bendrucker/firebase-auto-ids
- Issues: https://github.com/bendrucker/firebase-auto-ids/issues
- npm.io page: https://npm.io/package/firebase-auto-ids

## 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.1.0 (latest) — 2015-02-24
- 1.0.0 — 2015-02-24

## README

# firebase-auto-ids [![Build Status](https://travis-ci.org/bendrucker/firebase-auto-ids.svg?branch=master)](https://travis-ci.org/bendrucker/firebase-auto-ids)

Generate random time-based, collision-proof IDs a la [`Firebase.push`](https://www.firebase.com/docs/web/api/firebase/push.html). Designed for testing and education (readability), not performance.

## Installing

```sh
$ npm install firebase-auto-ids
```

## API

##### `generate(now)` -> `String`

firebase-auto-ids exports a function. Pass in `now`, the current timestamp (e.g. `Date.now()`). `generate` returns an ID string. Like `Firebase.push`, IDs hold the following properties:

* `id1` < `id2` where `id1` was created at an earlier time (`now`) than `id2`
* `id1` < `id2` where `id1` and `id2` were created at the same `now` but `generateAutoId` was executed for `id1` before `id2`
* `id1` !== `id2` where `id1` and `id2` were created at the same `now` in different clients

<hr>

##### `new generate.Generator()` -> `generator`

Creates a new `generator` instance. Individual instances do not share state. This means that IDs created at the same time in a given runtime will no longer be determined by call order. 

##### `generator.generate(now)` -> `String`

Same as [`generate(now)`](#generatenow---string)

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