get-short-id
Advanced tools
Comparing version 1.0.5 to 2.0.1
11
index.js
@@ -1,11 +0,12 @@ | ||
const {customAlphabet} = require('nanoid'); | ||
const {customAlphabet} = require("nanoid"); | ||
function getId(prefix, chars) { | ||
prefix = typeof prefix === 'string' ? prefix : ''; | ||
chars = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; | ||
function getId({prefix, count, chars}) { | ||
prefix = typeof prefix === "string" ? prefix : ""; | ||
chars = chars || "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; | ||
// generate 1k IDs/second and you will need 2 billion years to have 1% probability of 1 collision | ||
// https://zelark.github.io/nano-id-cc/ | ||
return prefix + (customAlphabet(chars, 24)()); | ||
count = count || 24; | ||
return prefix + (customAlphabet(chars, count)()); | ||
} | ||
module.exports = getId; |
{ | ||
"name": "get-short-id", | ||
"version": "1.0.5", | ||
"version": "2.0.1", | ||
"description": "Random ID generator function with options to provide prefix and character set. Uses nanoid(23) as random string source.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5577
14