Created
May 13, 2021 21:16
-
-
Save peterbe/ec855768f8921db49f09d5e368524d0f 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
function* fastKSParser(s) { | |
for (const match of s.matchAll( | |
/\{\{\s*(\w+[\w-\.]*\w+)\s*(\((.*?)\)|)\s*\}\}/gms | |
)) { | |
const { index } = match; | |
if (s.charAt(index - 1) === "\\") { | |
continue; | |
} | |
const split = (match[3] || "").trim().split(","); | |
yield { | |
name: match[1], | |
args: split, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment