one-shot.js
function oneShot(callback) {
  var done = false;
  return function (err) {
    if (!done) {
      done = true;
      return callback.apply(this, arguments);
    }
    if (err) console.error(err.stack);
  }
}
function oneShot(callback) {
  var done = false;
  return function (err) {
    if (!done) {
      done = true;
      return callback.apply(this, arguments);
    }
    if (err) console.error(err.stack);
  }
}
function oneShot ( callback ) { var done = false ; return function ( err ) { if ( ! done ) { done = true ; return callback . apply ( this , arguments ) ; } if ( err ) console . error ( err . stack ) ; } }
Makes sure a callback is only called once.
Makes sure a callback is only called once .