vendor/assets/elfinder_OLD/js/elfinder.full.js
function(func, arr, opts) {
		var dfrd = $.Deferred(),
			abortFlg = false,
			parms = Object.assign({
				interval : 0,
				numPerOnce : 1
			}, opts || {}),
			resArr = [],
			vars =[],
			curVars = [],
			exec,
			tm;
		
		dfrd._abort = function(resolve) {
			tm && clearTimeout(tm);
			vars = [];
			abortFlg = true;
			if (dfrd.state() === 'pending') {
				dfrd[resolve? 'resolve' : 'reject'](resArr);
			}
		};
		
		dfrd.fail(function() {
			dfrd._abort();
		}).always(function() {
			dfrd._abort = function() {};
		});

		if (typeof func === 'function' && Array.isArray(arr)) {
			vars = arr.concat();
			exec = function() {
				var i, len, res;
				if (abortFlg) {
					return;
				}
				curVars = vars.splice(0, parms.numPerOnce);
				len = curVars.length;
				for (i = 0; i < len; i++) {
					if (abortFlg) {
						break;
					}
					res = func(curVars[i]);
					(res !== null) && resArr.push(res);
				}
				if (abortFlg) {
					return;
				}
				if (vars.length) {
					tm = setTimeout(exec, parms.interval);
				} else {
					dfrd.resolve(resArr);
				}
			};
			if (vars.length) {
				tm = setTimeout(exec, 0);
			} else {
				dfrd.resolve(resArr);
			}
		} else {
			dfrd.reject();
		}
		return dfrd;
	}
function(func, arr, opts) {
		var dfrd = $.Deferred(),
			abortFlg = false,
			parms = Object.assign({
				interval : 0,
				numPerOnce : 1
			}, opts || {}),
			resArr = [],
			vars =[],
			curVars = [],
			exec,
			tm;
		
		dfrd._abort = function(resolve) {
			tm && clearTimeout(tm);
			vars = [];
			abortFlg = true;
			if (dfrd.state() === 'pending') {
				dfrd[resolve? 'resolve' : 'reject'](resArr);
			}
		};
		
		dfrd.fail(function() {
			dfrd._abort();
		}).always(function() {
			dfrd._abort = function() {};
		});

		if (typeof func === 'function' && Array.isArray(arr)) {
			vars = arr.concat();
			exec = function() {
				var i, len, res;
				if (abortFlg) {
					return;
				}
				curVars = vars.splice(0, parms.numPerOnce);
				len = curVars.length;
				for (i = 0; i < len; i++) {
					if (abortFlg) {
						break;
					}
					res = func(curVars[i]);
					(res !== null) && resArr.push(res);
				}
				if (abortFlg) {
					return;
				}
				if (vars.length) {
					tm = setTimeout(exec, parms.interval);
				} else {
					dfrd.resolve(resArr);
				}
			};
			if (vars.length) {
				tm = setTimeout(exec, 0);
			} else {
				dfrd.resolve(resArr);
			}
		} else {
			dfrd.reject();
		}
		return dfrd;
	}
function ( func , arr , opts ) { var dfrd = $ . Deferred ( ) , abortFlg = false , parms = Object . assign ( { interval : 0 , numPerOnce : 1 } , opts || { } ) , resArr = [ ] , vars = [ ] , curVars = [ ] , exec , tm ; dfrd . _abort = function ( resolve ) { tm && clearTimeout ( tm ) ; vars = [ ] ; abortFlg = true ; if ( dfrd . state ( ) === 'pending' ) { dfrd [ resolve ? 'resolve' : 'reject' ] ( resArr ) ; } } ; dfrd . fail ( function ( ) { dfrd . _abort ( ) ; } ) . always ( function ( ) { dfrd . _abort = function ( ) { } ; } ) ; if ( typeof func === 'function' && Array . isArray ( arr ) ) { vars = arr . concat ( ) ; exec = function ( ) { var i , len , res ; if ( abortFlg ) { return ; } curVars = vars . splice ( 0 , parms . numPerOnce ) ; len = curVars . length ; for ( i = 0 ; i < len ; i ++ ) { if ( abortFlg ) { break ; } res = func ( curVars [ i ] ) ; ( res !== null ) && resArr . push ( res ) ; } if ( abortFlg ) { return ; } if ( vars . length ) { tm = setTimeout ( exec , parms . interval ) ; } else { dfrd . resolve ( resArr ) ; } } ; if ( vars . length ) { tm = setTimeout ( exec , 0 ) ; } else { dfrd . resolve ( resArr ) ; } } else { dfrd . reject ( ) ; } return dfrd ; }
Abortable async job performer

@param func Function
@param arr  Array
@param opts Object

@return Object $.Deferred that has an extended method _abort()
Abortable async job performer