Skip to content

Commit

Permalink
feat(x): 新增 cuid、uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Dec 21, 2020
1 parent 1ee40c7 commit e938c99
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"cuid": "^2.1.8",
"date-fns": "^2.16.1",
"fast-xml-parser": "^3.17.5",
"lodash-uni": "^1.1.0",
"miniprogram-api-typings": "^3.2.0",
"react-use": "^15.3.4",
"uuid": "^8.3.2",
"yup": "~0.31.0"
},
"devDependencies": {
Expand All @@ -114,6 +116,7 @@
"@types/react": "17.0.0",
"@types/react-dom": "17.0.0",
"@types/standard-version": "7.0.0",
"@types/uuid": "^8.3.0",
"benchmark": "2.1.4",
"cli-table3": "0.6.0",
"codecov": "3.8.1",
Expand Down
24 changes: 23 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/x/cuid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { cuid } from './cuid'

describe('cuid', () => {
test('表现正常', () => {
expect(cuid()).toStartWith('c')
})
})
10 changes: 10 additions & 0 deletions src/x/cuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import _cuid from 'cuid'

/**
* 生成 CUID。
*
* @see https://www.npmjs.com/package/cuid
*/
export function cuid(): string {
return _cuid()
}
2 changes: 2 additions & 0 deletions src/x/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@

// @index(['./**/*.ts', '!./**/*.test.*', '!**/__*'], f => `export * from '${f.path}'`)
export * from './createXml'
export * from './cuid'
export * from './parseXml'
export * from './uuid'
// @endindex
7 changes: 7 additions & 0 deletions src/x/uuid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { uuid } from './uuid'

describe('uuid', () => {
test('表现正常', () => {
expect(uuid()).toHaveLength(36)
})
})
10 changes: 10 additions & 0 deletions src/x/uuid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { v4 as _uuid } from 'uuid'

/**
* 生成 RFC4122 V4 版本的 UUID。
*
* @see https://www.npmjs.com/package/uuid
*/
export function uuid(): string {
return _uuid()
}

0 comments on commit e938c99

Please sign in to comment.