UNPKG

recoder-code

Version:

🚀 AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!

15 lines (12 loc) • 350 B
var IDX=256, HEX=[], SIZE=256, BUFFER; while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1); function uid(len) { var i=0, tmp=(len || 11); if (!BUFFER || ((IDX + tmp) > SIZE*2)) { for (BUFFER='',IDX=0; i < SIZE; i++) { BUFFER += HEX[Math.random() * 256 | 0]; } } return BUFFER.substring(IDX, IDX++ + tmp); } exports.uid = uid;