# safer-function

> Function traps for bind, call, and apply.

Latest version **0.1.2** (published 2019-05-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install safer-function
pnpm add safer-function
yarn add safer-function
bun add safer-function
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2019-05-15 |
| First published | 2019-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | secure, function, call, apply, bind |

## Links

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

## Recent versions

- 0.1.2 (latest) — 2019-05-15
- 0.1.1 — 2019-05-15
- 0.1.0 — 2019-05-14
- 0.0.0 — 2019-05-14

## README

# safer-function

[![Build Status](https://travis-ci.com/WebReflection/safer-function.svg?branch=master)](https://travis-ci.com/WebReflection/safer-function) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/safer-function/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/safer-function?branch=master) ![WebReflection status](https://offline.report/status/webreflection.svg)

Function traps for `bind`, `call`, and `apply`.

Please ensure this module, or any dependent of it, is included before any other or, at least, before any polyfill, to grant reliability.

```js
import {bind, call, apply} from 'safer-function';
const {bind, call, apply} = require('./');

// basic usage
const {toString} = {};
call(toString, 'any object');

const {fromCharCode} = String;
call(fromCharCode, String, 104, 101, 108, 108, 111);
apply(fromCharCode, String, [104, 101, 108, 108, 111]);

// secured bound usage
const fromCharsCall = bind(fromCharCode, String);
fromCharsCall(104, 101, 108, 108, 111);

const fromCharsApply = bind(apply, call, fromCharCode, String);
fromCharsApply([104, 101, 108, 108, 111]);

```

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