UNPKG

tinycoll

Version:

A minimal reactive document store with Mongo-like querying, reactivity, TTL support, and optional persistence.

14 lines (13 loc) 480 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.newShortId = newShortId; const getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues ? () => crypto.getRandomValues(new Uint32Array(1))[0].toString(36) : () => Math.random().toString(36).substring(2, 15); function newShortId(length = 17) { let id = ""; while (id.length < length) { id += getRandomValues(); } return id.substring(0, length); }