corq.js
function $item(corq, item){
		var typeName = item.type;
		if (!corq.callbacks[typeName]){
			throw "Item handler not found for items of type `" + typeName + "`";
		}
		$debug(corq, 'Corq: Calling handler for item `' + typeName + '`');
		$debug(corq, item.data);
		var _next = function(){
			var freq = (corq.delay) ? corq.delayLength : corq.frequency;
			setTimeout(function(){
				$next(corq);
			}, freq);
		};
		var _success = function(){
			$debug(corq, 'Corq: Item processing SUCCESS `' + typeName + '` ');
			$debug(corq, item.data);
			$success(corq,item);
			_next();
		};
		var _fail = function(){
			$debug(corq, 'Corq: Item processing FAILURE `' + typeName + '` ');
			$debug(corq, item.data);
			$fail(corq, item);
			_next();
		};
		try {
			corq.callbacks[typeName](item.data, _success, _fail);
		}catch(e){
			$debug(corq, 'Corq: Error thrown by item processing function `' + typeName + '` ');
			$debug(corq, item.data);
			_fail();
			throw e;
		}
	}
function $item(corq, item){
		var typeName = item.type;
		if (!corq.callbacks[typeName]){
			throw "Item handler not found for items of type `" + typeName + "`";
		}
		$debug(corq, 'Corq: Calling handler for item `' + typeName + '`');
		$debug(corq, item.data);
		var _next = function(){
			var freq = (corq.delay) ? corq.delayLength : corq.frequency;
			setTimeout(function(){
				$next(corq);
			}, freq);
		};
		var _success = function(){
			$debug(corq, 'Corq: Item processing SUCCESS `' + typeName + '` ');
			$debug(corq, item.data);
			$success(corq,item);
			_next();
		};
		var _fail = function(){
			$debug(corq, 'Corq: Item processing FAILURE `' + typeName + '` ');
			$debug(corq, item.data);
			$fail(corq, item);
			_next();
		};
		try {
			corq.callbacks[typeName](item.data, _success, _fail);
		}catch(e){
			$debug(corq, 'Corq: Error thrown by item processing function `' + typeName + '` ');
			$debug(corq, item.data);
			_fail();
			throw e;
		}
	}
function $item ( corq , item ) { var typeName = item . type ; if ( ! corq . callbacks [ typeName ] ) { throw "Item handler not found for items of type `" + typeName + "`" ; } $debug ( corq , 'Corq: Calling handler for item `' + typeName + '`' ) ; $debug ( corq , item . data ) ; var _next = function ( ) { var freq = ( corq . delay ) ? corq . delayLength : corq . frequency ; setTimeout ( function ( ) { $next ( corq ) ; } , freq ) ; } ; var _success = function ( ) { $debug ( corq , 'Corq: Item processing SUCCESS `' + typeName + '` ' ) ; $debug ( corq , item . data ) ; $success ( corq , item ) ; _next ( ) ; } ; var _fail = function ( ) { $debug ( corq , 'Corq: Item processing FAILURE `' + typeName + '` ' ) ; $debug ( corq , item . data ) ; $fail ( corq , item ) ; _next ( ) ; } ; try { corq . callbacks [ typeName ] ( item . data , _success , _fail ) ; } catch ( e ) { $debug ( corq , 'Corq: Error thrown by item processing function `' + typeName + '` ' ) ; $debug ( corq , item . data ) ; _fail ( ) ; throw e ; } }
calls all necessary handlers for this item
calls all necessary handlers for this item