Skip to content

Commit cd1b9dd

Browse files
committed
add nanoid method
1 parent d9e1d94 commit cd1b9dd

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ babel.config.json
77
docs/
88
.mocharc.json
99
dev.js
10+
release-doc.md

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uni-utils",
3-
"version": "1.1.1",
3+
"version": "1.2.1",
44
"description": " A unified toolkit for Nodejs",
55
"main": "./dist/index.js",
66
"types": "./index.d.ts",
@@ -30,6 +30,7 @@
3030
"fast-csv": "^4.3.6",
3131
"https-proxy-agent": "^5.0.0",
3232
"json2csv": "^5.0.0",
33+
"nanoid": "3",
3334
"node-fetch": "^3.0.0",
3435
"rimraf": "^3.0.2",
3536
"uuid": "^8.3.2"

src/core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,13 @@ const uuid = (v="v1", ...args) => {
8787
return require('uuid')[v](...args)
8888
}
8989
exports.uuid = uuid
90+
91+
const nanoid = (length) => {
92+
return require('nanoid').nanoid(length)
93+
}
94+
exports.nanoid = nanoid
95+
96+
const urlNanoid = (length) => {
97+
return require('nanoid').customAlphabet('useandom26T198340PX75pxJACKVERYMINDBUSHWOLFGQZbfghjklqvwyzrict', 21)(length)
98+
}
99+
exports.urlNanoid = urlNanoid

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,11 @@ nanocolors@^0.1.0, nanocolors@^0.1.5:
20502050
resolved "https://registry.yarnpkg.com/nanocolors/-/nanocolors-0.1.12.tgz#8577482c58cbd7b5bb1681db4cf48f11a87fd5f6"
20512051
integrity sha512-2nMHqg1x5PU+unxX7PGY7AuYxl2qDx7PSrTRjizr8sxdd3l/3hBuWWaki62qmtYm2U5i4Z5E7GbjlyDFhs9/EQ==
20522052

2053+
nanoid@3:
2054+
version "3.3.7"
2055+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
2056+
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==
2057+
20532058
20542059
version "3.1.25"
20552060
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.25.tgz#09ca32747c0e543f0e1814b7d3793477f9c8e152"

0 commit comments

Comments
 (0)