mirror of
https://github.com/Doodle3D/Doodle3D-API
synced 2024-11-10 15:03:23 +01:00
25 lines
527 B
JavaScript
25 lines
527 B
JavaScript
|
/* */
|
||
|
var assertFunction = require("./$.assert").fn;
|
||
|
module.exports = function(fn, that, length) {
|
||
|
assertFunction(fn);
|
||
|
if (~length && that === undefined)
|
||
|
return fn;
|
||
|
switch (length) {
|
||
|
case 1:
|
||
|
return function(a) {
|
||
|
return fn.call(that, a);
|
||
|
};
|
||
|
case 2:
|
||
|
return function(a, b) {
|
||
|
return fn.call(that, a, b);
|
||
|
};
|
||
|
case 3:
|
||
|
return function(a, b, c) {
|
||
|
return fn.call(that, a, b, c);
|
||
|
};
|
||
|
}
|
||
|
return function() {
|
||
|
return fn.apply(that, arguments);
|
||
|
};
|
||
|
};
|