mirror of https://github.com/codefeathers/window
Muthu Kumar
7 years ago
3 changed files with 20 additions and 45 deletions
@ -1,26 +0,0 @@ |
|||
class Deck extends Array { |
|||
|
|||
recurse (fn) { |
|||
let index = 0; |
|||
const call = (arr, acc = []) => { |
|||
if(arr[0]) { |
|||
const res = fn(index++, arr[0]); |
|||
return call(arr.slice(1), [ res, ...acc ]); |
|||
} |
|||
return acc; |
|||
}; |
|||
return call(this); |
|||
} |
|||
|
|||
findIndexAfter(index, predicate) { |
|||
const self = this; |
|||
let i = index + 1; |
|||
while(i < self.length) { |
|||
if(predicate(self[i])) return i; |
|||
i++; |
|||
} |
|||
return -1; |
|||
} |
|||
}; |
|||
|
|||
module.exports = Deck; |
Loading…
Reference in new issue