Give me a basic summary of what this function does:
export function query<T extends (...args: P) => R, P extends ReadonlyArray<any>, R>(
	errorHandling: Function,
	fn: T,
): T {
	return (async (...args: P) => {
		if (updatingToken) throw new Error("updating token");
		try {
			return await fn(...args);
		} catch (error) {
			updatingToken = true;
			const retry = await errorHandling(error);
			updatingToken = false;
			if (retry) return await fn(...args);
			else throw error;
		}
	}) as T;
}
system
Give me a basic summary of what this function does:
export function query<T extends (...args: P) => R, P extends ReadonlyArray<any>, R>(
	errorHandling: Function,
	fn: T,
): T {
	return (async (...args: P) => {
		if (updatingToken) throw new Error("updating token");
		try {
			return await fn(...args);
		} catch (error) {
			updatingToken = true;
			const retry = await errorHandling(error);
			updatingToken = false;
			if (retry) return await fn(...args);
			else throw error;
		}
	}) as T;
}
user
The query function returns an asynchronous callback that attempts to call a provided function. If there is an error, it executes the provided error handling function and retries the function call if possible.
assistant
<|system|>
</s>
<|user|>
Give me a basic summary of what this function does:
export function query<T extends (...args: P) => R, P extends ReadonlyArray<any>, R>(
	errorHandling: Function,
	fn: T,
): T {
	return (async (...args: P) => {
		if (updatingToken) throw new Error("updating token");
		try {
			return await fn(...args);
		} catch (error) {
			updatingToken = true;
			const retry = await errorHandling(error);
			updatingToken = false;
			if (retry) return await fn(...args);
			else throw error;
		}
	}) as T;
}</s>
<|assistant|>
The query function returns an asynchronous callback that attempts to call a provided function. If there is an error, it executes the provided error handling function and retries the function call if possible.</s>
