then(success, error = noop) {
      const getResponseStatus = event => ({
        ok: event.target.status >= 200 && event.target.status < 300,
        status: event.target.status,
        statusText: event.target.statusText,
      });

      if (hasBar) {
        const id = setInterval(
          _ =>
            progressbar({
              step: Math.floor(Math.random() * 5 + 1),
            }),
          500,
        );

        xhr.addEventListener('progress', progressbar);
        xhr.addEventListener('loadend', evt => {
          progressbar(evt);
          clearInterval(id);
        });
      }

      xhr.addEventListener('error', event => {
        error(event, getResponseStatus(event));
      });

      xhr.addEventListener('load', event => {
        const target = /** @type {XMLHttpRequest} */ (event.target);

        if (target.status >= 400) {
          error(event, getResponseStatus(event));
        } else {
          if (typeof target.response !== 'string') {
            throw new TypeError('Unsupported content type.');
          }

          const result = (cache[url] = {
            content: target.response,
            opt: {
              updatedAt: xhr.getResponseHeader('last-modified') ?? '',
            },
          });

          success(result.content, result.opt, getResponseStatus(event));
        }
      });
    }
@param {(text: string, opt: CacheOpt, response: ResponseStatus) => void} success
@param {(event: ProgressEvent<XMLHttpRequestEventTarget>, response: ResponseStatus) => void} error