matrix-rotate
Rotate a 2D JavaScript array in place by 90 degrees, with a simple command.
Example:
var rotate = ; var matrix = 1234 5678 9101112 13141516; ; console;/* Output: [ [ 13, 9, 5, 1 ], [ 14, 10, 6, 2 ], [ 15, 11, 7, 3 ], [ 16, 12, 8, 4 ] ]; */
Installation
npm install matrix-rotate
Preconditions
- Matrices are square (it cannot rotate a non-square matrix).