byuitechops / action-series-master

The master module for all of the action-series child modules.
3 stars 0 forks source link

Switch to a filter #32

Closed zachintosh closed 6 years ago

zachintosh commented 6 years ago

https://github.com/byuitechops/action-series-master/blob/6242a2ffc0f996c03860c1fecf92d3674e47ac5e/actions/universal-fix-dropbox-links.js#L161-L190

Instead of looking through all the links, checking if we have any with HREFs that contain "drop_box", and then looking through them all again, you could just switch this all to a single Array.filter(), and then a forEach on the items provided by the filter. Cheerio has an equivalent filter function. Since forEach doesn't run on an empty arrays (or throw an error), you would be able to skip a lot of the checking happening here.

csammcgrath commented 6 years ago

Fixed with the latest pull request.