SkillAgentSearch skills...

Snowflaker

Twitter's snowflake algorithm implementation in Dart. The Snowflake algorithm is a unique ID generator that was originally developed by Twitter. The algorithm generates 64-bit IDs that are composed of a timestamp, a worker ID, and a sequence number.

Install / Use

/learn @hawkkiller/Snowflaker
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Snowflake ID Generator

A Dart library for generating unique, sortable ID strings using the Twitter's Snowflake algorithm.

Features

  • Thread-safe generation of unique IDs.
  • Each ID contains a timestamp with millisecond precision.
  • Customizable worker and datacenter identifiers.

Usage

Add the following to your pubspec.yaml file:

dependencies:
  snowflaker: ^1.0.0

Then import the library:

import 'package:snowflaker/snowflaker.dart';

To generate a new ID, create a new instance of snowflaker and call its nextId() method:


// Create a new instance of snowflaker with a worker ID of 1 and a datacenter ID of 1.
final snowflaker = Snowflaker(workerId: 1, datacenterId: 1);

// Generate a new ID.
final id = snowflaker.nextId();
View on GitHub
GitHub Stars4
CategoryDevelopment
Updated10mo ago
Forks1

Languages

Dart

Security Score

77/100

Audited on May 9, 2025

No findings