{"name":"handle-arguments","version":"3.0.4","description":"Handles given Arguments object - return separatly last argument (commonly callback) and other arguments as Array. Useful in node-style callback flow. Used by `hybridify`.","repository":{"type":"git","url":"git+https://github.com/hybridables/handle-arguments.git"},"author":{"name":"Charlike Mike Reagent","email":"@tunnckoCore","url":"http://www.tunnckocore.tk"},"main":"index.js","license":"MIT","scripts":{"test":"standard && node test.js"},"dependencies":{"is-arguments":"^1.0.1","sliced":"^1.0.1"},"devDependencies":{"assertit":"^0.1.0"},"files":["index.js"],"keywords":["api","apis","aplus","args","argument","arguments","bluebird","callback","callbacks","cb","handle","handle-callback","hybrid","hybrid-apis","hybridify","promise","promises","promises-aplus","then"],"gitHead":"a84a5c119a0a3f213b9782555162afb6e422b78b","bugs":{"url":"https://github.com/hybridables/handle-arguments/issues"},"homepage":"https://github.com/hybridables/handle-arguments#readme","_id":"handle-arguments@3.0.4","_shasum":"204ab5c7820bce75d0411791dca0f846b7e3cbf6","_from":".","_npmVersion":"3.2.2","_nodeVersion":"3.0.0","_npmUser":{"name":"tunnckocore","email":"mameto_100@mail.bg"},"dist":{"shasum":"204ab5c7820bce75d0411791dca0f846b7e3cbf6","tarball":"http://registry-npm.ywwl.com/handle-arguments/download/handle-arguments-3.0.4.tgz","integrity":"sha512-t8avRrzMuTnmnYvBO5cggJzAG/5xeY0jwky4wB9nmdo1yzaub7b2FItCmOfCUkFmiRDWGZiTaqQut1AmkM6SMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHTg8VcwNMJciNee4eq4GLchN9iQJVajC9EocII+fR4kAiEAyxLeQo9ygfxpcAetZ/LfEqTUI7LbuhmjVcgcQxoEeXM="}],"size":3980,"noattachment":false,"key":"/handle-arguments/-/handle-arguments-3.0.4.tgz"},"maintainers":[{"name":"tunnckocore","email":"mameto_100@mail.bg"}],"directories":{},"readme":"# [handle-arguments][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] \n\n> Get separately non-callback arguments in `.arguments` and the last argument if it [is-callback-function][] in `.callback`. It also works like [sliced][], but returns object with `.arguments` and `.callback` properties.\n\n[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]\n\n## Install\n```\nnpm i handle-arguments --save\n```\n\n## Usage\n> For more use-cases see the [tests](./test.js)\n\n```js\nconst handleArguments = require('handle-arguments')\n```\n\n### [handleArguments](index.js#L55)\n> Get separately non-callback arguments in `.arguments`, and the last function if it [is-callback-function][] in `.callback`. Signature is like [sliced][], it works almost the same way, but returns object with `.arguments` and `.callback` properties.\n\n**Params**\n\n* `argz` **{Array|Arguments}**: Arguments object or array to eat.    \n* `names` **{Array|Number}**: If array directly passed to [is-callback-function][], otherwise to [sliced][].    \n* `index` **{Number}**: Passed directly to [sliced][] if `number`.    \n* `returns` **{Object}**  \n\n**Example**\n\n```js\nvar handle = require('handle-arguments')\n\nfunction fixture () {\n  return handle(arguments)\n}\n\nfunction cb () {}\nfunction noop () {}\n\nconsole.log(fixture(1, 2, 3, 4).arguments) // => [1, 2, 3, 4]\nconsole.log(fixture(1, 2, 3, 4).callback) // => false\n\nconsole.log(fixture(1, 2, cb).arguments) // => [1, 2]\nconsole.log(fixture(1, 2, cb).callback) // => [Function: cb]\n\nconsole.log(fixture(1, 2, noop).arguments) // => [1, 2, noop]\nconsole.log(fixture(1, 2, noop).callback) // => false\n\n// treat functions named `noop` or `foo` as callback\nfunction fn () {\n  return handle(arguments, ['foo', 'noop'])\n}\n\nconsole.log(fn(1, 2, 3, noop).arguments) // => [1, 2, 3]\nconsole.log(fn(1, 2, 3, noop).callback) // => [Function: noop]\n```\n\n### Instead of commonly used and wrong pattern\n> It is part of \"Optiomization Killers\" and needed very much, so we need correct pattern to reuse.\n \n```js\nfunction fixture () {\n  var args = [].slice.call(arguments)\n  var len = args.length\n  var callback = args[len - 1]\n\n  if (typeof callback === 'function') {\n    args = args.slice(0, -1)\n    callback.apply(null, [null].concat(args))\n  }\n  return args\n}\n```\n\n## Related\n* [arr-includes](https://www.npmjs.com/package/arr-includes): Return true if any of passed values exists in array. Using [in-array][]. | [homepage](https://github.com/tunnckocore/arr-includes)\n* [common-callback-names](https://www.npmjs.com/package/common-callback-names): List of common callback names - callback, cb, callback_, next, done. | [homepage](https://github.com/tunnckocore/common-callback-names)\n* [function-arguments](https://www.npmjs.com/package/function-arguments): Get arguments of a function, useful for and used in dependency injectors.… [more](https://www.npmjs.com/package/function-arguments) | [homepage](https://github.com/tunnckocore/function-arguments)\n* [get-fn-name](https://www.npmjs.com/package/get-fn-name): Get function name with strictness and correctness in mind. Also works for… [more](https://www.npmjs.com/package/get-fn-name) | [homepage](https://github.com/tunnckocore/get-fn-name)\n* [is-async-function](https://www.npmjs.com/package/is-async-function): Is function really asynchronous function? Trying to guess that based on check… [more](https://www.npmjs.com/package/is-async-function) | [homepage](https://github.com/tunnckocore/is-async-function)\n* [is-callback-function](https://www.npmjs.com/package/is-callback-function): Returns true if function is a callback. Checks its name is one… [more](https://www.npmjs.com/package/is-callback-function) | [homepage](https://github.com/tunnckocore/is-callback-function)\n* [parse-function](https://www.npmjs.com/package/parse-function): Parse a function, arrow function or string to object with name, args,… [more](https://www.npmjs.com/package/parse-function) | [homepage](https://github.com/tunnckocore/parse-function)\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/hybridables/handle-arguments/issues/new).  \nBut before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.\n\n## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]\n\n[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]\n\n[in-array]: https://github.com/jonschlinkert/in-array\n[is-callback-function]: https://github.com/tunnckocore/is-callback-function\n[sliced]: https://github.com/aheckmann/sliced\n\n[npmjs-url]: https://www.npmjs.com/package/handle-arguments\n[npmjs-img]: https://img.shields.io/npm/v/handle-arguments.svg?label=handle-arguments\n\n[license-url]: https://github.com/hybridables/handle-arguments/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/handle-arguments.svg\n\n[downloads-url]: https://www.npmjs.com/package/handle-arguments\n[downloads-img]: https://img.shields.io/npm/dm/handle-arguments.svg\n\n[codeclimate-url]: https://codeclimate.com/github/hybridables/handle-arguments\n[codeclimate-img]: https://img.shields.io/codeclimate/github/hybridables/handle-arguments.svg\n\n[travis-url]: https://travis-ci.org/hybridables/handle-arguments\n[travis-img]: https://img.shields.io/travis/hybridables/handle-arguments/master.svg\n\n[coveralls-url]: https://coveralls.io/r/hybridables/handle-arguments\n[coveralls-img]: https://img.shields.io/coveralls/hybridables/handle-arguments.svg\n\n[david-url]: https://david-dm.org/hybridables/handle-arguments\n[david-img]: https://img.shields.io/david/hybridables/handle-arguments.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[author-www-url]: http://www.tunnckocore.tk\n[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg\n\n[keybase-url]: https://keybase.io/tunnckocore\n[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg\n\n[author-npm-url]: https://www.npmjs.com/~tunnckocore\n[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg\n\n[author-twitter-url]: https://twitter.com/tunnckoCore\n[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg\n\n[author-github-url]: https://github.com/tunnckoCore\n[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg\n\n[freenode-url]: http://webchat.freenode.net/?channels=charlike\n[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg\n\n[new-message-url]: https://github.com/tunnckoCore/ama\n[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg","publish_time":1441757909095,"_cnpm_publish_time":1441757909095,"dist-tags":{"latest":"3.1.0"}}