An open API service indexing awesome lists of open source software.

https://github.com/bubao/cherry-id-js


https://github.com/bubao/cherry-id-js

nodejs

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# 🌸 cherry-id

[![NPM version](https://img.shields.io/npm/v/cherry-id.svg)](https://www.npmjs.com/package/cherry-id) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)](README.md)

## 介绍

核心算法版权属于 [yitter](https://github.com/yitter)

项目更多介绍参照:[https://github.com/yitter/IdGenerator](https://github.com/yitter/IdGenerator)

## 使用

```js
const GenId = require('cherry-id');
const genid = new GenId({ WorkerId: (process.argv[2] || 1) - 0 });

(() => {
console.time("Test Run");
const HSet = new Set();
for (let index = 0; index < 500000; index++) {
HSet.add(genid.NextId());
}
console.timeEnd("Test Run");
console.log([...HSet.values()].join("\n"))
console.log(HSet.size);
})();
```