UNPKG

@triply/tus-js-client

Version:

A pure JavaScript client for the tus resumable upload protocol

26 lines (24 loc) 829 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = uuid; /** * Generate a UUID v4 based on random numbers. We intentioanlly use the less * secure Math.random function here since the more secure crypto.getRandomNumbers * is not available on all platforms. * This is not a problem for us since we use the UUID only for generating a * request ID, so we can correlate server logs to client errors. * * This function is taken from following site: * https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript * * @return {string} The generate UUID */ function uuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8; return v.toString(16); }); }