Skip to content

Commit fbd1ba0

Browse files
committed
Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
1 parent a0c771d commit fbd1ba0

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
321321

322322
* The Loader has a new property `headers`. This is an object checked by XHR Requests, used to set the Request Header of certain file types. JSON and XML are pre-configured, but you can add to, or modify this property as required (thanks @stoneman1 #2585 #2485)
323323
* Phaser now has support for Typings, the TypeScript Definition Manager. See the `typescript/readme.md` file for installation instructions (thanks @monagames #2576)
324-
*
324+
* Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
325325

326326
### Updates
327327

src/utils/Utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
*/
1111
Phaser.Utils = {
1212

13+
/**
14+
* Takes the given string and reverses it, returning the reversed string.
15+
* For example if given the string `Atari 520ST` it would return `TS025 iratA`.
16+
*
17+
* @method Phaser.Utils.reverseString
18+
* @param {string} string - The string to be reversed.
19+
* @return {string} The reversed string.
20+
*/
21+
reverseString: function (string) {
22+
23+
return string.split('').reverse().join('');
24+
25+
},
26+
1327
/**
1428
* Gets an objects property by string.
1529
*

typescript/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5468,6 +5468,7 @@ declare module Phaser {
54685468
static setProperty(obj: any, prop: string, value: any): any;
54695469
static chanceRoll(chance: number): boolean;
54705470
static randomChoice(choice1: string | number, choice2: any): any;
5471+
static reverseString(string: string): string;
54715472
static parseDimension(size: any, dimension: number): number;
54725473
static pad(str: string, len?: number, pad?: string, dir?: number): string;
54735474
static isPlainObject(object: any): boolean;

0 commit comments

Comments
 (0)