dist/node/iterators/thread.js
function getTasks() {
	const tasks = {},
	      tmp = {},
	      mods = {},
	      exec = Object.assign({}, execStack);

	let total = 0,
	    count = 0;

	(0, _core2.default)(exec).forEach((el, key) => {
		tmp[key] = (0, _core2.default)(el).map((el, key) => key);
		mods[key] = 0;
		count++;
	}, el => el.length);

	/* eslint-disable no-loop-func */

	const sort = (a, b) => b.value - a.value;

	while (total <= _thread.MAX_PRIORITY) {
		const rands = [];

		(0, _core2.default)(exec).forEach((el, key) => {
			rands.push({
				key,
				value: _thread.PRIORITY[key]
			});
		}, el => el.length);

		rands.sort(sort);

		let pos = rands.length - 1,
		    max = 0;

		(0, _core2.default)(rands).forEach((el, i) => {
			const interval = intervals[pos];

			if (interval[1] > max) {
				max = interval[1];
			}

			rands[i].value = interval;
			pos--;
		});

		const rand = (0, _math.getRandomInt)(0, max);

		(0, _core2.default)(rands).forEach(({ key, value }) => {
			const arr = tmp[key];

			if (rand >= value[0] && rand <= value[1]) {
				tasks[key] = tasks[key] || [];
				let pos = lastPos[key];

				if (arr[pos] == null) {
					lastPos[key] = pos = 0;
					mods[key] = 0;
				}

				const point = exec[key][arr[pos]];

				if (point && !point.pause) {
					mods[key]++;
					tasks[key].push(arr[pos]);
					total += _thread.PRIORITY[key];
				}

				arr.splice(pos, 1);
				if (!arr.length) {
					delete exec[key];
					count--;
				}

				return false;
			}
		});

		if (!count) {
			break;
		}
	}

	/* eslint-enable no-loop-func */

	(0, _core2.default)(mods).forEach((el, key) => {
		lastPos[key] += el;
	});

	return tasks;
}
function getTasks() {
	const tasks = {},
	      tmp = {},
	      mods = {},
	      exec = Object.assign({}, execStack);

	let total = 0,
	    count = 0;

	(0, _core2.default)(exec).forEach((el, key) => {
		tmp[key] = (0, _core2.default)(el).map((el, key) => key);
		mods[key] = 0;
		count++;
	}, el => el.length);

	/* eslint-disable no-loop-func */

	const sort = (a, b) => b.value - a.value;

	while (total <= _thread.MAX_PRIORITY) {
		const rands = [];

		(0, _core2.default)(exec).forEach((el, key) => {
			rands.push({
				key,
				value: _thread.PRIORITY[key]
			});
		}, el => el.length);

		rands.sort(sort);

		let pos = rands.length - 1,
		    max = 0;

		(0, _core2.default)(rands).forEach((el, i) => {
			const interval = intervals[pos];

			if (interval[1] > max) {
				max = interval[1];
			}

			rands[i].value = interval;
			pos--;
		});

		const rand = (0, _math.getRandomInt)(0, max);

		(0, _core2.default)(rands).forEach(({ key, value }) => {
			const arr = tmp[key];

			if (rand >= value[0] && rand <= value[1]) {
				tasks[key] = tasks[key] || [];
				let pos = lastPos[key];

				if (arr[pos] == null) {
					lastPos[key] = pos = 0;
					mods[key] = 0;
				}

				const point = exec[key][arr[pos]];

				if (point && !point.pause) {
					mods[key]++;
					tasks[key].push(arr[pos]);
					total += _thread.PRIORITY[key];
				}

				arr.splice(pos, 1);
				if (!arr.length) {
					delete exec[key];
					count--;
				}

				return false;
			}
		});

		if (!count) {
			break;
		}
	}

	/* eslint-enable no-loop-func */

	(0, _core2.default)(mods).forEach((el, key) => {
		lastPos[key] += el;
	});

	return tasks;
}
Returns a working plan for the current iteration of the event loop
@return {!Object}