/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['base/broadcast.js']) {
  _$jscoverage['base/broadcast.js'] = [];
  _$jscoverage['base/broadcast.js'][1] = 0;
  _$jscoverage['base/broadcast.js'][5] = 0;
  _$jscoverage['base/broadcast.js'][8] = 0;
  _$jscoverage['base/broadcast.js'][9] = 0;
  _$jscoverage['base/broadcast.js'][10] = 0;
  _$jscoverage['base/broadcast.js'][11] = 0;
  _$jscoverage['base/broadcast.js'][12] = 0;
  _$jscoverage['base/broadcast.js'][14] = 0;
  _$jscoverage['base/broadcast.js'][15] = 0;
  _$jscoverage['base/broadcast.js'][16] = 0;
  _$jscoverage['base/broadcast.js'][17] = 0;
  _$jscoverage['base/broadcast.js'][20] = 0;
  _$jscoverage['base/broadcast.js'][26] = 0;
  _$jscoverage['base/broadcast.js'][27] = 0;
  _$jscoverage['base/broadcast.js'][34] = 0;
  _$jscoverage['base/broadcast.js'][35] = 0;
  _$jscoverage['base/broadcast.js'][36] = 0;
  _$jscoverage['base/broadcast.js'][37] = 0;
  _$jscoverage['base/broadcast.js'][38] = 0;
  _$jscoverage['base/broadcast.js'][39] = 0;
  _$jscoverage['base/broadcast.js'][40] = 0;
  _$jscoverage['base/broadcast.js'][42] = 0;
  _$jscoverage['base/broadcast.js'][45] = 0;
  _$jscoverage['base/broadcast.js'][48] = 0;
  _$jscoverage['base/broadcast.js'][68] = 0;
  _$jscoverage['base/broadcast.js'][69] = 0;
  _$jscoverage['base/broadcast.js'][70] = 0;
  _$jscoverage['base/broadcast.js'][71] = 0;
  _$jscoverage['base/broadcast.js'][72] = 0;
  _$jscoverage['base/broadcast.js'][73] = 0;
  _$jscoverage['base/broadcast.js'][74] = 0;
  _$jscoverage['base/broadcast.js'][75] = 0;
  _$jscoverage['base/broadcast.js'][76] = 0;
  _$jscoverage['base/broadcast.js'][77] = 0;
  _$jscoverage['base/broadcast.js'][78] = 0;
  _$jscoverage['base/broadcast.js'][80] = 0;
  _$jscoverage['base/broadcast.js'][82] = 0;
  _$jscoverage['base/broadcast.js'][84] = 0;
  _$jscoverage['base/broadcast.js'][105] = 0;
  _$jscoverage['base/broadcast.js'][106] = 0;
  _$jscoverage['base/broadcast.js'][107] = 0;
  _$jscoverage['base/broadcast.js'][108] = 0;
  _$jscoverage['base/broadcast.js'][109] = 0;
  _$jscoverage['base/broadcast.js'][110] = 0;
  _$jscoverage['base/broadcast.js'][111] = 0;
  _$jscoverage['base/broadcast.js'][112] = 0;
  _$jscoverage['base/broadcast.js'][113] = 0;
  _$jscoverage['base/broadcast.js'][135] = 0;
  _$jscoverage['base/broadcast.js'][136] = 0;
  _$jscoverage['base/broadcast.js'][141] = 0;
  _$jscoverage['base/broadcast.js'][142] = 0;
  _$jscoverage['base/broadcast.js'][143] = 0;
  _$jscoverage['base/broadcast.js'][145] = 0;
  _$jscoverage['base/broadcast.js'][146] = 0;
  _$jscoverage['base/broadcast.js'][147] = 0;
  _$jscoverage['base/broadcast.js'][156] = 0;
  _$jscoverage['base/broadcast.js'][157] = 0;
  _$jscoverage['base/broadcast.js'][158] = 0;
  _$jscoverage['base/broadcast.js'][159] = 0;
  _$jscoverage['base/broadcast.js'][160] = 0;
  _$jscoverage['base/broadcast.js'][161] = 0;
  _$jscoverage['base/broadcast.js'][164] = 0;
  _$jscoverage['base/broadcast.js'][165] = 0;
}
_$jscoverage['base/broadcast.js'][1]++;
var func = require("./functions"), obj = require("./object"), define = require("../define").define;
_$jscoverage['base/broadcast.js'][5]++;
var comb = exports;
_$jscoverage['base/broadcast.js'][8]++;
var wrapper = (function () {
  _$jscoverage['base/broadcast.js'][9]++;
  return (function () {
  _$jscoverage['base/broadcast.js'][10]++;
  var c = arguments.callee, listeners = c.__listeners, func = c.func, r;
  _$jscoverage['base/broadcast.js'][11]++;
  if (func) {
    _$jscoverage['base/broadcast.js'][12]++;
    r = func.apply(this, arguments);
  }
  _$jscoverage['base/broadcast.js'][14]++;
  for (var i = 0; i < listeners.length; i++) {
    _$jscoverage['base/broadcast.js'][15]++;
    var lis = listeners[i];
    _$jscoverage['base/broadcast.js'][16]++;
    if (lis) {
      _$jscoverage['base/broadcast.js'][17]++;
      lis.apply(this, arguments);
    }
}
  _$jscoverage['base/broadcast.js'][20]++;
  return r;
});
});
_$jscoverage['base/broadcast.js'][26]++;
var listeners = {};
_$jscoverage['base/broadcast.js'][27]++;
obj.merge(comb, {disconnect: (function (handle) {
  _$jscoverage['base/broadcast.js'][34]++;
  if (handle && handle.length == 3) {
    _$jscoverage['base/broadcast.js'][35]++;
    var obj = handle[0], method = handle[1], cb = handle[2];
    _$jscoverage['base/broadcast.js'][36]++;
    if (typeof method != "string") {
      _$jscoverage['base/broadcast.js'][36]++;
      throw "comb.disconnect : When calling disconnect the method must be string";
    }
    _$jscoverage['base/broadcast.js'][37]++;
    var scope = obj || global, ls;
    _$jscoverage['base/broadcast.js'][38]++;
    if (typeof scope[method] == "function") {
      _$jscoverage['base/broadcast.js'][39]++;
      ls = scope[method].__listeners;
      _$jscoverage['base/broadcast.js'][40]++;
      if (ls && cb-- > 0) {
        _$jscoverage['base/broadcast.js'][42]++;
        ls[cb] = null;
      }
    }
    else {
      _$jscoverage['base/broadcast.js'][45]++;
      throw new Error("unknown method " + method + " in object " + obj);
    }
  }
  else {
    _$jscoverage['base/broadcast.js'][48]++;
    throw "comb.disconnect : invalid handle";
  }
}), connect: (function (obj, method, cb, scope) {
  _$jscoverage['base/broadcast.js'][68]++;
  var index;
  _$jscoverage['base/broadcast.js'][69]++;
  if (typeof method != "string") {
    _$jscoverage['base/broadcast.js'][69]++;
    throw new Error("When calling connect the method must be string");
  }
  _$jscoverage['base/broadcast.js'][70]++;
  if (! func.isFunction(cb)) {
    _$jscoverage['base/broadcast.js'][70]++;
    throw new Error("When calling connect callback must be a string");
  }
  _$jscoverage['base/broadcast.js'][71]++;
  var scope = obj || global, listeners, newMethod;
  _$jscoverage['base/broadcast.js'][72]++;
  if (typeof scope[method] == "function") {
    _$jscoverage['base/broadcast.js'][73]++;
    listeners = scope[method].__listeners;
    _$jscoverage['base/broadcast.js'][74]++;
    if (! listeners) {
      _$jscoverage['base/broadcast.js'][75]++;
      newMethod = wrapper();
      _$jscoverage['base/broadcast.js'][76]++;
      newMethod.func = obj[method];
      _$jscoverage['base/broadcast.js'][77]++;
      listeners = (newMethod.__listeners = []);
      _$jscoverage['base/broadcast.js'][78]++;
      scope[method] = newMethod;
    }
    _$jscoverage['base/broadcast.js'][80]++;
    index = listeners.push(cb);
  }
  else {
    _$jscoverage['base/broadcast.js'][82]++;
    throw new Error("unknow method " + method + " in object " + obj);
  }
  _$jscoverage['base/broadcast.js'][84]++;
  return [obj, method, index];
}), broadcast: (function () {
  _$jscoverage['base/broadcast.js'][105]++;
  var args = Array.prototype.slice.call(arguments);
  _$jscoverage['base/broadcast.js'][106]++;
  var topic = args.splice(0, 1)[0];
  _$jscoverage['base/broadcast.js'][107]++;
  if (topic) {
    _$jscoverage['base/broadcast.js'][108]++;
    var list = listeners[topic];
    _$jscoverage['base/broadcast.js'][109]++;
    if (list) {
      _$jscoverage['base/broadcast.js'][110]++;
      for (var i = list.length - 1; i >= 0; i--) {
        _$jscoverage['base/broadcast.js'][111]++;
        var han = list[i], cb = han.cb;
        _$jscoverage['base/broadcast.js'][112]++;
        if (cb) {
          _$jscoverage['base/broadcast.js'][113]++;
          cb.apply(this, args);
        }
}
    }
  }
}), listen: (function (topic, callback) {
  _$jscoverage['base/broadcast.js'][135]++;
  if (! func.isFunction(callback)) {
    _$jscoverage['base/broadcast.js'][135]++;
    throw new Error("callback must be a function");
  }
  _$jscoverage['base/broadcast.js'][136]++;
  var handle = {topic: topic, cb: callback, pos: null};
  _$jscoverage['base/broadcast.js'][141]++;
  var list = listeners[topic];
  _$jscoverage['base/broadcast.js'][142]++;
  if (! list) {
    _$jscoverage['base/broadcast.js'][143]++;
    list = (listeners[topic] = []);
  }
  _$jscoverage['base/broadcast.js'][145]++;
  list.push(handle);
  _$jscoverage['base/broadcast.js'][146]++;
  handle.pos = list.length - 1;
  _$jscoverage['base/broadcast.js'][147]++;
  return handle;
}), unListen: (function (handle) {
  _$jscoverage['base/broadcast.js'][156]++;
  if (handle) {
    _$jscoverage['base/broadcast.js'][157]++;
    var topic = handle.topic, list = listeners[topic];
    _$jscoverage['base/broadcast.js'][158]++;
    if (list) {
      _$jscoverage['base/broadcast.js'][159]++;
      for (var i = list.length - 1; i >= 0; i--) {
        _$jscoverage['base/broadcast.js'][160]++;
        if (list[i] == handle) {
          _$jscoverage['base/broadcast.js'][161]++;
          list.splice(i, 1);
        }
}
      _$jscoverage['base/broadcast.js'][164]++;
      if (! list.length) {
        _$jscoverage['base/broadcast.js'][165]++;
        delete listeners[topic];
      }
    }
  }
})});
_$jscoverage['base/broadcast.js'].source = ["var func = require(\"./functions\"),","\t\tobj = require(\"./object\"),","\t\tdefine = require(\"../define\").define;","","var comb = exports;","","","var wrapper = function() {","\treturn function() {","\t\tvar c = arguments.callee, listeners = c.__listeners, func = c.func, r;","\t\tif (func) {","\t\t\tr = func.apply(this, arguments);","\t\t}","\t\tfor (var i = 0; i &lt; listeners.length; i++) {","\t\t\tvar lis = listeners[i];","\t\t\tif (lis) {","\t\t\t\tlis.apply(this, arguments);","\t\t\t}","\t\t}","\t\treturn r;","","\t}","};","","","var listeners = {};","obj.merge(comb, {","            /**@lends comb*/","\t\t\t/**","\t\t\t * Disconnects a listener to a function","\t\t\t * @param {handle} A handle returned from comb.connect","\t\t\t */","\t\t\tdisconnect : function(handle) {","\t\t\t\tif (handle &amp;&amp; handle.length == 3) {","\t\t\t\t\tvar obj = handle[0], method = handle[1], cb = handle[2];","\t\t\t\t\tif (typeof method != \"string\") throw \"comb.disconnect : When calling disconnect the method must be string\";","\t\t\t\t\tvar scope = obj || global, ls;","\t\t\t\t\tif (typeof scope[method] == \"function\") {","\t\t\t\t\t\tls = scope[method].__listeners;","\t\t\t\t\t\tif (ls &amp;&amp; cb-- &gt; 0) {","\t\t\t\t\t\t\t//we dont want to splice it because our indexing will get off","\t\t\t\t\t\t\tls[cb] = null;","\t\t\t\t\t\t}","\t\t\t\t\t} else {","\t\t\t\t\t\tthrow new Error(\"unknown method \" + method + \" in object \" + obj);","\t\t\t\t\t}","\t\t\t\t} else {","\t\t\t\t\tthrow \"comb.disconnect : invalid handle\"","\t\t\t\t}","\t\t\t},","","\t\t\t/**","\t\t\t * Function to listen when other functions are called","\t\t\t *","\t\t\t * @example","\t\t\t *","\t\t\t *  comb.connect(obj, \"event\", myfunc);","\t\t\t *  comb.connect(obj, \"event\", \"log\", console);","\t\t\t *","\t\t\t * @param {Object} obj the object in which the method you are connection to resides","\t\t\t * @param {String} method the name of the method to connect to","\t\t\t * @param {Function} cb the function to callback","\t\t\t * @param {Object} [scope] the scope to call the specified cb in","\t\t\t *","\t\t\t * @returns {Array} handle to pass to {@link comb.disconnect}","\t\t\t */","\t\t\tconnect : function(obj, method, cb, scope) {","\t\t\t\tvar index;","\t\t\t\tif (typeof method != \"string\") throw new Error(\"When calling connect the method must be string\");","\t\t\t\tif (!func.isFunction(cb)) throw new Error(\"When calling connect callback must be a string\");","\t\t\t\tvar scope = obj || global, listeners, newMethod;","\t\t\t\tif (typeof scope[method] == \"function\") {","\t\t\t\t\tlisteners = scope[method].__listeners;","\t\t\t\t\tif (!listeners) {","\t\t\t\t\t\tnewMethod = wrapper();","\t\t\t\t\t\tnewMethod.func = obj[method];","\t\t\t\t\t\tlisteners = (newMethod.__listeners = []);","\t\t\t\t\t\tscope[method] = newMethod;","\t\t\t\t\t}","\t\t\t\t\tindex = listeners.push(cb);","\t\t\t\t} else {","\t\t\t\t\tthrow new Error(\"unknow method \" + method + \" in object \" + obj);","\t\t\t\t}","\t\t\t\treturn [obj, method, index];","\t\t\t},","","","\t\t\t/**","\t\t\t * Broadcasts an event to all listeners","\t\t\t * NOTE : the function takes a variable number of arguments","\t\t\t *        i.e. all arguments after the topic will be passed to the listeners","\t\t\t *","\t\t\t * @example","\t\t\t *","\t\t\t *","\t\t\t * comb.broadcast(\"hello\", \"hello world\");","\t\t\t * //the args \"hello\" and \"world\" will be passed to any listener of the topic","\t\t\t * //\"hello\"","\t\t\t * comb.broadcast(\"hello\", \"hello\", \"world\");","\t\t\t *","\t\t\t * @param  {String} topic the topic to brodcast","\t\t\t * @param params the information to bradcast","\t\t\t */","\t\t\tbroadcast : function() {","\t\t\t\tvar args = Array.prototype.slice.call(arguments);","\t\t\t\tvar topic = args.splice(0, 1)[0];","\t\t\t\tif (topic) {","\t\t\t\t\tvar list = listeners[topic];","\t\t\t\t\tif (list) {","\t\t\t\t\t\tfor (var i = list.length - 1; i &gt;= 0; i--) {","\t\t\t\t\t\t\tvar han = list[i], cb = han.cb;","\t\t\t\t\t\t\tif (cb) {","\t\t\t\t\t\t\t\tcb.apply(this, args);","\t\t\t\t\t\t\t}","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t}","\t\t\t},","","\t\t\t/**","\t\t\t * Listen for the broadcast of certain events","\t\t\t *","\t\t\t * @example","\t\t\t *  comb.listen(\"hello\", function(arg1, arg2){","\t\t\t *     console.log(arg1);","\t\t\t *     console.log(arg2);","\t\t\t *  });","\t\t\t *","\t\t\t * @param {String} topic the topic to listen for","\t\t\t * @param {Function} callback the funciton to call when the topic is published","\t\t\t *","\t\t\t * @returns a handle to pass to {@link comb.unListen}","\t\t\t */","\t\t\tlisten : function(topic, callback) {","\t\t\t\tif (!func.isFunction(callback)) throw new Error(\"callback must be a function\");","\t\t\t\tvar handle = {","\t\t\t\t\ttopic : topic,","\t\t\t\t\tcb : callback,","\t\t\t\t\tpos : null","\t\t\t\t};","\t\t\t\tvar list = listeners[topic];","\t\t\t\tif (!list) {","\t\t\t\t\tlist = (listeners[topic] = []);","\t\t\t\t}","\t\t\t\tlist.push(handle);","\t\t\t\thandle.pos = list.length - 1;","\t\t\t\treturn handle;","\t\t\t},","","\t\t\t/**","\t\t\t * Disconnects a listener","\t\t\t *","\t\t\t * @param handle a handle returned from {@link comb.listen}","\t\t\t */","\t\t\tunListen : function(handle) {","\t\t\t\tif (handle) {","\t\t\t\t\tvar topic = handle.topic, list = listeners[topic];","\t\t\t\t\tif (list) {","\t\t\t\t\t\tfor (var i = list.length - 1; i &gt;= 0; i--) {","\t\t\t\t\t\t\tif (list[i] == handle) {","\t\t\t\t\t\t\t\tlist.splice(i, 1);","\t\t\t\t\t\t\t}","\t\t\t\t\t\t}","\t\t\t\t\t\tif (!list.length) {","\t\t\t\t\t\t\tdelete listeners[topic];","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t}","\t\t\t}","","\t\t});",""];
