argument-index

Pass an argument at a specified index along to a function

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
argument-index
001.0.07 years ago7 years agoMinified + gzip package size for argument-index in KB

Readme

argument-index Build Status
Pass an argument at a specified index along to a function

Install

$ npm install --save argument-index

Usage

var argument = require('argument-index')

var doubleSecond = argument(1, function double (value) {
  return value * 2
})

doubleSecond(1, 2)
//=> 4

doubleSecond(2, 5)
//=> 10

API

argument(index, fn) -> function

Returns a function (outer) that will call fn (inner) with the outer argument at index.
index
Required
Type: number
The numeric index of the argument to process.
fn
Required
Type: function
Arguments: value
A single argument function that will be called with the argument at the specified index.

License

MIT © Ben Drucker