enslave

binds this to a function's first argument

What is enslave?

enslave is the inverse function of liberate

Usage

var enslave = require('enslave')
 
function add(ab){ return a.value + b.value }
 
var n = {add: enslave(add)}
 
var A = Object.create(n)
A.value = 1
 
var B = Object.create(n)
B.value = 2
 
A.add(B)  // returns 3 
 

Credits

Ripped straight from sinful.js, as I found it useful on its own.