var child_process = require('child_process')

/**
 * The executable cache.
 * @type {Object.<!Executable>}
 */
var registry = {}

/**
 * A memoized executable command. The first time the command is run, the results are stored.
 * Callbacks are tracked while the command is running to avoid race conditions.
 *
 * @constructor
 * @param {string} command The command to execute.
 */
function Executable(command) {
  /** @type {string} */
  this.command = command

  /** @type {Array.<function(Error, Buffer, Buffer)>} */
  this.callbacks = []

  child_process.exec(this.command, function() {
    this.results = arguments

    for (var i = 0; i < this.callbacks.length; i++) {
      var callback = this.callbacks[i]
      callback.apply(null, arguments)
    }
  }.bind(this))
}

/**
 * Executes a memoized command and triggers the callback on a result.
 * @param {string} command
 * @param {function(Error, Buffer, Buffer)=} opt_callback
 */
module.exports = function(command, opt_callback) {
  if (!registry[command]) {
    registry[command] = new Executable(command)
  }

  var executable = registry[command]
  if (opt_callback) {
    if (executable.results) {
      opt_callback.apply(null, executable.results)
    } else {
      executable.callbacks.push(opt_callback)
    }
  }
}

@@ -123,10 +123,28 @@
 y = 
-%7B%7D
+Object.create(null)%0A
 %0A%0A/*
@@ -553,16 +553,66 @@
 s = %5B%5D%0A%0A
+  /** @type %7BArguments%7D */%0A  this.results = null%0A%0A
   child_
@@ -837,16 +837,248 @@
 is))%0A%7D%0A%0A
+/**%0A * @param %7Bfunction(Error, Buffer, Buffer)%7D callback%0A */%0AExecutable.prototype.addCallback = function (callback) %7B%0A  if (this.results) %7B%0A    callback.apply(null, this.results)%0A  %7D else %7B%0A    this.callbacks.push(callback)%0A  %7D%0A%7D%0A%0A%0A
 /**%0A * E
@@ -1425,18 +1425,8 @@
 ck) 
-%7B%0A    if (
 exec
@@ -1436,114 +1436,19 @@
 ble.
-results) %7B%0A      opt_callback.apply(null, executable.results)%0A    %7D else %7B%0A      executable.c
+addC
 allback
-s.push
 (opt
@@ -1462,16 +1462,6 @@
 ck)%0A
-    %7D%0A  %7D%0A
 %7D%0A

Move callback management to the executable instance.