functional-abstraction/functools

View on GitHub
src/rbind.js

Summary

Maintainability
A
0 mins
Test Coverage
export default function rbind(callable, that, args) {
    const stack = args.slice(0);

    return function () {
        const new_args = Array.prototype.slice.call(arguments, 0);

        const args = [that].concat(new_args).concat(stack);

        const fn = Function.prototype.bind.apply(callable, args);

        return fn();
    };
}