Last active
April 29, 2016 15:21
-
-
Save ViBiOh/6e228557532f8b46b9a8 to your computer and use it in GitHub Desktop.
Extract strings from a javascript source file
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
function isFunction(potentialFunction) { | |
return potentialFunction && Object.prototype.toString.call(potentialFunction) === '[object Function]'; | |
} | |
function stringsReplace(str, callback) { | |
if (isFunction(callback)) { | |
str.replace(/(["'`])((?:(?=(\\?))\3.)*?)\1/gmi, (all, quote, value) => callback(value)); | |
} | |
return str.replace(mustacheRegex, callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.