# array-types-counter

> Simple helper to obtain the count of different array item's types.

Latest version **1.0.1** (published 2021-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install array-types-counter
pnpm add array-types-counter
yarn add array-types-counter
bun add array-types-counter
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-05-30 |
| First published | 2021-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alberto Rico |
| Maintainers | alrico88 |
| Keywords | array, types, count |

## Links

- npm: https://www.npmjs.com/package/array-types-counter
- Repository: https://github.com/alrico88/array-types-counter
- npm.io page: https://npm.io/package/array-types-counter

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.21
- [number-helper-functions](https://npm.io/package/number-helper-functions.md) ^4.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-05-30

## README

# array-types-counter

Simple helper to obtain the count of different array item's types.

## Installation

Using npm, `npm i array-types-counter`.

Using yarn, `yarn add array-types-counter`.

## Usage

Using `import`

```javascript
import { countArrayTypes } from 'array-types-counter';

const array = [1, 2, 'three', [1, 2, 3]];

const counts = countArrayTypes(array);

// counts is [{type: 'number', count: 2}, {type: 'string', count: 1}, {type: 'object', count: 1}]
```

In a CommonJS environment

```javascript
const { countArrayTypes } = require('array-types-counter');

const array = [1, 2, '3', [1, 2, 3]]; // Strings that can be casted to numbers, count as numbers

const counts = countArrayTypes(array);

// counts is [{type: 'number', count: 3}, {type: 'object', count: 1}]
```

## Table of contents

### Functions

- [countArrayTypes](modules.md#countarraytypes)

## Functions

### countArrayTypes

▸ **countArrayTypes**(`array`: _any_[]): TypeCount[]

Counts the array's item types

**`export`**

#### Parameters:

| Name    | Type    |
| :------ | :------ |
| `array` | _any_[] |

**Returns:** TypeCount[]

The array item types ordered by count, descending

Defined in: [index.ts:34](https://github.com/alrico88/array-types-counter/blob/b562c59/src/index.ts#L34)

---
_Source: https://npm.io/package/array-types-counter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
