Index: mojo/edk/js/test/hexdump.js |
diff --git a/mojo/edk/js/test/hexdump.js b/mojo/edk/js/test/hexdump.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b36c47f33a9a7f311ad9e9e329c2357ba1c4d7fc |
--- /dev/null |
+++ b/mojo/edk/js/test/hexdump.js |
@@ -0,0 +1,34 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+define(function() { |
+ function hexify(value, length) { |
+ var hex = value.toString(16); |
+ while (hex.length < length) |
+ hex = "0" + hex; |
+ return hex; |
+ } |
+ |
+ function dumpArray(bytes) { |
+ var dumped = ""; |
+ for (var i = 0; i < bytes.length; ++i) { |
+ dumped += hexify(bytes[i], 2); |
+ |
+ if (i % 16 == 15) { |
+ dumped += "\n"; |
+ continue; |
+ } |
+ |
+ if (i % 2 == 1) |
+ dumped += " "; |
+ if (i % 8 == 7) |
+ dumped += " "; |
+ } |
+ return dumped; |
+ } |
+ |
+ var exports = {}; |
+ exports.dumpArray = dumpArray; |
+ return exports; |
+}); |