-
Notifications
You must be signed in to change notification settings - Fork 0
decontextify
Subhajit Sahu edited this page Jul 29, 2022
·
2 revisions
Decontextify a function by accepting this-object as the first argument.
Similar: contextify, decontextify.
function decontextify(x)
// x: a function
const xfunction = require('extra-function');
function count(value) {
var a = 0;
for (var v of this)
if (v===value) ++a;
return a;
}
var fn = xfunction.decontextify(count);
fn([6, 3, 4, 3], 3);
// → 2
fn([6, 1, 4, 3], 3);
// → 1