michangarrito/apps/backend/node_modules/uid/secure/index.mjs
rckrdmrd 48dea7a5d0 feat: Initial commit - michangarrito
Marketplace móvil para negocios locales mexicanos.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React Web)
- apps/mobile (Expo/React Native)
- apps/mcp-server (Claude MCP Server)
- apps/whatsapp-service (WhatsApp Business API)
- database/ (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:02 -06:00

19 lines
390 B
JavaScript

import { random } from '@lukeed/csprng';
var IDX=256, HEX=[], SIZE=256*16, BUFFER;
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
export function uid(len) {
var str='', tmp=(len || 11), num=(1+tmp) / 2 | 0;
if (!BUFFER || ((IDX + num) > SIZE)) {
BUFFER = random(SIZE);
IDX = 0;
}
while (num--) {
str += HEX[BUFFER[IDX++]];
}
return str.substring(0, tmp);
}