JSPM

matrix-rotate

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q29337F
  • License MIT

Rotate a 2D matrix by 90 degrees clockwise with one command

Package Exports

  • matrix-rotate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (matrix-rotate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

matrix-rotate

Rotate a 2D JavaScript array in place by 90 degrees, with a simple command.

Example:

var rotate = require('matrix-rotate');

var matrix = [
    [1,2,3,4],
    [5,6,7,8],
    [9,10,11,12],
    [13,14,15,16]
];

rotate(matrix);

console.log(matrix);
/*
    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).