mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
feat(docgen): typescript support
This commit is contained in:
28
packages/docgen/src/util/splitVarName.ts
Normal file
28
packages/docgen/src/util/splitVarName.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export function splitVarName(str: string) {
|
||||
const res: string[][] = [];
|
||||
let currGroup: string[] = [];
|
||||
let currStr = '';
|
||||
|
||||
const isASymbol = (char: string) => '-!$%^&*()_+|~=`{}[]:;<>?, '.includes(char);
|
||||
|
||||
for (const char of str) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
currGroup.push(currStr);
|
||||
res.push(currGroup);
|
||||
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user