deferred.js
function promiseThen(success, reject, notify){
		/**
		 * @define {object} Return a new promise
		 */
		var def = Deferred();

		/**
		 * Resolved promise
		 * @example example
		 * @param {string} A string key for the event system
		 * @param {function} A callback when event is triggered
		 * @return {object} Returns promise object
		 */
		event.on('resolve', function(){ 
			/**
			 * If the success callback returns a promise
			 * then resolve/reject/notify that returned promise
			 */
			var promise = success();
			if(!promise) return;
			promise.success(function(){
				/** handle the returned deferred object */
				def.resolve();
			});
			promise.error(function(){
				def.reject();
			});
			promise.notify(function(){
				def.notify();
			});
		});

		/**
		 * If promise is rejected/notify trigger the callback
		 */
		event.on('reject', function(){ 
			if(reject) reject();
		});

		event.on('notify', function(){ 
			if(notify) notify();
		});

		/**
		 * @return {object} Returns a promise object
		 */
		return def.promise; 
	}
function promiseThen(success, reject, notify){
		/**
		 * @define {object} Return a new promise
		 */
		var def = Deferred();

		/**
		 * Resolved promise
		 * @example example
		 * @param {string} A string key for the event system
		 * @param {function} A callback when event is triggered
		 * @return {object} Returns promise object
		 */
		event.on('resolve', function(){ 
			/**
			 * If the success callback returns a promise
			 * then resolve/reject/notify that returned promise
			 */
			var promise = success();
			if(!promise) return;
			promise.success(function(){
				/** handle the returned deferred object */
				def.resolve();
			});
			promise.error(function(){
				def.reject();
			});
			promise.notify(function(){
				def.notify();
			});
		});

		/**
		 * If promise is rejected/notify trigger the callback
		 */
		event.on('reject', function(){ 
			if(reject) reject();
		});

		event.on('notify', function(){ 
			if(notify) notify();
		});

		/**
		 * @return {object} Returns a promise object
		 */
		return def.promise; 
	}
function promiseThen ( success , reject , notify ) { /**
		 * @define {object} Return a new promise
		 */ var def = Deferred ( ) ; /**
		 * Resolved promise
		 * @example example
		 * @param {string} A string key for the event system
		 * @param {function} A callback when event is triggered
		 * @return {object} Returns promise object
		 */ event . on ( 'resolve' , function ( ) { /**
			 * If the success callback returns a promise
			 * then resolve/reject/notify that returned promise
			 */ var promise = success ( ) ; if ( ! promise ) return ; promise . success ( function ( ) { /** handle the returned deferred object */ def . resolve ( ) ; } ) ; promise . error ( function ( ) { def . reject ( ) ; } ) ; promise . notify ( function ( ) { def . notify ( ) ; } ) ; } ) ; /**
		 * If promise is rejected/notify trigger the callback
		 */ event . on ( 'reject' , function ( ) { if ( reject ) reject ( ) ; } ) ; event . on ( 'notify' , function ( ) { if ( notify ) notify ( ) ; } ) ; /**
		 * @return {object} Returns a promise object
		 */ return def . promise ; }
Promise then method
This is for chaining promis callbacks
@example promiseFunction().then(
function(){ // success },
function(){ // rejected },
function(){ // notify }
).then( ... );
@param {function} sucess Success callback
@param {function} reject Reject callback
@param {function} notify notify callback
@return {object} Returns the promise object
Promise then method This is for chaining promis callbacks