function xhr(url, format) {
  /**
   * @param {import("./extent.js").Extent} extent Extent.
   * @param {number} resolution Resolution.
   * @param {import("./proj/Projection.js").default} projection Projection.
   * @param {function(Array<FeatureType>): void} [success] Success
   *      Function called when loading succeeded.
   * @param {function(): void} [failure] Failure
   *      Function called when loading failed.
   * @this {import("./source/Vector.js").default<FeatureType>}
   */
  return function (extent, resolution, projection, success, failure) {
    loadFeaturesXhr(
      url,
      format,
      extent,
      resolution,
      projection,
      /**
       * @param {Array<FeatureType>} features The loaded features.
       * @param {import("./proj/Projection.js").default} dataProjection Data
       * projection.
       */
      (features, dataProjection) => {
        this.addFeatures(features);
        if (success !== undefined) {
          success(features);
        }
      },
      () => {
        this.changed();
        if (failure !== undefined) {
          failure();
        }
      },
    );
  };
}
Create an XHR feature loader for a `url` and `format`. The feature loader
loads features (with XHR), parses the features, and adds them to the
vector source.

@template {import("./Feature.js").FeatureLike} [FeatureType=import("./Feature.js").default]
@param {string|FeatureUrlFunction} url Feature URL service.
@param {import("./format/Feature.js").default<FeatureType>} format Feature format.
@return {FeatureLoader<FeatureType>} The feature loader.
@api