@squirrel-forge/ui-util
Version:
A collection of utilities, classes, functions and abstracts made for the browser and babel compatible.
11 lines (10 loc) • 338 B
JavaScript
/**
* Generate a random string
* @param {boolean} entropy - True for higher entropy
* @return {string} - A random string
*/
export function strand( entropy = false ) {
const time = !entropy ? '' : '-'
+ ( performance.now() + '' ).replace( /\./g, '-' );
return Math.random().toString( 36 ).substring( 2, 12 ) + time;
}