MCPcopy Create free account
hub / github.com/ampproject/amphtml / compareStringArrays_

Method compareStringArrays_

extensions/amp-bind/0.1/bind-impl.js:1638–1650  ·  view source on GitHub ↗

* Returns true if both arrays contain the same strings. * @param {!(IArrayLike |Array )} a * @param {!(IArrayLike |Array )} b * @return {boolean} * @private

(a, b)

Source from the content-addressed store, hash-verified

1636 * @private
1637 */
1638 compareStringArrays_(a, b) {
1639 if (a.length !== b.length) {
1640 return false;
1641 }
1642 const sortedA = (isArray(a) ? a : toArray(a)).sort();
1643 const sortedB = (isArray(b) ? b : toArray(b)).sort();
1644 for (let i = 0; i < a.length; i++) {
1645 if (sortedA[i] !== sortedB[i]) {
1646 return false;
1647 }
1648 }
1649 return true;
1650 }
1651
1652 /**
1653 * Copies an object containing JSON data and returns it.

Callers 1

verifyBinding_Method · 0.95

Calls 2

toArrayFunction · 0.90
isArrayFunction · 0.85

Tested by

no test coverage detected