https://github.com/bubao/cherry-id-js
https://github.com/bubao/cherry-id-js
nodejs
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bubao/cherry-id-js
- Owner: bubao
- License: mit
- Created: 2021-06-05T16:07:06.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T14:13:55.000Z (almost 2 years ago)
- Last Synced: 2025-03-11T09:05:14.384Z (over 1 year ago)
- Topics: nodejs
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.cn.md
- License: LICENSE
Awesome Lists containing this project
README
# 🌸 cherry-id
[](https://www.npmjs.com/package/cherry-id) [](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);
})();
```