safer-function

0.1.2 • Public • Published

safer-function

Build Status Coverage Status WebReflection status

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.

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]);
 

Package Sidebar

Install

npm i safer-function

Weekly Downloads

0

Version

0.1.2

License

ISC

Unpacked Size

3.41 kB

Total Files

6

Last publish

Collaborators

  • webreflection