Version 1
[yaffs-website] / node_modules / phantomjs-prebuilt / node_modules / uuid / lib / bytesToUuid.js
diff --git a/node_modules/phantomjs-prebuilt/node_modules/uuid/lib/bytesToUuid.js b/node_modules/phantomjs-prebuilt/node_modules/uuid/lib/bytesToUuid.js
new file mode 100644 (file)
index 0000000..9ee989c
--- /dev/null
@@ -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;