MCPcopy Create free account
hub / github.com/bugy/script-server / guid

Function guid

web-src/src/common/utils/common.js:227–251  ·  view source on GitHub ↗
(length)

Source from the content-addressed store, hash-verified

225}
226
227export function guid(length) {
228 function s4() {
229 return Math.floor((1 + Math.random()) * 0x10000)
230 .toString(16)
231 .substring(1);
232 }
233
234 var guid = s4() + s4() + '-' + s4() + '-' + s4() + '-' +
235 s4() + '-' + s4() + s4() + s4();
236
237
238 if (length && length > 0) {
239 if (guid.length < length) {
240 while (guid.length < length) {
241 guid += guid;
242 }
243 }
244
245 if (guid.length > length) {
246 guid = guid.substring(0, length);
247 }
248 }
249
250 return guid;
251}
252
253export function logError(error) {
254 (console.error || console.log).call(console, error.stack || error);

Callers 2

setupOAuthFunction · 0.90
reloadModelFunction · 0.90

Calls 1

s4Function · 0.85

Tested by

no test coverage detected