Created
November 12, 2018 17:49
-
-
Save zerobias/7c8fae23c670a51552dfbbee0dc7aba6 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
| // @flow | |
| /** | |
| * Simple function for formatting strings. | |
| * Replaces placeholders with values passed as extra arguments | |
| */ | |
| export default function sprintf(format: string, ...args: mixed[]) { | |
| let index = 0; | |
| return format.replace(/%s/g, match => String(args[index++])); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment