All files async-quick-sort.js

100% Statements 9/9
83.33% Branches 5/6
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 381x                               871x 871x             870x 513x     870x 343x       870x     1x  
const { asyncPartition } = require('./helpers');
 
/**
 * Async Quick Sort
 *
 * Asynchronously sorts an iterable using quick-sort algorithm
 * @ignore
 * @param {any[]} iterable
 * @param {Number} leftIndex
 * @param {Number} rightIndex
 * @param {Function} compareFunc
 * @return {any[]}
 */
async function asyncQuickSort(iterable, leftIndex, rightIndex, compareFunc) {
	let index;
 
	Eif (iterable.length > 1) {
		index = await asyncPartition(
			iterable,
			leftIndex,
			rightIndex,
			compareFunc
		);
 
		if (leftIndex < index - 1) {
			await asyncQuickSort(iterable, leftIndex, index - 1, compareFunc);
		}
 
		if (index < rightIndex) {
			await asyncQuickSort(iterable, index, rightIndex, compareFunc);
		}
	}
 
	return iterable;
}
 
module.exports = { asyncQuickSort };