Strip a leading emoji token (and trailing whitespace) from a heading
line, repeatedly, so headings like 🚀 ⚠️ Risk Scoring become Risk Scoring.
The implementation peels the string character-by-character via
String.prototype[Symbol.iterator] to correctly handle astral-plane
pictographics, VS-16 (\uFE0F), and ZWJ sequences — without the
nested quantifier patterns that would trigger
security/detect-unsafe-regex.
Parameters
text: string
Heading text (without the leading # )
Returns string
Trimmed text with any leading emoji tokens removed
Strip a leading emoji token (and trailing whitespace) from a heading line, repeatedly, so headings like
🚀 ⚠️ Risk ScoringbecomeRisk Scoring.The implementation peels the string character-by-character via
String.prototype[Symbol.iterator]to correctly handle astral-plane pictographics, VS-16 (\uFE0F), and ZWJ sequences — without the nested quantifier patterns that would triggersecurity/detect-unsafe-regex.