{"_id":"partial-apply","_rev":"209456","name":"partial-apply","description":"Call a function using an array of arguments while maintaining its original \"this\" context.","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"time":{"modified":"2021-06-03T15:25:23.000Z","created":"2014-05-31T05:26:02.142Z","0.1.0":"2014-05-31T05:26:02.142Z"},"users":{},"author":{"name":"Mike McNeil"},"repository":{"type":"git","url":"git://github.com/balderdashy/partial-apply.git"},"versions":{"0.1.0":{"name":"partial-apply","version":"0.1.0","description":"Call a function using an array of arguments while maintaining its original \"this\" context.","main":"index.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/balderdashy/partial-apply.git"},"keywords":["lodash","_","call","partial","this","context","apply","_.partial"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/balderdashy/partial-apply/issues"},"homepage":"https://github.com/balderdashy/partial-apply","dependencies":{"lodash":"~2.4.1"},"devDependencies":{"should":"~2.1.1"},"_id":"partial-apply@0.1.0","dist":{"shasum":"8befee9b59022da6b424880136325e54d8c7400b","size":1819,"noattachment":false,"key":"/partial-apply/-/partial-apply-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/partial-apply/download/partial-apply-0.1.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1401513962142,"_cnpm_publish_time":1401513962142,"_hasShrinkwrap":false}},"readme":"# partial-apply\n\nImplements a context-free version of `Function.prototype.apply` in Node.js/JavaScript.\n\n\nIf `someFn` has unknown arguments, and we want to pass those arguments through\nto a wrapped function, say `someOtherFn`, we can use `someOtherFn.apply()` to\ncall the wrapped function with `someFn`'s arguments.\n\nBut in the process, we corrupt the \"this\" context of the wrapped function.\nIn order to have it stay correctly defined, we have to pass in the context manually.\nThis creates some nasty dependencies and hurts reusability in your code base.\n\n`_.partial()` in lodash gets us a bit closer, but it does not support an **array**\nof arguments- just arguments passed in one after the other, like `_.partial(fn,x0,x1,etc)`.\n\nFor example, if we expected `someOtherFn` in the example below to have its \"this\"\nvalue refer to, say, a Waterline model, it's actually quite annoying in vanilla\nJavaScript to pass down a dynamic array of arguments to a function AND maintain its\noriginal \"this\" context.\n\nAnyway, this is why `partial-apply` was created.\n\n\n## Installation\n\n```sh\n$ npm install partial-apply\n```\n\n## Usage\n\n```javascript\nvar partialApply = require('partial-apply');\n\nfunction someFn( /* ... */ ) {\n  return partialApply(someOtherFn, arguments);\n}\n\n```\n\n## Why?\n\nThis module is a temporary solution, until lodash has something\nsimilar in core that can be called as a single method.\nIn the mean time, this is a hack to make our code more readable.\n\nTo get the latest status, see the [lodash docs](http://lodash.com/docs).\n\nI'll update this repo with install/version info if something comparable is\nadded to lodash core at some point.\n\n\n\n## License\n\nMIT &copy; Mike McNeil 2014\n","_attachments":{},"homepage":"https://github.com/balderdashy/partial-apply","bugs":{"url":"https://github.com/balderdashy/partial-apply/issues"},"license":"MIT"}