mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
matchAll -> exec loop
This commit is contained in:
parent
fd9c2ee734
commit
68b1fab369
1 changed files with 4 additions and 1 deletions
|
|
@ -70,7 +70,10 @@
|
||||||
const parts = [];
|
const parts = [];
|
||||||
let lastMatch = 0;
|
let lastMatch = 0;
|
||||||
|
|
||||||
for (const match of usage.matchAll(/`([^`]+)`/g)) {
|
// matchAll isn't common yet, using exec :(
|
||||||
|
const re = /`([^`]+)`/g;
|
||||||
|
let match;
|
||||||
|
while (match = re.exec(usage)) {
|
||||||
if (match.index > 0)
|
if (match.index > 0)
|
||||||
parts.push({type: "str", str: usage.substring(lastMatch, match.index)});
|
parts.push({type: "str", str: usage.substring(lastMatch, match.index)});
|
||||||
parts.push({type: "arg", arg: match[1]});
|
parts.push({type: "arg", arg: match[1]});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue