Skip to content

WebReflection/safer-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

safer-function

Social Media Photo by freestocks.org on Unsplash

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

About

Function traps for bind, call, and apply.

Resources

License

Stars

Watchers

Forks

Packages

No packages published