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

arity-of

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arity-of

Exposes max arity and other metadata for JS functions

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

arity-of

Build Status Dependencies Status npm Coverage Status Install Size Known Vulnerabilities

An NPM library that exposes max arity and other metadata for JS functions

This package implements the es-shim API interface. It works in an ES6-supported environment and complies with the spec (TODO this is a lie. Write a proposal).

Concepts

"Arity" refers to the number of parameters a function declares.

function (a, b, c) {} declares 3 parameters so has a minimum and maximum arity of 3.

function (a, b = 0, ...rest) {} declares 3 parameters. It has a minimum arity of 1 since there is no default value for a. It has a maximum arity of 3 since that is the number declared. It uses a rest parameter ...rest so it can actually take additional parameters.

Installation

npm install arity-of

Usage

const arityOf = require('arity-of');

function myFunction(a, b = 0, [c, d], ...e) {
  // ...
}

myFunction.length;   // Minimum arity

const {
  max,               // Maximum arity (including any ...restParamater)
  usesRest,          // True if there is a ...restParameter.
} = arityOf(myFunction);

Keywords

FAQs

Package last updated on 08 Jul 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