async function vacuum(data) {
  if (_vacuuming) return _vacuuming;
  let resolveSelf;
  _vacuuming = new Promise(r => { resolveSelf = r; });
  const noFetch = data && [];
  const sizes = {};
  const result = {};
  const toFetch = [];
  const keysToRemove = [];
  /** -1=untouched, 1=touched, 2(+scriptId)=missing */
  const status = {};
  const prefixRe = RegExp(`^(${[
    S_VALUE_PRE,
    S_CACHE_PRE,
    S_REQUIRE_PRE,
    S_CODE_PRE,
    S_MOD_PRE,
  ].join('|')})`);
  const prefixIgnoreMissing = [
    S_VALUE_PRE,
    S_MOD_PRE,
  ];
  const downloadUrls = {};
  const touch = (prefix, id, scriptId, pathMap) => {
    if (!id || pathMap && isDataUri(id)) {
      return 0;
    }
    const key = prefix + (pathMap?.[id] || id);
    const val = status[key];
    if (val < 0) {
      status[key] = 1;
      if (id !== scriptId) {
        status[S_MOD_PRE + id] = 1;
      }
      if (prefix === S_VALUE_PRE) {
        if ((sizes[key] = deepSize(data[key])) === 2) {
          // remove empty {}
          sizes[key] = 0;
          status[key] = -1;
        }
      } else if (prefix !== S_MOD_PRE) {
        sizes[key] = deepSize(data[key]) + key.length;
      }
    } else if (!val && !prefixIgnoreMissing.includes(prefix)) {
      status[key] = 2 + scriptId;
    }
  };
  if (!data) data = await storage.base.getMulti();
  data::forEachKey((key) => {
    if (prefixRe.test(key)) {
      status[key] = -1;
    }
  });
  scriptSizes = sizes;
  getScriptsByIdsOrAll().forEach((script) => {
    const { meta, props } = script;
    const icon = script.custom.icon || meta.icon;
    const { id } = props;
    const pathMap = script.custom.pathMap || buildPathMap(script);
    const updUrls = getScriptUpdateUrl(script, { all: true });
    if (updUrls) {
      updUrls.forEach(url => touch(S_MOD_PRE, url, id));
      downloadUrls[id] = updUrls[0];
    }
    touch(S_CODE_PRE, id, id);
    touch(S_VALUE_PRE, id, id);
    meta.require.forEach(url => touch(S_REQUIRE_PRE, url, id, pathMap));
    meta.resources::forEachValue(url => touch(S_CACHE_PRE, url, id, pathMap));
    if (isRemote(icon)) touch(S_CACHE_PRE, icon, id, pathMap);
  });
  status::forEachEntry(([key, value]) => {
    if (value < 0) {
      // Removing redundant value
      keysToRemove.push(key);
    } else if (value >= 2) {
      // Downloading the missing code or resource
      const area = storage.forKey(key);
      const id = area.toId(key);
      const url = area.name === S_CODE ? downloadUrls[id] : id;
      if (noFetch) {
        noFetch.push(url || +id && getScriptPrettyUrl(getScriptById(id)) || key);
      } else if (url && area.fetch) {
        keysToRemove.push(S_MOD_PRE + url);
        toFetch.push(area.fetch(url).catch(err => `${
          getScriptName(getScriptById(+id || value - 2))
        }: ${
          formatHttpError(err)
        }`));
      }
    }
  });
  if (keysToRemove.length) {
    await storage.base.remove(keysToRemove); // Removing `mod` before fetching
    result.errors = (await Promise.all(toFetch)).filter(Boolean);
  }
  if (noFetch && noFetch.length) {
    console.warn('Missing required resources. Try vacuuming database in options.', noFetch);
  }
  _vacuuming = null;
  result.fixes = toFetch.length + keysToRemove.length;
  resolveSelf(result);
  return result;
}
@param {Object} [data]
@return {Promise<{errors:string[], fixes:number}>}