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

Function equalArraysOrString

packages/router/src/utils/collection.ts:52–64  ·  view source on GitHub ↗
(
  a: string | readonly string[],
  b: string | readonly string[],
)

Source from the content-addressed store, hash-verified

50 * Test equality for arrays of strings or a string.
51 */
52export function equalArraysOrString(
53 a: string | readonly string[],
54 b: string | readonly string[],
55): boolean {
56 if (Array.isArray(a) && Array.isArray(b)) {
57 if (a.length !== b.length) return false;
58 const aSorted = [...a].sort();
59 const bSorted = [...b].sort();
60 return aSorted.every((val, index) => bSorted[index] === val);
61 } else {
62 return a === b;
63 }
64}
65
66/**
67 * Return the last element of an array.

Callers 2

containsParamsFunction · 0.90
shallowEqualFunction · 0.85

Calls 1

isArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…