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

Function findInArray

third_party/subscriptions-project/swg.js:3062–3076  ·  view source on GitHub ↗

* Implements `Array.find()` method that's not yet available in all browsers. * * @param {?Array } array * @param {function(T, number, !Array ):boolean} predicate * @return {?T} * @template T

(array, predicate)

Source from the content-addressed store, hash-verified

3060 * @template T
3061 */
3062function findInArray(array, predicate) {
3063 if (!array) {
3064 return null;
3065 }
3066 const len = array.length || 0;
3067 if (len > 0) {
3068 for (let i = 0; i < len; i++) {
3069 const other = array[i];
3070 if (predicate(other, i, array)) {
3071 return other;
3072 }
3073 }
3074 }
3075 return null;
3076}
3077
3078/**
3079 * Copyright 2019 The Subscribe with Google Authors. All Rights Reserved.

Callers 1

getEntitlementForMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected