Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/common.js

Issue 29417597: Issue 5161 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created April 19, 2017, 4:33 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ext/common.js
===================================================================
--- a/ext/common.js
+++ b/ext/common.js
@@ -68,11 +68,29 @@
{
return chrome.extension.getBackgroundPage();
}
};
/* Utils */
+ ext.mapIterable = function(iterable, callback, thisArg)
Sebastian Noack 2017/04/29 22:46:32 Why do we need this helper? IMO the calling code s
Manish Jethani 2017/05/04 14:47:33 Fair enough, the function that used this now retur
+ {
+ let iterator = iterable[Symbol.iterator]();
+ return {
+ [Symbol.iterator]()
+ {
+ return this;
+ },
+ next()
+ {
+ let next = iterator.next();
+ if (!next.done)
+ next.value = callback.call(thisArg, next.value);
+ return next;
+ }
+ };
+ };
+
ext.getURL = chrome.extension.getURL;
ext.i18n = chrome.i18n;
}());

Powered by Google App Engine
This is Rietveld