MCPcopy Index your code
hub / github.com/angular/angular / classIndexOf

Function classIndexOf

packages/core/src/render3/styling/class_differ.ts:22–46  ·  view source on GitHub ↗
(
  className: string,
  classToSearch: string,
  startingIndex: number,
)

Source from the content-addressed store, hash-verified

20 * @returns an index of the located class (or -1 if not found)
21 */
22export function classIndexOf(
23 className: string,
24 classToSearch: string,
25 startingIndex: number,
26): number {
27 ngDevMode && assertNotEqual(classToSearch, '', 'can not look for "" string.');
28 let end = className.length;
29 while (true) {
30 const foundIndex = className.indexOf(classToSearch, startingIndex);
31 if (foundIndex === -1) return foundIndex;
32 if (foundIndex === 0 || className.charCodeAt(foundIndex - 1) <= CharCode.SPACE) {
33 // Ensure that it has leading whitespace
34 const length = classToSearch.length;
35 if (
36 foundIndex + length === end ||
37 className.charCodeAt(foundIndex + length) <= CharCode.SPACE
38 ) {
39 // Ensure that it has trailing whitespace
40 return foundIndex;
41 }
42 }
43 // False positive, keep searching from where we left off.
44 startingIndex = foundIndex + 1;
45 }
46}

Callers 2

isCssClassMatchingFunction · 0.90

Calls 2

assertNotEqualFunction · 0.90
indexOfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…