source: trip-planner-front/node_modules/lodash/_createBind.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 853 bytes
Line 
1var createCtor = require('./_createCtor'),
2 root = require('./_root');
3
4/** Used to compose bitmasks for function metadata. */
5var WRAP_BIND_FLAG = 1;
6
7/**
8 * Creates a function that wraps `func` to invoke it with the optional `this`
9 * binding of `thisArg`.
10 *
11 * @private
12 * @param {Function} func The function to wrap.
13 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
14 * @param {*} [thisArg] The `this` binding of `func`.
15 * @returns {Function} Returns the new wrapped function.
16 */
17function createBind(func, bitmask, thisArg) {
18 var isBind = bitmask & WRAP_BIND_FLAG,
19 Ctor = createCtor(func);
20
21 function wrapper() {
22 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
23 return fn.apply(isBind ? thisArg : this, arguments);
24 }
25 return wrapper;
26}
27
28module.exports = createBind;
Note: See TracBrowser for help on using the repository browser.