And for those that stumble into this thread looking for it, my version works on the following theory:
For a given Matrix NxM: (Note: This works on non-square arrays!)
Example:
N=5,M=3
[[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]]
Or:
[
[1,2,3],
[4,5,6],
[7,8,9],
[10,11,12],
[13,14,15]
]
A clockwise shift represents rotation such that the elements of a given column X should at the end be the elements of row X, with the order of elements being reversed.
IE, the rotation of the above matrix should be the 3x5:
[
[13,10,7,4,1],
[14,11,8,5,2],
[15,12,9,6,3]
]
It is observed that if the elements of the matrix are laid out as a single dimensional array in ascending order across the rows of the matrix:
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
that the elements corresponding to a given row of the resultant matrix must be kM distance from the other elements of that row, with k being an integer;
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
(The distance between any two numbers with the same coloring is M)
in this way, the resulting matrix can be formed by taking groupings of values with indices kM+o, with o being from 0 to N-1, and k being from 0 to array.length/M. These groupings must be reversed to provide the correct ordering of elements.
So,
function rotateMatrix(matrix) {
var theta = matrix.reduce((omega,alpha) => omega.concat(alpha));
var delta = [];
for(x = 0; x < matrix[0].length; x++) {
i = x;
delta[x] = [];
while(i < theta.length) {
delta[x].push(theta[i]);
i += matrix[0].length;
}
delta[x].reverse();
}
return delta;
}

(to rotate counterclockwise, run the X loop in reverse, set i to matrix[0].length-1-x instead of x, and do not reverse the results.)