Browse Source

[fix] call custom predicate

master
Muthu Kumar 6 years ago
parent
commit
ce6d45823f
  1. 2
      lib/slideHelper.js
  2. 2
      test.js

2
lib/slideHelper.js

@ -26,7 +26,7 @@ const startSliding = (k, predicate, host, guest, window, windowPos) => {
const test = predicate ? predicate : isEq;
const firstMatch = host.findIndex(wrap(isEq, window[0]));
const firstMatch = host.findIndex(wrap(test, window[0]));
// If first item returns a match, then continue to slideNext()
const len = firstMatch ? slideNext(host, guest, firstMatch, windowPos) : undefined;

2
test.js

@ -3,5 +3,5 @@ const Slider = require('.');
const a = [ 0, 1, 2, 3, 4, 5 ];
const b = [ 2, 3, 4 ];
const w = new Slider({ size: 3 });
const w = new Slider({ size: 3 , predicate: (a, b) => a === b });
console.log(w.slide(a, b));
Loading…
Cancel
Save