MCPcopy Index your code
hub / github.com/nodejs/node / breakIntoSpans

Function breakIntoSpans

test/fixtures/snapshot/typescript.js:142743–142766  ·  view source on GitHub ↗
(identifier, word)

Source from the content-addressed store, hash-verified

142741 }
142742 ts.breakIntoWordSpans = breakIntoWordSpans;
142743 function breakIntoSpans(identifier, word) {
142744 var result = [];
142745 var wordStart = 0;
142746 for (var i = 1; i < identifier.length; i++) {
142747 var lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
142748 var currentIsDigit = isDigit(identifier.charCodeAt(i));
142749 var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
142750 var hasTransitionFromUpperToLower = word && transitionFromUpperToLower(identifier, i, wordStart);
142751 if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
142752 charIsPunctuation(identifier.charCodeAt(i)) ||
142753 lastIsDigit !== currentIsDigit ||
142754 hasTransitionFromLowerToUpper ||
142755 hasTransitionFromUpperToLower) {
142756 if (!isAllPunctuation(identifier, wordStart, i)) {
142757 result.push(ts.createTextSpan(wordStart, i - wordStart));
142758 }
142759 wordStart = i;
142760 }
142761 }
142762 if (!isAllPunctuation(identifier, wordStart, identifier.length)) {
142763 result.push(ts.createTextSpan(wordStart, identifier.length - wordStart));
142764 }
142765 return result;
142766 }
142767 function charIsPunctuation(ch) {
142768 switch (ch) {
142769 case 33 /* CharacterCodes.exclamation */:

Callers 2

breakIntoCharacterSpansFunction · 0.85
breakIntoWordSpansFunction · 0.85

Calls 6

isDigitFunction · 0.85
charIsPunctuationFunction · 0.85
isAllPunctuationFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…