JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 159
  • Score
    100M100P100Q68013F
  • License MIT

Handles given Arguments object - return separatly last argument (commonly callback) and other arguments as Array. Useful in node-style callback flow. Used by `hybridify`.

Package Exports

  • handle-arguments

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (handle-arguments) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

handle-arguments npmjs.com The MIT License

Handles given Arguments object - return separatly last argument (commonly callback) and other arguments as Array. Useful in node-style callback flow. Used by hybridify

code climate standard code style travis build status coverage status dependency status

Install

npm i handle-arguments --save

Features

API

For more use-cases see the tests

handleArguments

  • <argsObject> {Arguments} the arguments object
  • return {Object}
    • callback {Function} last argument if function or undefined
    • cb {Function} alias of callback
    • arguments {Array} all arguments without last (the callback)
    • args {Array} alias of arguments

Example:

var handleArguments = require('handle-arguments')

function fixture () {
  return handleArguments(arguments)
}

console.log(fixture(1, 2, 3))
//=> {callback: undefined, cb: undefined
// arguments: [1, 2, 3], args: [1, 2, 3]}

console.log(fixture(1, 2, function _callback_ () {}))
//=> {callback: [Function: _callback_], cb: [Function: _callback_],
// arguments: [1, 2], args: [1, 2]}

instead of commonly used pattern

function fixture () {
  var args = [].slice.call(arguments)
  var len = args.length
  var callback = args[len - 1]

  if (typeof callback === 'function') {
    args = args.slice(0, -1)
    callback.apply(null, [null].concat(args))
  }
  return args
}
  • async-exec-cmd: Simple, fast, flexible and cross-platform async executing commands (with node-cross-spawn).
  • bluebird: Full featured Promises/A+ implementation with exceptionally good performance
  • hybridify: Building hybrid APIs. You can use both callback and promise in same time. Like… more
  • handle-callback: Initial step for creating hybrid APIs, used by hybridify. Handle callback in promise - give… more
  • manage-arguments: Prevents arguments leakage - managing arguments. From Optimization killers by Petka Antonov. Powers handle-arguments
  • Optimization killers by @petkaantonov

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github