abort-utils icon indicating copy to clipboard operation
abort-utils copied to clipboard

Add `abortAll(iterable)` and `abortAllAndClear(iterable)`

Open fregante opened this issue 7 months ago • 0 comments

function abortAll(iterable) {
	for (const controller of iterable) {
		controller.abort();
	}
}

function abortAllAndClear(iterable) {
	abortAll(iterable);
	
	if (Array.isArray(iterable)) {
		iterable.length = 0;
	} else {
		iterable.clear();
	}
}

fregante avatar Jul 09 '24 07:07 fregante