source: trip-planner-front/node_modules/uuid/dist/parse.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _validate = _interopRequireDefault(require("./validate.js"));
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12function parse(uuid) {
13 if (!(0, _validate.default)(uuid)) {
14 throw TypeError('Invalid UUID');
15 }
16
17 let v;
18 const arr = new Uint8Array(16); // Parse ########-....-....-....-............
19
20 arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
21 arr[1] = v >>> 16 & 0xff;
22 arr[2] = v >>> 8 & 0xff;
23 arr[3] = v & 0xff; // Parse ........-####-....-....-............
24
25 arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
26 arr[5] = v & 0xff; // Parse ........-....-####-....-............
27
28 arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
29 arr[7] = v & 0xff; // Parse ........-....-....-####-............
30
31 arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
32 arr[9] = v & 0xff; // Parse ........-....-....-....-############
33 // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
34
35 arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
36 arr[11] = v / 0x100000000 & 0xff;
37 arr[12] = v >>> 24 & 0xff;
38 arr[13] = v >>> 16 & 0xff;
39 arr[14] = v >>> 8 & 0xff;
40 arr[15] = v & 0xff;
41 return arr;
42}
43
44var _default = parse;
45exports.default = _default;
Note: See TracBrowser for help on using the repository browser.