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

Unified Diff: lib/coreUtils.js

Issue 29780560: Issue 6665 - Optimize element hiding emulation filter lookups (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Update JSDoc Created May 13, 2018, 8:30 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
« no previous file with comments | « no previous file | lib/elemHideEmulation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/coreUtils.js
===================================================================
--- a/lib/coreUtils.js
+++ b/lib/coreUtils.js
@@ -50,8 +50,40 @@
}
exports.findIndex = findIndex;
function indexOf(iterable, searchElement)
{
return findIndex(iterable, item => item === searchElement);
}
exports.indexOf = indexOf;
+
+function* filterIt(iterable, callback, thisArg)
+{
+ for (let item of iterable)
+ {
+ if (callback.call(thisArg, item))
+ yield item;
+ }
+}
+exports.filterIt = filterIt;
+
+function* mapIt(iterable, callback, thisArg)
+{
+ for (let item of iterable)
+ yield callback.call(thisArg, item);
+}
+exports.mapIt = mapIt;
+
+function* flattenIt(iterable, callback, thisArg)
+{
+ for (let item of iterable)
+ yield* item;
+}
+exports.flattenIt = flattenIt;
+
+function* regExpIt(regExp, string)
+{
+ let match = null;
+ while (match = regExp.exec(string))
+ yield match;
+}
+exports.regExpIt = regExpIt;
« no previous file with comments | « no previous file | lib/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld