aboutsummaryrefslogtreecommitdiff
path: root/cordova/node_modules/uuid/lib/bytesToUuid.js
diff options
context:
space:
mode:
Diffstat (limited to 'cordova/node_modules/uuid/lib/bytesToUuid.js')
-rwxr-xr-xcordova/node_modules/uuid/lib/bytesToUuid.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/cordova/node_modules/uuid/lib/bytesToUuid.js b/cordova/node_modules/uuid/lib/bytesToUuid.js
new file mode 100755
index 0000000..9ee989c
--- /dev/null
+++ b/cordova/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;