| Index: lib/coreUtils.js |
| =================================================================== |
| --- a/lib/coreUtils.js |
| +++ b/lib/coreUtils.js |
| @@ -29,8 +29,29 @@ |
| } |
| exports.desc = desc; |
| function extend(cls, properties) |
| { |
| return Object.create(cls.prototype, desc(properties)); |
| } |
| exports.extend = extend; |
| + |
| +function indexOf(iterable, searchElement) |
| +{ |
| + return findIndex(iterable, item => item === searchElement); |
| +} |
| +exports.indexOf = indexOf; |
| + |
| +function findIndex(iterable, callback, thisArg) |
|
kzar
2018/03/19 20:53:22
Nit: Could you put findIndex first since indexOf c
Manish Jethani
2018/03/20 11:34:58
Done.
|
| +{ |
| + let index = 0; |
| + for (let item of iterable) |
| + { |
| + if (callback.call(thisArg, item)) |
| + return index; |
| + |
| + index++; |
| + } |
| + |
| + return -1; |
| +} |
| +exports.findIndex = findIndex; |