MCPcopy Create free account
hub / github.com/tensorflow/tfjs / count

Function count

tfjs-layers/src/utils/generic_utils.ts:48–56  ·  view source on GitHub ↗
(array: T[], refernce: T)

Source from the content-addressed store, hash-verified

46 * Count the number of elements of the `array` that are equal to `reference`.
47 */
48export function count<T>(array: T[], refernce: T) {
49 let counter = 0;
50 for (const item of array) {
51 if (item === refernce) {
52 counter++;
53 }
54 }
55 return counter;
56}
57
58/**
59 * If an array is of length 1, just return the first element. Otherwise, return

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…