-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (28 loc) · 763 Bytes
/
Copy pathindex.js
File metadata and controls
32 lines (28 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
Function.prototype.atfirst = function () {
var firstArgs = arguments;
return function () {
var i = firstArgs.length;
while (i) {
i -= 1;
Array.prototype.unshift.call(arguments, firstArgs[i]);
}
return this.apply(this, arguments);
}.bind(this);
};
Function.prototype.atlast = function () {
var lastArgs = arguments;
return function () {
var i = 0;
while (i < lastArgs.length) {
Array.prototype.push.call(arguments, lastArgs[i]);
i += 1;
}
return this.apply(this, arguments);
}.bind(this);
};
Function.prototype.at = function (firstArgs, lastArgs) {
var newFunc = this.atfirst.apply(this, firstArgs);
return newFunc.atlast.apply(newFunc, lastArgs);
};
module.exports = true;