<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [countBy](./brick-next-pipes.countby.md)

## countBy() function

统计一个集合中每个元素的指定属性（或迭代器执行结果）的值出现的次数。

 Collection

**Signature:**

```typescript
export declare function countBy(collection: unknown[] | Record<string, unknown>, iteratee: string | number): Record<string, number>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  collection | unknown\[\] \| Record&lt;string, unknown&gt; | 数据集合。 |
|  iteratee | string \| number | 属性名（或迭代器）。 |

**Returns:**

Record&lt;string, number&gt;

统计结果。

## Remarks

透传调用 [\_.countBy](https://lodash.com/docs/#countBy)<!-- -->。

## Example


```ts
countBy([6.1, 4.2, 6.3], Math.floor);
// => { '4': 1, '6': 2 }

countBy(['one', 'two', 'three'], 'length');
// => { '3': 2, '5': 1 }
```


