UNPKG

1.07 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3/*-----------------------------------------------------------------------------
4| Copyright (c) 2014-2017, PhosphorJS Contributors
5|
6| Distributed under the terms of the BSD 3-Clause License.
7|
8| The full license is in the file LICENSE, distributed with this software.
9|----------------------------------------------------------------------------*/
10import { Random } from './random.browser';
11import { uuid4Factory } from './uuid';
12
13/**
14 * The namespace for UUID related functionality.
15 */
16export namespace UUID {
17 /**
18 * A function which generates UUID v4 identifiers.
19 *
20 * @returns A new UUID v4 string.
21 *
22 * #### Notes
23 * This implementation complies with RFC 4122.
24 *
25 * This uses `Random.getRandomValues()` for random bytes, which in
26 * turn will use the underlying `crypto` module of the platform if
27 * it is available. The fallback for randomness is `Math.random`.
28 */
29 export const uuid4 = uuid4Factory(Random.getRandomValues);
30}