/** * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /** * @module utils/uid */ /** * Returns a unique id. This id consist of an 'e' character and a randomly generated string of 32 aphanumeric characters. * Each character in uid string represents a hexadecimal digit (base 16). * * @returns {String} A hexadecimal number representing the id. */ export default function uid() { let uuid = 'e'; // Make sure that id does not start with number. for ( let i = 0; i < 8; i++ ) { uuid += Math.floor( ( 1 + Math.random() ) * 0x10000 ).toString( 16 ).substring( 1 ); } return uuid; }