mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 12:58:35 +02:00
Rename uuid related namespaces.
This commit is contained in:
parent
4607d92c31
commit
f81542a792
3 changed files with 12 additions and 13 deletions
48
src/uxbox/util/uuid_impl.js
Normal file
48
src/uxbox/util/uuid_impl.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
goog.provide("uxbox.util.uuid_impl");
|
||||
goog.require("uxbox.util.rng_impl");
|
||||
|
||||
goog.scope(function() {
|
||||
const self = uxbox.util.uuid_impl;
|
||||
const rng = uxbox.util.rng_impl;
|
||||
|
||||
const hexMap = [];
|
||||
for (let i = 0; i < 256; i++) {
|
||||
hexMap[i] = (i + 0x100).toString(16).substr(1);
|
||||
}
|
||||
|
||||
function toHexString(buf) {
|
||||
let i = 0;
|
||||
return (hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] + '-' +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] + '-' +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] + '-' +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] + '-' +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]] +
|
||||
hexMap[buf[i++]]);
|
||||
}
|
||||
|
||||
self.v4 = function() {
|
||||
const buf = rng.getBytes(16);
|
||||
buf[6] = (buf[6] & 0x0f) | 0x40;
|
||||
buf[8] = (buf[8] & 0x3f) | 0x80;
|
||||
return toHexString(buf);
|
||||
};
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue