mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Moving bind into it's own file
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function bind(fn, thisArg) {
|
||||
return function wrap() {
|
||||
var args = new Array(arguments.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return fn.apply(thisArg, args);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
var bind = require('../../../lib/helpers/bind');
|
||||
|
||||
describe('bind', function () {
|
||||
it('should bind an object to a function', function () {
|
||||
var o = { val: 123 };
|
||||
var f = bind(function (num) {
|
||||
return this.val * num;
|
||||
}, o);
|
||||
|
||||
expect(f(2)).toEqual(246);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user