Last active
May 15, 2020 18:53
-
-
Save urain39/eaf1b07215f7c2c2c2b9db2e1c3eca42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof String.prototype.format !== "function") { | |
String.prototype.format = function (mappable, filter) { | |
var self = this; | |
return self.replace(/\{([0-9A-Za-z_$]+)\}/g, filter ? | |
function(_, key) { return filter(mappable[key]); } | |
: | |
function(_, key) { return mappable[key]; } | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment