mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(VarType): parsing type names
This commit is contained in:
@@ -17,18 +17,31 @@ export class DocumentedVarType extends DocumentedItem<VarType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private splitVarName(str: string) {
|
private splitVarName(str: string) {
|
||||||
if (str === '*') return ['*'];
|
const res: string[][] = [];
|
||||||
str = str.replace(/\./g, '');
|
let currGroup: string[] = [];
|
||||||
const matches = str.match(/([\w*]+)([^\w*]+)/g);
|
let currStr = '';
|
||||||
const output = [];
|
|
||||||
if (matches) {
|
const isASymbol = (char: string) => '-!$%^&*()_+|~=`{}[]:;<>?, '.includes(char);
|
||||||
for (const match of matches) {
|
|
||||||
const groups = /([\w*]+)([^\w*]+)/.exec(match);
|
for (const char of str) {
|
||||||
output.push([groups![1], groups![2]]);
|
const currentlyInASymbolSection = isASymbol(currStr[0]!);
|
||||||
|
const charIsASymbol = isASymbol(char);
|
||||||
|
|
||||||
|
if (currStr.length && currentlyInASymbolSection !== charIsASymbol) {
|
||||||
|
currGroup.push(currStr);
|
||||||
|
currStr = char;
|
||||||
|
|
||||||
|
if (!charIsASymbol) {
|
||||||
|
res.push(currGroup);
|
||||||
|
currGroup = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currStr += char;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
output.push([str.match(/([\w*]+)/g)![0]]);
|
|
||||||
}
|
}
|
||||||
return output;
|
currGroup.push(currStr);
|
||||||
|
res.push(currGroup);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user