all files / src/util/ makeGuid.ts

100% Statements 8/8
100% Branches 2/2
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                      279×   279×            
/**
 * Created by gavorhes on 11/3/2015.
 */
 
import provide from './provide';
let nm = provide('util');
 
 
/**
 * guids are used to uniquely identify groups and features
 * @returns {string} a new guid
 */
function makeGuid() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
            .replace(/[xy]/g, function (c) {
                let r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
 
                return v.toString(16);
            });
 
}
nm.makeGuid = makeGuid;
export default makeGuid;