async function _databaseExists(name) {
	const indexedDB = globalThis.indexedDB;

	if (!indexedDB) {
		throw new Error('IndexedDB is not supported in this browser');
	}

	if (indexedDB.databases) {
		const dbs = await indexedDB.databases();
		const db = dbs.find(db => db.name === name);
		// @ts-ignore
		return db || 0;
	}

	// Try if it exist
	const req = indexedDB.open(name);

	return new Promise(function (resolve, reject) {
		req.onsuccess = () => {
			req.result.close();
			resolve({name, version: req.result.version});
		};

		req.onupgradeneeded = evt => {
			evt.target.transaction.abort();
			resolve(0);
		};

		req.onerror = () => {
			reject(new Error('IndexedDB error'));
		};

		req.onblocked = () => {
			resolve({name, version: req.result.version});
		};
	});
}
@param {string} name
@returns {Promise<{name: string, version: number}|0>}