(items, keyOrFn)
| 107 | } |
| 108 | |
| 109 | function countBy(items, keyOrFn) { |
| 110 | const counts = {}; |
| 111 | for (const item of items) { |
| 112 | const key = typeof keyOrFn === 'function' ? keyOrFn(item) : item && item[keyOrFn]; |
| 113 | const safeKey = key || 'unknown'; |
| 114 | counts[safeKey] = (counts[safeKey] || 0) + 1; |
| 115 | } |
| 116 | return counts; |
| 117 | } |
| 118 | |
| 119 | function filterText(items, q) { |
| 120 | if (!q) return items; |
no outgoing calls
no test coverage detected