MCPcopy Create free account
hub / github.com/github/docs / countArrayValues

Function countArrayValues

script/search/validate-records.js:5–11  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

3import { isArray, isString } from 'lodash-es'
4
5function countArrayValues(arr) {
6 const counter = new Map()
7 arr.forEach((value) => counter.set(value, (counter.get(value) || 0) + 1))
8 return [...counter.entries()].map(([value, count]) => {
9 return { value, count }
10 })
11}
12
13export default function validateRecords(name, records) {
14 assert(isString(name) && name.length, '`name` is required')

Callers 1

validateRecordsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected