UNPKG

vike

Version:

The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.

15 lines (14 loc) 566 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRandomId = getRandomId; const assert_js_1 = require("./assert.js"); // https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript function getRandomId(length = 12) { let randomId = ''; while (randomId.length < length) { randomId += Math.random().toString(36).slice(2); } randomId = randomId.slice(0, length); (0, assert_js_1.assert)(/^[a-z0-9]+$/.test(randomId) && randomId.length === length); return randomId; }