Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-array-of-length

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-array-of-length

Returns true if a value is an array containing the specified number of elements.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-17.09%
Maintainers
1
Weekly downloads
 
Created
Source

is-array-of-length

Returns true if a value is an array containing the specified number of elements.

Installation

Requires Node.js 6.0.0 or above.

npm i is-array-of-length

API

The module exports a single function.

Parameters

  1. arr (any): What may or may not be an array
  2. lengths (integer or array): One or more integers, each of which represents an acceptable number of items in the array.
  3. Optional: Object argument:
    • arrays (class, string, or array): One or more classes or names of classes that should be treated as equivalent to Array.

Return Values

  • true if arr is an array with a length given in lengths
  • false otherwise

Example

const isArrayOfLength = require('is-array-of-length')

isArrayOfLength(['a', 'b'], 2) // true
isArrayOfLength(['a', 'b'], 3) // false
isArrayOfLength(['a', 'b'], [2, 3]) // true
isArrayOfLength('7 chars', 7) // false

// Supports the bind operator
['a', 'b']::isArrayOfLength(2) // true

Keywords

FAQs

Package last updated on 01 Sep 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc