UNPKG

486 BJavaScriptView Raw
1"use strict";
2
3/**
4 * Copyright 2004-present Facebook. All Rights Reserved.
5 *
6 * @typechecks
7 *
8 * @format
9 */
10
11/*eslint-disable no-bitwise */
12
13/**
14 * Based on the rfc4122-compliant solution posted at
15 * http://stackoverflow.com/questions/105034
16 */
17function uuid() {
18 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
19 var r = Math.random() * 16 | 0;
20 var v = c == 'x' ? r : r & 0x3 | 0x8;
21 return v.toString(16);
22 });
23}
24
25module.exports = uuid;
\No newline at end of file