Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
array-types-counter
Advanced tools
Simple helper to obtain the count of different array item's types.
Simple helper to obtain the count of different array item's types.
Using npm, npm i array-types-counter
.
Using yarn, yarn add array-types-counter
.
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}]
▸ countArrayTypes(array
: any[]): TypeCount[]
Counts the array's item types
export
Name | Type |
---|---|
array | any[] |
Returns: TypeCount[]
The array item types ordered by count, descending
Defined in: index.ts:34
FAQs
Simple helper to obtain the count of different array item's types.
We found that array-types-counter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.