Socket
Socket
Sign inDemoInstall

util-arity

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    util-arity

Set the length of a function.


Version published
Weekly downloads
1.1M
increased by4.03%
Maintainers
1
Install size
5.03 kB
Created
Weekly downloads
 

Readme

Source

Arity

NPM version NPM downloads Build status Test coverage

Set a functions arity (the argument count) by proxying function calls.

P.S. If you need need to enforce arity and don't care about argument length or this, use nary. It's magnitudes faster than using .apply to proxy arguments.

When would I use this?

It's unlikely you'll need to use this utility in everyday development. The reason I wrote it was for functional utilities and backward compatibility with user expectations. For example, many modules use function arity to decide how the function behaves (e.g. error middleware in express, callbacks in mocha).

Installation

npm install util-arity --save

Usage

var fn = function () {};
var arity = require('util-arity');

var oneArg = arity(1, fn);
var twoArgs = arity(2, fn);
var threeArgs = arity(3, fn);

oneArgs.length; //=> 1
twoArgs.length; //=> 2
threeArgs.length; //=> 3

TypeScript

The typings for this project are available for node module resolution with TypeScript.

License

MIT

Keywords

FAQs

Last updated on 28 Jan 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc