array-windows
Iterator over all contiguous windows (overlapping subslices) of predetermined
size
from a given array. The windows overlap. If the window slice is shorter
than size
, the iteration ends. size
must not be bigger than the array length.
Install
$ npm install array-windows
$ yarn add array-windows
Use
const arrayWindows = const arr = 'b' 'a' 'l' 'i'const windowSize = 2
API
arrayWindows(array, size, callback)
array
array An array containing the values that we want to iterate through.
number
size It represents how many values to the right of the current iteration index the the algorithm will take into account to call the callback with.
function
callback(win) This function will receive the window slice as an argument, the length of this
array is determined by the size
attribute. If the window slice is shorter than
the size
the iteration ends.