Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
/ traverse-2d Public archive

Higher order generators for 2d arrays traversing

License

Notifications You must be signed in to change notification settings

elcoosp/traverse-2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Higher order generators for 2d arrays traversing

Resources

License

Stars

Watchers

Forks

Packages

No packages published