insomnia/app/database/util.js
2016-04-16 18:52:53 -07:00

12 lines
276 B
JavaScript

const CHARS = '023456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ'.split('');
export function generateId (prefix) {
let id = `${prefix}_${Date.now()}-`;
for (let i = 0; i < 10; i++) {
id += CHARS[Math.floor(Math.random() * CHARS.length)];
}
return id;
}