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) |
Manish Jethani
2018/05/13 20:39:48
These are helper functions as described in Trac #6
|
+{ |
+ 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; |