https://github.com/gavinning/unique-integer-id
数字ID,常用于生成订单号,流水单号
https://github.com/gavinning/unique-integer-id
Last synced: 5 months ago
JSON representation
数字ID,常用于生成订单号,流水单号
- Host: GitHub
- URL: https://github.com/gavinning/unique-integer-id
- Owner: gavinning
- Created: 2020-07-24T07:17:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-24T14:21:51.000Z (over 5 years ago)
- Last Synced: 2024-11-08T02:49:13.076Z (about 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
unique-integer-id
---
数字ID,常用于订单号,流水号等常见数字ID场景
### Install
```sh
npm i @4a/cid
```
### Usage
```js
const cid = require('@4a/cid')
// 默认长度26
cid() // 20072418073123028206226431
cid(36) // 200724180731230341096740207611144342
```
```js
cid(24) // 设置长度24 推荐QPS低于10万
cid(26) // 设置长度26 推荐QPS低于20万
```
### Prefix
```js
// 默认前缀取两位数年份
// 例如2021年,则前缀是21
// 同样可以自定义前缀,两位数
cid(26, { prefix: 10 })
```