# partial-apply

> Call a function using an array of arguments while maintaining its original "this" context.

Latest version **0.1.0** (published 2014-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install partial-apply
pnpm add partial-apply
yarn add partial-apply
bun add partial-apply
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2014-05-31 |
| First published | 2014-05-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mike McNeil |
| Maintainers | balderdashy |
| Keywords | lodash, _, call, partial, this, context, apply, _.partial |

## Links

- npm: https://www.npmjs.com/package/partial-apply
- Repository: https://github.com/balderdashy/partial-apply
- Issues: https://github.com/balderdashy/partial-apply/issues
- npm.io page: https://npm.io/package/partial-apply

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ~2.4.1

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2014-05-31

## README

# partial-apply

Implements a context-free version of `Function.prototype.apply` in Node.js/JavaScript.


If `someFn` has unknown arguments, and we want to pass those arguments through
to a wrapped function, say `someOtherFn`, we can use `someOtherFn.apply()` to
call the wrapped function with `someFn`'s arguments.

But in the process, we corrupt the "this" context of the wrapped function.
In order to have it stay correctly defined, we have to pass in the context manually.
This creates some nasty dependencies and hurts reusability in your code base.

`_.partial()` in lodash gets us a bit closer, but it does not support an **array**
of arguments- just arguments passed in one after the other, like `_.partial(fn,x0,x1,etc)`.

For example, if we expected `someOtherFn` in the example below to have its "this"
value refer to, say, a Waterline model, it's actually quite annoying in vanilla
JavaScript to pass down a dynamic array of arguments to a function AND maintain its
original "this" context.

Anyway, this is why `partial-apply` was created.


## Installation

```sh
$ npm install partial-apply
```

## Usage

```javascript
var partialApply = require('partial-apply');

function someFn( /* ... */ ) {
  return partialApply(someOtherFn, arguments);
}

```

## Why?

This module is a temporary solution, until lodash has something
similar in core that can be called as a single method.
In the mean time, this is a hack to make our code more readable.

To get the latest status, see the [lodash docs](http://lodash.com/docs).

I'll update this repo with install/version info if something comparable is
added to lodash core at some point.



## License

MIT &copy; Mike McNeil 2014

---
_Source: https://npm.io/package/partial-apply · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
