arcade-physics
Version:
Use Arcade Physics without Phaser.
28 lines • 997 B
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Takes a string and replaces instances of markers with values in the given array.
* The markers take the form of `%1`, `%2`, etc. I.e.:
*
* `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])`
*
* @function Phaser.Utils.String.Format
* @since 3.0.0
*
* @param {string} string - The string containing the replacement markers.
* @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead.
*
* @return {string} The string containing replaced values.
*/
const Format = (string, values) => {
return string.replace(/%([0-9]+)/g, (s, n) => {
return values[Number(n) - 1];
});
};
exports.default = Format;
//# sourceMappingURL=Format.js.map