main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
978 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.default = v1ToV6;
|
---|
4 | const parse_js_1 = require("./parse.js");
|
---|
5 | const stringify_js_1 = require("./stringify.js");
|
---|
6 | function v1ToV6(uuid) {
|
---|
7 | const v1Bytes = typeof uuid === 'string' ? (0, parse_js_1.default)(uuid) : uuid;
|
---|
8 | const v6Bytes = _v1ToV6(v1Bytes);
|
---|
9 | return typeof uuid === 'string' ? (0, stringify_js_1.unsafeStringify)(v6Bytes) : v6Bytes;
|
---|
10 | }
|
---|
11 | function _v1ToV6(v1Bytes) {
|
---|
12 | return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
|
---|
13 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.