# function.apply-x

> Function.prototype.apply()

Latest version **1.0.0** (published 2025-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install function.apply-x
pnpm add function.apply-x
yarn add function.apply-x
bun add function.apply-x
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2025-12-21 |
| First published | 2025-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fox Jones |
| Maintainers | xsfj |
| Keywords | function, apply |

## Links

- npm: https://www.npmjs.com/package/function.apply-x
- Repository: https://github.com/xsfj/function-apply
- Homepage: https://github.com/xsfj/function-apply#readme
- Issues: https://github.com/xsfj/function-apply/issues
- npm.io page: https://npm.io/package/function.apply-x

## Recent versions

- 1.0.0 (latest) — 2025-12-21

## README

# function.apply-x

Robustly caches `Function.prototype.apply` for reliable usage across environments.

## Installation

```bash
npm install function.apply-x
```

## Usage

```javascript
const apply = require('function.apply-x');

function greet(greeting, name) {
  return `${greeting}, ${name}!`;
}

// Use apply to call the function with an array of arguments
const result = apply.call(greet, null, ['Hello', 'World']);
console.log(result); // "Hello, World!"
```

## Why?

This module caches a reference to the native `Function.prototype.apply` method. This is useful in scenarios where:

- You need to ensure you're using the original, unmodified `apply` method
- Third-party code may have modified or overridden `Function.prototype.apply`
- You want to protect against prototype pollution
- You're building low-level utility libraries that need guaranteed native behavior

## API

The module exports the cached `Function.prototype.apply` method directly.

```javascript
apply.call(func, thisArg, argsArray)
```

- **func**: The function to invoke
- **thisArg**: The value to use as `this` when calling the function
- **argsArray**: An array of arguments to pass to the function

## Example

```javascript
const apply = require('function.apply-x');

const obj = {
  value: 42,
  getValue: function(multiplier, offset) {
    return this.value * multiplier + offset;
  }
};

const result = apply.call(obj.getValue, obj, [2, 10]);
console.log(result); // 94
```

## License

MIT

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