main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
842 bytes
|
Line | |
---|
1 | import parse from './parse.js';
|
---|
2 | import { unsafeStringify } from './stringify.js';
|
---|
3 | export default function v6ToV1(uuid) {
|
---|
4 | const v6Bytes = typeof uuid === 'string' ? parse(uuid) : uuid;
|
---|
5 | const v1Bytes = _v6ToV1(v6Bytes);
|
---|
6 | return typeof uuid === 'string' ? unsafeStringify(v1Bytes) : v1Bytes;
|
---|
7 | }
|
---|
8 | function _v6ToV1(v6Bytes) {
|
---|
9 | return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
|
---|
10 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.