|
|
@ -22,7 +22,9 @@ const slideNext = (host, window, hostPos, windowPos, len = 1) => { |
|
|
|
return (len); |
|
|
|
}; |
|
|
|
|
|
|
|
const startSliding = (k, host, guest, window, windowPos) => { |
|
|
|
const startSliding = (k, predicate, host, guest, window, windowPos) => { |
|
|
|
|
|
|
|
const test = predicate ? predicate : isEq; |
|
|
|
|
|
|
|
const firstMatch = host.findIndex(wrap(isEq, window[0])); |
|
|
|
|
|
|
@ -38,14 +40,14 @@ const startSliding = (k, host, guest, window, windowPos) => { |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const slide = (k, host, guest) => { |
|
|
|
const slide = (k, predicate, host, guest) => { |
|
|
|
|
|
|
|
if (k > host.length) return errors.WIN_TOO_LARGE_HOST; |
|
|
|
if (k > guest.length) return errors.WIN_TOO_LARGE_GUEST; |
|
|
|
|
|
|
|
// Create a new window and start sliding
|
|
|
|
const window = guest.slice(0, k); |
|
|
|
return startSliding(k, host, guest, window, 0); |
|
|
|
return startSliding(k, predicate, host, guest, window, 0); |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = slide; |