Skip to content

Commit 4bc57ca

Browse files
author
Raphael Levin
committed
fix lint and comments
1 parent ba5bcd8 commit 4bc57ca

File tree

3 files changed

+33
-32
lines changed

3 files changed

+33
-32
lines changed

bundle_size.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const fs = require('fs');
2-
const path = require('path');
32

43
const newDistPath = './dist';
54
const oldDistPath = './dist_old';

docs/api/vast-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ http://example.dailymotion.com/vast.php?domain=mywebsite.com
384384
*/
385385
```
386386

387-
### removeURLTemplateFilter()
387+
### removeLastURLTemplateFilter()
388388

389389
Removes the last element of the url templates filters array.
390390

src/fetcher/fetcher.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export class Fetcher {
6666
* @param {Object} params.wrapperAd - Previously parsed ad node (Wrapper) related to this fetching.
6767
* @param {Number} params.maxWrapperDepth - The maximum number of Wrapper that can be fetch
6868
* @param {Function} params.emitter - The function used to Emit event
69+
* @emits VASTParser#VAST-resolving
70+
* @emits VASTParser#VAST-resolved
6971
* @return {Promise}
7072
*/
7173
fetchVAST({
@@ -76,46 +78,46 @@ export class Fetcher {
7678
previousUrl = null,
7779
wrapperAd = null,
7880
}) {
79-
return new Promise(async (resolve, reject) => {
81+
return new Promise((resolve, reject) => {
8082
const timeBeforeGet = Date.now();
8183

8284
// Process url with defined filter
8385
this.URLTemplateFilters.forEach((filter) => {
8486
url = filter(url);
8587
});
8688

87-
try {
88-
emitter('VAST-resolving', {
89-
url,
90-
previousUrl,
91-
wrapperDepth,
92-
maxWrapperDepth: maxWrapperDepth,
93-
timeout: this.fetchingOptions.timeout,
94-
wrapperAd,
95-
});
89+
emitter('VAST-resolving', {
90+
url,
91+
previousUrl,
92+
wrapperDepth,
93+
maxWrapperDepth,
94+
timeout: this.fetchingOptions.timeout,
95+
wrapperAd,
96+
});
9697

97-
let data = await this.urlHandler.get(url, this.fetchingOptions);
98-
const requestDuration = Math.round(Date.now() - timeBeforeGet);
98+
this.urlHandler
99+
.get(url, this.fetchingOptions)
100+
.then((data) => {
101+
const requestDuration = Math.round(Date.now() - timeBeforeGet);
99102

100-
emitter('VAST-resolved', {
101-
url,
102-
previousUrl,
103-
wrapperDepth,
104-
error: data?.error || null,
105-
duration: requestDuration,
106-
statusCode: data?.statusCode || null,
107-
...data?.details,
108-
});
109-
updateEstimatedBitrate(data?.details?.byteLength, requestDuration);
103+
emitter('VAST-resolved', {
104+
url,
105+
previousUrl,
106+
wrapperDepth,
107+
error: data?.error || null,
108+
duration: requestDuration,
109+
statusCode: data?.statusCode || null,
110+
...data?.details,
111+
});
112+
updateEstimatedBitrate(data?.details?.byteLength, requestDuration);
110113

111-
if (data.error) {
112-
reject(data.error);
113-
} else {
114-
resolve(data.xml);
115-
}
116-
} catch (error) {
117-
reject(error);
118-
}
114+
if (data.error) {
115+
reject(data.error);
116+
} else {
117+
resolve(data.xml);
118+
}
119+
})
120+
.catch((error) => reject(error));
119121
});
120122
}
121123
}

0 commit comments

Comments
 (0)