Created
April 29, 2016 13:18
-
-
Save andreasvirkus/ff1f191821654f46a5c9ada7ad033728 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
* | |
* This function does not attempt to implement all of sprintf, just %s, | |
* which is the only one that I ever use. | |
*/ | |
function sprintf(text){ | |
var i = 1, | |
args = arguments; | |
return text.replace(/%s/g, function(pattern) { | |
return (i < args.length) ? args[i++] : ""; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment