parse(
    vastXml,
    {
      url = null,
      resolveAll = true,
      wrapperSequence = null,
      previousUrl = null,
      wrapperDepth = 0,
      isRootVAST = false,
      followAdditionalWrappers,
      allowMultipleAds,
    } = {}
  ) {
    let ads = [];
    // allowMultipleAds was introduced in VAST 3 as wrapper attribute
    // for retrocompatibility set it to true for vast pre-version 3
    if (this.vastVersion && parseFloat(this.vastVersion) < 3 && isRootVAST) {
      allowMultipleAds = true;
    }
    try {
      ads = this.parseVastXml(vastXml, {
        isRootVAST,
        url,
        wrapperDepth,
        allowMultipleAds,
        followAdditionalWrappers,
      });
    } catch (e) {
      return Promise.reject(e);
    }

    /* Keep wrapper sequence value to not break AdPod when wrapper contain only one Ad.
    e.g,for a AdPod containing :
    - Inline with sequence=1
    - Inline with sequence=2
    - Wrapper with sequence=3 wrapping a Inline with sequence=1
    once parsed we will obtain :
    - Inline sequence 1,
    - Inline sequence 2,
    - Inline sequence 3
  */
    if (
      ads.length === 1 &&
      wrapperSequence !== undefined &&
      wrapperSequence !== null
    ) {
      ads[0].sequence = wrapperSequence;
    }

    // Split the VAST in case we don't want to resolve everything at the first time
    if (resolveAll === false) {
      this.remainingAds = parserUtils.splitVAST(ads);
      // Remove the first element from the remaining ads array, since we're going to resolve that element
      ads = this.remainingAds.shift();
    }

    return this.resolveAds(ads, { wrapperDepth, previousUrl, url });
  }
/**
   * Parses the given xml Object into an array of unwrapped ads.
   * Returns a Promise which resolves with the array or rejects with an error according to the result of the parsing.
   * @param {Object} vastXml - An object representing an xml document.
   * @param {Object} options - An optional Object of parameters to be used in the parsing process.
   * @emits VASTParser#VAST-resolving
   * @emits VASTParser#VAST-resolved
   * @emits VASTParser#VAST-warning
   * @return {Promise}
   */
Parses the given xml Object into an array of unwrapped ads.
Returns a Promise which resolves with the array or rejects with an error according to the result of the parsing.
@param {Object} vastXml - An object representing an xml document.
@param {Object} options - An optional Object of parameters to be used in the parsing process.
Parses the given xml Object into an array of unwrapped ads . Returns a Promise which resolves with the array or rejects with an error according to the result of the parsing . @param { Object } vastXml - An object representing an xml document . @param { Object } options - An optional Object of parameters to be used in the parsing process .
parse(
    vastXml,
    {
      url = null,
      resolveAll = true,
      wrapperSequence = null,
      previousUrl = null,
      wrapperDepth = 0,
      isRootVAST = false,
      followAdditionalWrappers,
      allowMultipleAds,
    } = {}
  ) {
    let ads = [];
    if (this.vastVersion && parseFloat(this.vastVersion) < 3 && isRootVAST) {
      allowMultipleAds = true;
    }
    try {
      ads = this.parseVastXml(vastXml, {
        isRootVAST,
        url,
        wrapperDepth,
        allowMultipleAds,
        followAdditionalWrappers,
      });
    } catch (e) {
      return Promise.reject(e);
    }
    if (
      ads.length === 1 &&
      wrapperSequence !== undefined &&
      wrapperSequence !== null
    ) {
      ads[0].sequence = wrapperSequence;
    }
    if (resolveAll === false) {
      this.remainingAds = parserUtils.splitVAST(ads);
      ads = this.remainingAds.shift();
    }
    return this.resolveAds(ads, { wrapperDepth, previousUrl, url });
  }
parse ( vastXml , { url = null , resolveAll = true , wrapperSequence = null , previousUrl = null , wrapperDepth = 0 , isRootVAST = false , followAdditionalWrappers , allowMultipleAds , } = { } ) { let ads = [ ] ; if ( this . vastVersion && parseFloat ( this . vastVersion ) < 3 && isRootVAST ) { allowMultipleAds = true ; } try { ads = this . parseVastXml ( vastXml , { isRootVAST , url , wrapperDepth , allowMultipleAds , followAdditionalWrappers , } ) ; } catch ( e ) { return Promise . reject ( e ) ; } if ( ads . length === 1 && wrapperSequence !== undefined && wrapperSequence !== null ) { ads [ 0 ] . sequence = wrapperSequence ; } if ( resolveAll === false ) { this . remainingAds = parserUtils . splitVAST ( ads ) ; ads = this . remainingAds . shift ( ) ; } return this . resolveAds ( ads , { wrapperDepth , previousUrl , url } ) ; }
Parses the given xml Object into an array of unwrapped ads.
Parses the given xml Object into an array of unwrapped ads .
// allowMultipleAds was introduced in VAST 3 as wrapper attribute // for retrocompatibility set it to true for vast pre-version 3 /* Keep wrapper sequence value to not break AdPod when wrapper contain only one Ad.
    e.g,for a AdPod containing :
    - Inline with sequence=1
    - Inline with sequence=2
    - Wrapper with sequence=3 wrapping a Inline with sequence=1
    once parsed we will obtain :
    - Inline sequence 1,
    - Inline sequence 2,
    - Inline sequence 3
  */ // Split the VAST in case we don't want to resolve everything at the first time // Remove the first element from the remaining ads array, since we're going to resolve that element