Skip to content

Commit

Permalink
refactor for..of to reduce array instead
Browse files Browse the repository at this point in the history
  • Loading branch information
natalan committed Jun 7, 2019
1 parent d9168b1 commit 3b751a6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/js/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ function performPrint (iframeElement, params) {
}

function loadIframeImages (images) {
const promises = []

for (let image of images) {
if (image.src && image.src !== window.location.href) promises.push(loadIframeImage(image))
}
const promises = Array.prototype.slice.call(images).reduce((memo, image) => {
if (image.src && image.src !== window.location.href) {
memo.push(loadIframeImage(image));
}
return memo;
}, []);

return Promise.all(promises)
}
Expand Down

0 comments on commit 3b751a6

Please sign in to comment.