<commit_before>import {app} from 'electron';
import pEvent from 'p-event';
import pTimeout from 'p-timeout';

export function appReady() {
	if (app.isReady()) {
		return Promise.resolve();
	}
	return pTimeout(
		pEvent(app, 'ready'),
		2000
	);
}

export function focusWindow(window) {
	if (window.isFocused()) {
		return Promise.resolve(true);
	}

	window.focus();

	if (window.isFocused()) {
		return Promise.resolve(true);
	}

	return pTimeout(
		pEvent(window, 'focus').then(() => true),
		500
	).catch(err => {
		err.message = err.message.replace('Promise', 'Focus promise');
		throw err;
	});
}

export function minimizeWindow(window) {
	if (window.isMinimized()) {
		return Promise.resolve(true);
	}

	window.minimize();

	if (window.isMinimized()) {
		return Promise.resolve(true);
	}

	return pTimeout(
		pEvent(window, 'minimize').then(() => true),
		500
	).catch(err => {
		err.message = err.message.replace('Promise', 'Minimize promise');
		throw err;
	});
}

export async function restoreWindow(window) {
	if (!window.isMinimized()) {
		return Promise.resolve(true);
	}

	window.restore();

	if (!window.isMinimized()) {
		return Promise.resolve(true);
	}

	return pTimeout(<commit_msg>sync check in next tick<commit_after>import {app} from 'electron';
import pEvent from 'p-event';
import pTimeout from 'p-timeout';

export function appReady() {
	if (app.isReady()) {
		return Promise.resolve();
	}
	return pTimeout(
		pEvent(app, 'ready'),
		2000
	);
}

export function focusWindow(window) {
	if (window.isFocused()) {
		return Promise.resolve(true);
	}

	window.focus();

	if (window.isFocused()) {
		return Promise.resolve(true);
	}

	return pTimeout(
		pEvent(window, 'focus').then(() => true),
		500
	).catch(err => {
		err.message = err.message.replace('Promise', 'Focus promise');
		throw err;
	});
}

export function minimizeWindow(window) {
	if (window.isMinimized()) {
		return Promise.resolve(true);
	}

	window.minimize();

	return Promise.resolve().then(() =>
		(window.isMinimized()) ?

			Promise.resolve(true) :

			pTimeout(
				pEvent(window, 'minimize').then(() => true),
				500
			).catch(err => {
				err.message = err.message.replace('Promise', 'Minimize promise');
				throw err;
			})
	);
}

export async function restoreWindow(window) {
	if (!window.isMinimized()) {
		return Promise.resolve(true);
	}

	window.restore();

	if (!window.isMinimized()) {
		return Promise.resolve(true);
	}

	return pTimeout(
{'fraction_non_alphanumeric': 0.1704824202780049, 'fraction_numerical': 0.008176614881439084, 'mean_word_length': 4.206382978723404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3117382', 'n_tokens_mistral': 920, 'n_tokens_neox': 827, 'n_words': 180}