forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateRight.js
More file actions
30 lines (25 loc) · 725 Bytes
/
Copy pathRotateRight.js
File metadata and controls
30 lines (25 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Moves the element at the end of the array to the start, shifting all items in the process.
// The "rotation" happens to the right.
/**
* [description]
*
* @function Phaser.Utils.Array.RotateRight
* @since 3.0.0
*
* @param {array} array - The array to shift to the right. This array is modified in place.
* @param {integer} [total=1] - The number of times to shift the array.
*
* @return {any} The most recently shifted element.
*/
var RotateRight = function (array, total)
{
if (total === undefined) { total = 1; }
var element = null;
for (var i = 0; i < total; i++)
{
element = array.pop();
array.unshift(element);
}
return element;
};
module.exports = RotateRight;