Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
4 years ago | |
|---|---|---|
| .. | ||
| test | 4 years ago | |
| .gitignore | 4 years ago | |
| README.md | 4 years ago | |
| package-lock.json | 4 years ago | |
| package.json | 4 years ago | |
| snowflakeIdv1.ts | 4 years ago | |
| tsconfig.json | 4 years ago | |
项目更多介绍参照:https://github.com/yitter/idgenerator
代码贡献者:zhupengfei(在 bubao 布宝 的JS基础上改版,感谢bubao 布宝)
执行测试代码
ts-node test/test1.ts
import { snowflakeIdv1 } from '../snowflakeIdv1'
const WorkerId = process.env.WorkerId == undefined ? 1 : process.env.WorkerId
const Method = process.env.Method == undefined ? 1 : process.env.Method
let gen1 = new snowflakeIdv1({ WorkerId: WorkerId, Method: Method })
let id1 = gen1.NextId()
console.log(id1, id1.toString().length)
雪花算法中非常好用的数字ID生成器
C C# Pascal Go D other