\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md145}{}\doxysection{uuid $<$a href=\char`\"{}https\+://github.\+com/uuidjs/uuid/actions?query=workflow\%3\+ACI\char`\"{}$>$$<$img src=\char`\"{}https\+://github.\+com/uuidjs/uuid/workflows/\+CI/badge.\+svg\char`\"{} alt=\char`\"{}\+CI\char`\"{}/$>$$<$/a$>$ $<$a href=\char`\"{}https\+://github.\+com/uuidjs/uuid/actions?query=workflow\%3\+ABrowser\char`\"{}$>$$<$img src=\char`\"{}https\+://github.\+com/uuidjs/uuid/workflows/\+Browser/badge.\+svg\char`\"{} alt=\char`\"{}\+Browser\char`\"{}/$>$$<$/a$>$}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md145}
For the creation of \href{http://www.ietf.org/rfc/rfc4122.txt}{\texttt{ RFC4122}} UUIDs


\begin{DoxyItemize}
\item {\bfseries{Complete}} -\/ Support for RFC4122 version 1, 3, 4, and 5 UUIDs
\item {\bfseries{Cross-\/platform}} -\/ Support for ...
\begin{DoxyItemize}
\item Common\+JS, \href{\#ecmascript-modules}{\texttt{ ECMAScript Modules}} and \href{\#cdn-builds}{\texttt{ CDN builds}}
\item Node 8, 10, 12, 14
\item Chrome, Safari, Firefox, Edge, IE 11 browsers
\item Webpack and rollup.\+js module bundlers
\item \href{\#react-native}{\texttt{ React Native}}
\end{DoxyItemize}
\item {\bfseries{Secure}} -\/ Cryptographically-\/strong random values
\item {\bfseries{Small}} -\/ Zero-\/dependency, small footprint, plays nice with \char`\"{}tree shaking\char`\"{} packagers
\item {\bfseries{CLI}} -\/ Includes the \href{\#command-line}{\texttt{ {\ttfamily uuid} command line}} utility
\end{DoxyItemize}

{\bfseries{Upgrading from {\ttfamily uuid@3.\+x}?}} Your code is probably okay, but check out \href{\#upgrading-from-uuid3x}{\texttt{ Upgrading From {\ttfamily uuid@3.\+x}}} for details.\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md146}{}\doxysubsection{Quickstart}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md146}
To create a random UUID...

{\bfseries{1. Install}}


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install uuid }

\end{DoxyCode}


{\bfseries{2. Create a UUID}} (ES6 module syntax)


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{uuidv4(); // ⇨ '9b1deb4d-\/3b7d-\/4bad-\/9bdd-\/2b0d7b3dcb6d' }

\end{DoxyCode}


... or using Common\+JS syntax\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const \{ v4: uuidv4 \} = require('uuid');}
\DoxyCodeLine{uuidv4(); // ⇨ '1b9d6bcd-\/bbfd-\/4b2d-\/9b5d-\/ab8dfbbd4bed' }

\end{DoxyCode}


For timestamp UUIDs, namespace UUIDs, and other options read on ...\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md147}{}\doxysubsection{API Summary}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md147}
\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{3}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-3}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-3}
\endhead
\href{\#uuidnil}{\texttt{ {\ttfamily uuid.\+NIL}}}   &The nil UUID string (all zeros)   &New in {\ttfamily uuid@8.\+3}    \\\cline{1-3}
\href{\#uuidparsestr}{\texttt{ {\ttfamily uuid.\+parse()}}}   &Convert UUID string to array of bytes   &New in {\ttfamily uuid@8.\+3}    \\\cline{1-3}
\href{\#uuidstringifyarr-offset}{\texttt{ {\ttfamily uuid.\+stringify()}}}   &Convert array of bytes to UUID string   &New in {\ttfamily uuid@8.\+3}    \\\cline{1-3}
\href{\#uuidv1options-buffer-offset}{\texttt{ {\ttfamily uuid.\+v1()}}}   &Create a version 1 (timestamp) UUID   &\\\cline{1-3}
\href{\#uuidv3name-namespace-buffer-offset}{\texttt{ {\ttfamily uuid.\+v3()}}}   &Create a version 3 (namespace w/ MD5) UUID   &\\\cline{1-3}
\href{\#uuidv4options-buffer-offset}{\texttt{ {\ttfamily uuid.\+v4()}}}   &Create a version 4 (random) UUID   &\\\cline{1-3}
\href{\#uuidv5name-namespace-buffer-offset}{\texttt{ {\ttfamily uuid.\+v5()}}}   &Create a version 5 (namespace w/ SHA-\/1) UUID   &\\\cline{1-3}
\href{\#uuidvalidatestr}{\texttt{ {\ttfamily uuid.\+validate()}}}   &Test a string to see if it is a valid UUID   &New in {\ttfamily uuid@8.\+3}    \\\cline{1-3}
\href{\#uuidversionstr}{\texttt{ {\ttfamily uuid.\+version()}}}   &Detect RFC version of a UUID   &New in {\ttfamily uuid@8.\+3}   \\\cline{1-3}
\end{longtabu}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md148}{}\doxysubsection{API}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md148}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md149}{}\doxysubsubsection{uuid.\+NIL}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md149}
The nil UUID string (all zeros).

Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ NIL as NIL\_UUID \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{NIL\_UUID; // ⇨ '00000000-\/0000-\/0000-\/0000-\/000000000000' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md150}{}\doxysubsubsection{uuid.\+parse(str)}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md150}
Convert UUID string to array of bytes

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
{\ttfamily str}   &A valid UUID {\ttfamily String}    \\\cline{1-2}
{\itshape returns}   &{\ttfamily Uint8\+Array\mbox{[}16\mbox{]}}    \\\cline{1-2}
{\itshape throws}   &{\ttfamily Type\+Error} if {\ttfamily str} is not a valid UUID   \\\cline{1-2}
\end{longtabu}


Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ parse as uuidParse \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidParse('6ec0bd7f-\/11c0-\/43da-\/975e-\/2a8ad9ebae0b'); // ⇨ }
\DoxyCodeLine{  // Uint8Array(16) [}
\DoxyCodeLine{  //   110, 192, 189, 127,  17,}
\DoxyCodeLine{  //   192,  67, 218, 151,  94,}
\DoxyCodeLine{  //    42, 138, 217, 235, 174,}
\DoxyCodeLine{  //    11}
\DoxyCodeLine{  // ] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md151}{}\doxysubsubsection{uuid.\+stringify(arr\mbox{[}, offset\mbox{]})}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md151}
Convert array of bytes to UUID string

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
{\ttfamily arr}   &{\ttfamily Array}-\/like collection of 16 values (starting from {\ttfamily offset}) between 0-\/255    \\\cline{1-2}
\mbox{[}{\ttfamily offset} = 0\mbox{]}   &{\ttfamily Number} Starting index in the Array    \\\cline{1-2}
{\itshape returns}   &{\ttfamily String}    \\\cline{1-2}
{\itshape throws}   &{\ttfamily Type\+Error} if a valid UUID string cannot be generated   \\\cline{1-2}
\end{longtabu}


Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ stringify as uuidStringify \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{const uuidBytes = [110, 192, 189, 127, 17, 192, 67, 218, 151, 94, 42, 138, 217, 235, 174, 11];}
\DoxyCodeLine{}
\DoxyCodeLine{uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-\/11c0-\/43da-\/975e-\/2a8ad9ebae0b' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md152}{}\doxysubsubsection{uuid.\+v1(\mbox{[}options\mbox{[}, buffer\mbox{[}, offset\mbox{]}\mbox{]}\mbox{]})}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md152}
Create an RFC version 1 (timestamp) UUID

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
\mbox{[}{\ttfamily options}\mbox{]}   &{\ttfamily Object} with one or more of the following properties\+:    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+node} \mbox{]}   &RFC \char`\"{}node\char`\"{} field as an {\ttfamily Array\mbox{[}6\mbox{]}} of byte values (per 4.\+1.\+6)    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+clockseq}\mbox{]}   &RFC \char`\"{}clock sequence\char`\"{} as a {\ttfamily Number} between 0 -\/ 0x3fff    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+msecs}\mbox{]}   &RFC \char`\"{}timestamp\char`\"{} field ({\ttfamily Number} of milliseconds, unix epoch)    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+nsecs}\mbox{]}   &RFC \char`\"{}timestamp\char`\"{} field ({\ttfamily Number} of nanseconds to add to {\ttfamily msecs}, should be 0-\/10,000)    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+random}\mbox{]}   &{\ttfamily Array} of 16 random bytes (0-\/255)    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+rng}\mbox{]}   &Alternative to {\ttfamily options.\+random}, a {\ttfamily Function} that returns an {\ttfamily Array} of 16 random bytes (0-\/255)    \\\cline{1-2}
\mbox{[}{\ttfamily buffer}\mbox{]}   &{\ttfamily Array \textbackslash{}$\vert$ Buffer} If specified, uuid will be written here in byte-\/form, starting at {\ttfamily offset}    \\\cline{1-2}
\mbox{[}{\ttfamily offset} = 0\mbox{]}   &{\ttfamily Number} Index to start writing UUID bytes in {\ttfamily buffer}    \\\cline{1-2}
{\itshape returns}   &UUID {\ttfamily String} if no {\ttfamily buffer} is specified, otherwise returns {\ttfamily buffer}    \\\cline{1-2}
{\itshape throws}   &{\ttfamily Error} if more than 10M UUIDs/sec are requested   \\\cline{1-2}
\end{longtabu}


Note\+: The default \href{https://tools.ietf.org/html/rfc4122\#section-4.1.6}{\texttt{ node id}} (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.

Note\+: {\ttfamily options.\+random} and {\ttfamily options.\+rng} are only meaningful on the very first call to {\ttfamily v1()}, where they may be passed to initialize the internal {\ttfamily node} and {\ttfamily clockseq} fields.

Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v1 as uuidv1 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidv1(); // ⇨ '2c5ea4c0-\/4067-\/11e9-\/8bad-\/9b1deb4d3b7d' }

\end{DoxyCode}


Example using {\ttfamily options}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v1 as uuidv1 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{const v1options = \{}
\DoxyCodeLine{  node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],}
\DoxyCodeLine{  clockseq: 0x1234,}
\DoxyCodeLine{  msecs: new Date('2011-\/11-\/01').getTime(),}
\DoxyCodeLine{  nsecs: 5678,}
\DoxyCodeLine{\};}
\DoxyCodeLine{uuidv1(v1options); // ⇨ '710b962e-\/041c-\/11e1-\/9234-\/0123456789ab' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md153}{}\doxysubsubsection{uuid.\+v3(name, namespace\mbox{[}, buffer\mbox{[}, offset\mbox{]}\mbox{]})}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md153}
Create an RFC version 3 (namespace w/ MD5) UUID

API is identical to {\ttfamily v5()}, but uses \char`\"{}v3\char`\"{} instead.

\&\#x26a0;\&\#xfe0f; Note\+: Per the RFC, \char`\"{}\+\_\+\+If backward compatibility is not an issue, SHA-\/1 \mbox{[}\+Version 5\mbox{]} is preferred\+\_\+.\char`\"{}\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md154}{}\doxysubsubsection{uuid.\+v4(\mbox{[}options\mbox{[}, buffer\mbox{[}, offset\mbox{]}\mbox{]}\mbox{]})}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md154}
Create an RFC version 4 (random) UUID

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
\mbox{[}{\ttfamily options}\mbox{]}   &{\ttfamily Object} with one or more of the following properties\+:    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+random}\mbox{]}   &{\ttfamily Array} of 16 random bytes (0-\/255)    \\\cline{1-2}
\mbox{[}{\ttfamily options.\+rng}\mbox{]}   &Alternative to {\ttfamily options.\+random}, a {\ttfamily Function} that returns an {\ttfamily Array} of 16 random bytes (0-\/255)    \\\cline{1-2}
\mbox{[}{\ttfamily buffer}\mbox{]}   &{\ttfamily Array \textbackslash{}$\vert$ Buffer} If specified, uuid will be written here in byte-\/form, starting at {\ttfamily offset}    \\\cline{1-2}
\mbox{[}{\ttfamily offset} = 0\mbox{]}   &{\ttfamily Number} Index to start writing UUID bytes in {\ttfamily buffer}    \\\cline{1-2}
{\itshape returns}   &UUID {\ttfamily String} if no {\ttfamily buffer} is specified, otherwise returns {\ttfamily buffer}   \\\cline{1-2}
\end{longtabu}


Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidv4(); // ⇨ '1b9d6bcd-\/bbfd-\/4b2d-\/9b5d-\/ab8dfbbd4bed' }

\end{DoxyCode}


Example using predefined {\ttfamily random} values\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{const v4options = \{}
\DoxyCodeLine{  random: [}
\DoxyCodeLine{    0x10,}
\DoxyCodeLine{    0x91,}
\DoxyCodeLine{    0x56,}
\DoxyCodeLine{    0xbe,}
\DoxyCodeLine{    0xc4,}
\DoxyCodeLine{    0xfb,}
\DoxyCodeLine{    0xc1,}
\DoxyCodeLine{    0xea,}
\DoxyCodeLine{    0x71,}
\DoxyCodeLine{    0xb4,}
\DoxyCodeLine{    0xef,}
\DoxyCodeLine{    0xe1,}
\DoxyCodeLine{    0x67,}
\DoxyCodeLine{    0x1c,}
\DoxyCodeLine{    0x58,}
\DoxyCodeLine{    0x36,}
\DoxyCodeLine{  ],}
\DoxyCodeLine{\};}
\DoxyCodeLine{uuidv4(v4options); // ⇨ '109156be-\/c4fb-\/41ea-\/b1b4-\/efe1671c5836' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md155}{}\doxysubsubsection{uuid.\+v5(name, namespace\mbox{[}, buffer\mbox{[}, offset\mbox{]}\mbox{]})}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md155}
Createa an RFC version 5 (namespace w/ SHA-\/1) UUID

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
{\ttfamily name}   &{\ttfamily String \textbackslash{}$\vert$ Array}    \\\cline{1-2}
{\ttfamily namespace}   &{\ttfamily String \textbackslash{}$\vert$ Array\mbox{[}16\mbox{]}} Namespace UUID    \\\cline{1-2}
\mbox{[}{\ttfamily buffer}\mbox{]}   &{\ttfamily Array \textbackslash{}$\vert$ Buffer} If specified, uuid will be written here in byte-\/form, starting at {\ttfamily offset}    \\\cline{1-2}
\mbox{[}{\ttfamily offset} = 0\mbox{]}   &{\ttfamily Number} Index to start writing UUID bytes in {\ttfamily buffer}    \\\cline{1-2}
{\itshape returns}   &UUID {\ttfamily String} if no {\ttfamily buffer} is specified, otherwise returns {\ttfamily buffer}   \\\cline{1-2}
\end{longtabu}


Note\+: The RFC {\ttfamily DNS} and {\ttfamily URL} namespaces are available as {\ttfamily v5.\+DNS} and {\ttfamily v5.\+URL}.

Example with custom namespace\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v5 as uuidv5 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{// Define a custom namespace.  Readers, create your own using something like}
\DoxyCodeLine{// https://www.uuidgenerator.net/}
\DoxyCodeLine{const MY\_NAMESPACE = '1b671a64-\/40d5-\/491e-\/99b0-\/da01ff1f3341';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidv5('Hello, World!', MY\_NAMESPACE); // ⇨ '630eb68f-\/e0fa-\/5ecc-\/887a-\/7c7a62614681' }

\end{DoxyCode}


Example with RFC {\ttfamily URL} namespace\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v5 as uuidv5 \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidv5('https://www.w3.org/', uuidv5.URL); // ⇨ 'c106a26a-\/21bb-\/5538-\/8bf2-\/57095d1976c1' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md156}{}\doxysubsubsection{uuid.\+validate(str)}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md156}
Test a string to see if it is a valid UUID

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
{\ttfamily str}   &{\ttfamily String} to validate    \\\cline{1-2}
{\itshape returns}   &{\ttfamily true} if string is a valid UUID, {\ttfamily false} otherwise   \\\cline{1-2}
\end{longtabu}


Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ validate as uuidValidate \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidValidate('not a UUID'); // ⇨ false}
\DoxyCodeLine{uuidValidate('6ec0bd7f-\/11c0-\/43da-\/975e-\/2a8ad9ebae0b'); // ⇨ true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md157}{}\doxysubsubsection{uuid.\+version(str)}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md157}
Detect RFC version of a UUID

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{2}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ }\\\cline{1-2}
\endhead
{\ttfamily str}   &A valid UUID {\ttfamily String}    \\\cline{1-2}
{\itshape returns}   &{\ttfamily Number} The RFC version of the UUID    \\\cline{1-2}
{\itshape throws}   &{\ttfamily Type\+Error} if {\ttfamily str} is not a valid UUID   \\\cline{1-2}
\end{longtabu}


Example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ version as uuidVersion \} from 'uuid';}
\DoxyCodeLine{}
\DoxyCodeLine{uuidVersion('45637ec4-\/c85f-\/11ea-\/87d0-\/0242ac130003'); // ⇨ 1}
\DoxyCodeLine{uuidVersion('6ec0bd7f-\/11c0-\/43da-\/975e-\/2a8ad9ebae0b'); // ⇨ 4 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md158}{}\doxysubsection{Command Line}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md158}
UUIDs can be generated from the command line using {\ttfamily uuid}.


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ uuid}
\DoxyCodeLine{ddeb27fb-\/d9a0-\/4624-\/be4d-\/4615062daed4 }

\end{DoxyCode}


The default is to generate version 4 UUIDS, however the other versions are supported. Type {\ttfamily uuid -\/-\/help} for details\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ uuid -\/-\/help}
\DoxyCodeLine{}
\DoxyCodeLine{Usage:}
\DoxyCodeLine{  uuid}
\DoxyCodeLine{  uuid v1}
\DoxyCodeLine{  uuid v3 <name> <namespace uuid>}
\DoxyCodeLine{  uuid v4}
\DoxyCodeLine{  uuid v5 <name> <namespace uuid>}
\DoxyCodeLine{  uuid -\/-\/help}
\DoxyCodeLine{}
\DoxyCodeLine{Note: <namespace uuid> may be "{}URL"{} or "{}DNS"{} to use the corresponding UUIDs}
\DoxyCodeLine{defined by RFC4122 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md159}{}\doxysubsection{ECMAScript Modules}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md159}
This library comes with \href{https://www.ecma-international.org/ecma-262/6.0/\#sec-modules}{\texttt{ ECMAScript Modules}} (ESM) support for Node.\+js versions that support it (\href{./examples/node-esmodules/}{\texttt{ example}}) as well as bundlers like \href{https://rollupjs.org/guide/en/\#tree-shaking}{\texttt{ rollup.\+js}} (\href{./examples/browser-rollup/}{\texttt{ example}}) and \href{https://webpack.js.org/guides/tree-shaking/}{\texttt{ webpack}} (\href{./examples/browser-webpack/}{\texttt{ example}}) (targeting both, Node.\+js and browser environments).


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{uuidv4(); // ⇨ '1b9d6bcd-\/bbfd-\/4b2d-\/9b5d-\/ab8dfbbd4bed' }

\end{DoxyCode}


To run the examples you must first create a dist build of this library in the module root\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm run build }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md160}{}\doxysubsection{CDN Builds}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md160}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md161}{}\doxysubsubsection{ECMAScript Modules}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md161}
To load this module directly into modern browsers that \href{https://caniuse.com/\#feat=es6-module}{\texttt{ support loading ECMAScript Modules}} you can make use of \href{https://jspm.org/}{\texttt{ jspm}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script type="{}module"{}>}
\DoxyCodeLine{  import \{ v4 as uuidv4 \} from 'https://jspm.dev/uuid';}
\DoxyCodeLine{  console.log(uuidv4()); // ⇨ '1b9d6bcd-\/bbfd-\/4b2d-\/9b5d-\/ab8dfbbd4bed'}
\DoxyCodeLine{</script> }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md162}{}\doxysubsubsection{UMD}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md162}
To load this module directly into older browsers you can use the \href{https://github.com/umdjs/umd}{\texttt{ UMD (Universal Module Definition)}} builds from any of the following CDNs\+:

$\ast$$\ast$\+Using \href{https://unpkg.com/uuid@latest/dist/umd/}{\texttt{ UNPKG}}$\ast$$\ast$\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"{}></script> }

\end{DoxyCode}


$\ast$$\ast$\+Using \href{https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/}{\texttt{ js\+Delivr}}$\ast$$\ast$\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"{}></script> }

\end{DoxyCode}


{\bfseries{Using \href{https://cdnjs.com/libraries/uuid}{\texttt{ cdnjs}}}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script src="{}https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"{}></script> }

\end{DoxyCode}


These CDNs all provide the same \href{\#uuidv4options-buffer-offset}{\texttt{ {\ttfamily uuidv4()}}} method\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<script>}
\DoxyCodeLine{  uuidv4(); // ⇨ '55af1e37-\/0734-\/46d8-\/b070-\/a1e42e4fc392'}
\DoxyCodeLine{</script> }

\end{DoxyCode}


Methods for the other algorithms (\href{\#uuidv1options-buffer-offset}{\texttt{ {\ttfamily uuidv1()}}}, \href{\#uuidv3name-namespace-buffer-offset}{\texttt{ {\ttfamily uuidv3()}}} and \href{\#uuidv5name-namespace-buffer-offset}{\texttt{ {\ttfamily uuidv5()}}}) are available from the files {\ttfamily uuidv1.\+min.\+js}, {\ttfamily uuidv3.\+min.\+js} and {\ttfamily uuidv5.\+min.\+js} respectively.\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md163}{}\doxysubsection{\char`\"{}get\+Random\+Values() not supported\char`\"{}}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md163}
This error occurs in environments where the standard \href{https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues}{\texttt{ {\ttfamily crypto.\+get\+Random\+Values()}}} API is not supported. This issue can be resolved by adding an appropriate polyfill\+:\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md164}{}\doxysubsubsection{React Native}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md164}

\begin{DoxyEnumerate}
\item Install \href{https://github.com/LinusU/react-native-get-random-values\#readme}{\texttt{ {\ttfamily react-\/native-\/get-\/random-\/values}}}
\end{DoxyEnumerate}
\begin{DoxyEnumerate}
\item Import it before {\ttfamily uuid}\+:
\end{DoxyEnumerate}


\begin{DoxyCode}{0}
\DoxyCodeLine{import 'react-\/native-\/get-\/random-\/values';}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid'; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md165}{}\doxysubsubsection{Web Workers / Service Workers (\+Edge $<$= 18)}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md165}
\href{https://caniuse.com/\#feat=cryptography}{\texttt{ In Edge $<$= 18, Web Crypto is not supported in Web Workers or Service Workers}} and we are not aware of a polyfill (let us know if you find one, please).\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md166}{}\doxysubsection{Upgrading From $<$tt$>$uuid@7.\+x$<$/tt$>$}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md166}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md167}{}\doxysubsubsection{Only Named Exports Supported When Using with Node.\+js ESM}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md167}
{\ttfamily uuid@7.\+x} did not come with native ECMAScript Module (ESM) support for Node.\+js. Importing it in Node.\+js ESM consequently imported the Common\+JS source with a default export. This library now comes with true Node.\+js ESM support and only provides named exports.

Instead of doing\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import uuid from 'uuid';}
\DoxyCodeLine{uuid.v4(); }

\end{DoxyCode}


you will now have to use the named exports\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{uuidv4(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md168}{}\doxysubsubsection{Deep Requires No Longer Supported}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md168}
Deep requires like `require(\textquotesingle{}uuid/v4'){\ttfamily \mbox{[}which have been deprecated in}uuid@7.\+x\`{}\mbox{]}(\#deep-\/requires-\/now-\/deprecated) are no longer supported.\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md169}{}\doxysubsection{Upgrading From $<$tt$>$uuid@3.\+x$<$/tt$>$}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md169}
\char`\"{}\+\_\+\+Wait... what happened to \`{}uuid@4.\+x\`{} -\/ \`{}uuid@6.\+x\`{}?!?\+\_\+\char`\"{}

In order to avoid confusion with RFC \href{\#uuidv4options-buffer-offset}{\texttt{ version 4}} and \href{\#uuidv5name-namespace-buffer-offset}{\texttt{ version 5}} UUIDs, and a possible \href{http://gh.peabody.io/uuidv6/}{\texttt{ version 6}}, releases 4 thru 6 of this module have been skipped.\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md170}{}\doxysubsubsection{Deep Requires Now Deprecated}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md170}
{\ttfamily uuid@3.\+x} encouraged the use of deep requires to minimize the bundle size of browser builds\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const uuidv4 = require('uuid/v4'); // <== NOW DEPRECATED!}
\DoxyCodeLine{uuidv4(); }

\end{DoxyCode}


As of {\ttfamily uuid@7.\+x} this library now provides ECMAScript modules builds, which allow packagers like Webpack and Rollup to do \char`\"{}tree-\/shaking\char`\"{} to remove dead code. Instead, use the {\ttfamily import} syntax\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ v4 as uuidv4 \} from 'uuid';}
\DoxyCodeLine{uuidv4(); }

\end{DoxyCode}


... or for Common\+JS\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const \{ v4: uuidv4 \} = require('uuid');}
\DoxyCodeLine{uuidv4(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md171}{}\doxysubsubsection{Default Export Removed}\label{md_sfcode_node_modules__angular_cli_node_modules_uuid_README_autotoc_md171}
{\ttfamily uuid@3.\+x} was exporting the Version 4 UUID method as a default export\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const uuid = require('uuid'); // <== REMOVED! }

\end{DoxyCode}


This usage pattern was already discouraged in {\ttfamily uuid@3.\+x} and has been removed in {\ttfamily uuid@7.\+x}.

\DoxyHorRuler{0}
 Markdown generated from README\+\_\+js.md by \href{https://github.com/broofa/runmd}{\texttt{ }} 