veyron-browser: Plugin system for RPC output

Originally, JSON.stringify printed out all values regardless of type.
However, RPC output sometimes should be rendered differently.

In the case of monitoring, we receive an object, a histogram.
The histogram, when detected, will be rendered specially.
This is the motivation for a new plugin system for rendering RPC output

The new plugin system consists of 2 parts
* Given a value, identify the correct plugin to use
* Use the plugin to render the value

The code has been restructured to accommodate plugins for rendering output.

Change-Id: I910303d33582b563544d237c9027a539853f86bf
diff --git a/src/components/browse/item-details/plugins/histogram.js b/src/components/browse/item-details/plugins/histogram.js
new file mode 100644
index 0000000..85699ce
--- /dev/null
+++ b/src/components/browse/item-details/plugins/histogram.js
@@ -0,0 +1,28 @@
+var histogram = require('bars');
+var h = require('mercury').h;
+
+module.exports = {
+  'shouldRender': shouldRender,
+  'render': render
+};
+
+/*
+ * Render if the appropriate histogram fields are present.
+ * TODO(alexfandrianto): Negotiate a better way of identifying histogram data.
+ */
+function shouldRender(input) {
+  return input.count !== undefined && input.sum !== undefined &&
+    input.buckets !== undefined;
+}
+
+/*
+ * The histogram is rendered with bars (a fork of ascii-histogram).
+ * TODO(alexfandrianto): Consider using a prettier rendering package.
+ */
+function render(input) {
+  var histData = {};
+  input.buckets.forEach(function(obj) {
+    histData[obj.lowBound] = obj.count;
+  });
+  return h('pre', histogram(histData, { bar: '*', width: 20 }));
+}
\ No newline at end of file