MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / ctx

Function ctx

lib/web/polyfill.js:125–141  ·  view source on GitHub ↗
(fn, that, length)

Source from the content-addressed store, hash-verified

123}
124// Optional / simple context binding
125function ctx(fn, that, length){
126 assertFunction(fn);
127 if(~length && that === undefined)return fn;
128 switch(length){
129 case 1: return function(a){
130 return fn.call(that, a);
131 };
132 case 2: return function(a, b){
133 return fn.call(that, a, b);
134 };
135 case 3: return function(a, b, c){
136 return fn.call(that, a, b, c);
137 }
138 } return function(/* ...args */){
139 return fn.apply(that, arguments);
140 }
141}
142// Fast apply
143// http://jsperf.lnkit.com/fast-apply/5
144function invoke(fn, args, that){

Callers 6

polyfill.jsFile · 0.85
createArrayMethodFunction · 0.85
$defineFunction · 0.85
forOfFunction · 0.85
resolveFunction · 0.85
setArrayStaticsFunction · 0.85

Calls 3

assertFunctionFunction · 0.85
applyMethod · 0.65
callMethod · 0.45

Tested by

no test coverage detected