UNPKG

wavesurfer.js

Version:

Interactive navigable audio visualization using Web Audio and Canvas

23 lines (22 loc) 525 B
/** * Get a random prefixed ID * * @param {String} prefix Prefix to use. Default is `'wavesurfer_'`. * @returns {String} Random prefixed ID * @example * console.log(getId()); // logs 'wavesurfer_b5pors4ru6g' * * let prefix = 'foo-'; * console.log(getId(prefix)); // logs 'foo-b5pors4ru6g' */ export default function getId(prefix) { if (prefix === undefined) { prefix = 'wavesurfer_'; } return ( prefix + Math.random() .toString(32) .substring(2) ); }