Higher order generators for 2D arrays traversing
npm i -S traverse-2d
This library provide a Traverser function which return an object with 4 methods to traverse a matrix :
fromTopLeft
fromTopRight
fromBottomLeft
fromBottomRight
They all take a matrix and return a generator
import Traverser from "traverser-2d"
const matrix = [[0, 1, 2, 3], [4, 5, 6], [7, 8, 9]]
// Take a yielder function called on each move in the matrix,
// a column and row predicate,
// which should return true if should go to the next col/row.
// Default functions are provided for all arguments
const T = Traverser()
const traversed = [...T.fromTopLeft(matrix)] // return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Please open an issue for support.
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.