# snowyflake

> A modern implementation Snowflake on TypeScript

Latest version **2.0.1** (published 2025-02-15) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-02-15 |
| First published | 2018-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Vladlen |
| Maintainers | negezor |
| Keywords | snowflake, twitter, bigint, typescript, generator |

## Links

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

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2025-02-15
- 2.0.0 — 2021-12-14
- 1.2.0 — 2021-06-10
- 1.1.0 — 2021-06-10
- 1.0.2 — 2020-02-21
- 1.0.1 — 2019-07-15
- 1.0.0 — 2019-06-22
- 0.1.0 — 2018-12-20
- 0.0.1 — 2018-12-20

## README

<p align="center"><img src="https://raw.githubusercontent.com/negezor/snowyflake/master/docs/logo.svg?sanitize=true"></p>
<p align="center">
<a href="https://www.npmjs.com/package/snowyflake"><img src="https://img.shields.io/npm/v/snowyflake.svg?style=flat-square" alt="NPM version"></a>
<a href="https://github.com/negezor/snowyflake/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/negezor/snowyflake/tests.yml?style=flat-square" alt="Build Status"></a>
<a href="https://www.npmjs.com/package/snowyflake"><img src="https://img.shields.io/npm/dt/snowyflake.svg?style=flat-square" alt="NPM downloads"></a>
</p>

Snowyflake - A modern implementation Snowflake on TypeScript

| 📖 [Documentation](docs/) |
|---------------------------|

## Installation
> **[Node.js](https://nodejs.org/) 16.0.0 or newer is required**

> **TypeScript config required `"target": "ES2019"` or higher**

### Yarn
Recommended
```
yarn add snowyflake
```

### NPM
```
npm i snowyflake
```

## Example usage
```js
import { Snowyflake, Epoch } from 'snowyflake';

const snowyflake = new Snowyflake({
    workerId: 1n,
    epoch: Epoch.Twitter // BigInt timestamp
});

const snowflake = snowyflake.nextId();

console.log(snowflake); // => 1075766315999952896n

const deconstructSnowflake = snowyflake.deconstruct(snowflake);

console.log(deconstructSnowflake); // =>
// { timestamp: 1545317651163n,
//     workerId: 1n,
//     processId: 0n,
//     sequence: 0n }

```

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