Socket
Book a DemoInstallSign in
Socket

arg-find

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

arg-find

write functions that accept arguments in any order

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

arg-find

Write functions that accept arguments in any order (so long as each is of a unique type). It’s weird, yes, but I sometimes find this useful for handling optional parameters.

Build status

Install

$ npm install arg-find

Example

var find = require('arg-find')

function fn () {
  var arg = find(arguments)
  var opt = arg('object') || {}
  var cb = arg('function')

  opt.throw ?
    cb(new Error) :
    cb(null)
}

fn(function (err) {
  console.log(err)
  > null
})

fn({ throw: true }, function (err) {
  console.log(err instanceof Error)
  > true
})

fn(function (err) {
  console.log(err instanceof Error)
  > true
}, { throw: true })

License

MIT

Keywords

arguments

FAQs

Package last updated on 01 Jun 2016

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