main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
778 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const native_js_1 = require("./native.js");
|
---|
| 4 | const rng_js_1 = require("./rng.js");
|
---|
| 5 | const stringify_js_1 = require("./stringify.js");
|
---|
| 6 | function v4(options, buf, offset) {
|
---|
| 7 | if (native_js_1.default.randomUUID && !buf && !options) {
|
---|
| 8 | return native_js_1.default.randomUUID();
|
---|
| 9 | }
|
---|
| 10 | options = options || {};
|
---|
| 11 | const rnds = options.random || (options.rng || rng_js_1.default)();
|
---|
| 12 | rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
---|
| 13 | rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
---|
| 14 | if (buf) {
|
---|
| 15 | offset = offset || 0;
|
---|
| 16 | for (let i = 0; i < 16; ++i) {
|
---|
| 17 | buf[offset + i] = rnds[i];
|
---|
| 18 | }
|
---|
| 19 | return buf;
|
---|
| 20 | }
|
---|
| 21 | return (0, stringify_js_1.unsafeStringify)(rnds);
|
---|
| 22 | }
|
---|
| 23 | exports.default = v4;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.