traverse-2d

1.0.1 • Public • Published

Traverse-2d

Node version contributions welcome JavaScript Style Guide Known Vulnerabilities

Higher order generators for 2D arrays traversing

Table of Contents

Installation

npm i -S traverse-2d

Usage

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]

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

Readme

Keywords

none

Package Sidebar

Install

npm i traverse-2d

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

18.2 kB

Total Files

9

Last publish

Collaborators

  • elcoosp