|
@ -29,12 +29,12 @@ const startSliding = (k, predicate, host, guest, window, windowPos) => { |
|
|
const firstMatch = host.findIndex(wrap(test, window[0])); |
|
|
const firstMatch = host.findIndex(wrap(test, window[0])); |
|
|
|
|
|
|
|
|
// If first item returns a match, then continue to slideNext()
|
|
|
// If first item returns a match, then continue to slideNext()
|
|
|
const len = firstMatch ? slideNext(host, guest, firstMatch, windowPos) : undefined; |
|
|
const len = (firstMatch !== -1) ? slideNext(host, guest, firstMatch, windowPos) : undefined; |
|
|
if (len && len > 1) return converter(firstMatch, windowPos, len); |
|
|
if (len && len > 1) return converter(firstMatch, windowPos, len); |
|
|
|
|
|
|
|
|
const nextWindowPos = windowPos + 1; |
|
|
const nextWindowPos = windowPos + 1; |
|
|
const newWindow = guest.slice(nextWindowPos, nextWindowPos + k); |
|
|
const newWindow = guest.slice(nextWindowPos, nextWindowPos + k); |
|
|
if (newWindow.length === k) return startSliding(newWindow, nextWindowPos); |
|
|
if (newWindow.length === k) return startSliding(k, predicate, host, guest, newWindow, nextWindowPos); |
|
|
|
|
|
|
|
|
return errors.COULD_NOT_SLIDE; |
|
|
return errors.COULD_NOT_SLIDE; |
|
|
|
|
|
|
|
|