summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js')
-rw-r--r--deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js b/deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js
new file mode 100644
index 0000000000..9ee989cb9b
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js
@@ -0,0 +1,23 @@
+/**
+ * Convert array of 16 byte values to UUID string format of the form:
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+ */
+var byteToHex = [];
+for (var i = 0; i < 256; ++i) {
+ byteToHex[i] = (i + 0x100).toString(16).substr(1);
+}
+
+function bytesToUuid(buf, offset) {
+ var i = offset || 0;
+ var bth = byteToHex;
+ return bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] + '-' +
+ bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]] +
+ bth[buf[i++]] + bth[buf[i++]];
+}
+
+module.exports = bytesToUuid;