🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Book a DemoInstallSign in
Socket

array-types-counter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-types-counter

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

1.0.1
latest
Source
npm
Version published
Weekly downloads
110
-26.17%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

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

Functions

countArrayTypes

▸ countArrayTypes(array: any[]): TypeCount[]

Counts the array's item types

export

Parameters:

NameType
arrayany[]

Returns: TypeCount[]

The array item types ordered by count, descending

Defined in: index.ts:34

Keywords

array

FAQs

Package last updated on 30 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts