Sha256: 229faccb2beb1c287454a5c6f825c63393840d72bba5f7d80c29aa2f604abfb6

Contents?: true

Size: 1.35 KB

Versions: 270

Compression:

Stored size: 1.35 KB

Contents

var apply = require('./_apply'),
    createCtor = require('./_createCtor'),
    root = require('./_root');

/** Used to compose bitmasks for function metadata. */
var WRAP_BIND_FLAG = 1;

/**
 * Creates a function that wraps `func` to invoke it with the `this` binding
 * of `thisArg` and `partials` prepended to the arguments it receives.
 *
 * @private
 * @param {Function} func The function to wrap.
 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
 * @param {*} thisArg The `this` binding of `func`.
 * @param {Array} partials The arguments to prepend to those provided to
 *  the new function.
 * @returns {Function} Returns the new wrapped function.
 */
function createPartial(func, bitmask, thisArg, partials) {
  var isBind = bitmask & WRAP_BIND_FLAG,
      Ctor = createCtor(func);

  function wrapper() {
    var argsIndex = -1,
        argsLength = arguments.length,
        leftIndex = -1,
        leftLength = partials.length,
        args = Array(leftLength + argsLength),
        fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;

    while (++leftIndex < leftLength) {
      args[leftIndex] = partials[leftIndex];
    }
    while (argsLength--) {
      args[leftIndex++] = arguments[++argsIndex];
    }
    return apply(fn, isBind ? thisArg : this, args);
  }
  return wrapper;
}

module.exports = createPartial;

Version data entries

270 entries across 269 versions & 28 rubygems

Version Path
clapton-0.0.1 lib/clapton/javascripts/node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.47 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.46 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.45 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.44 node_modules/lodash/_createPartial.js
boring_generators-0.14.0 tmp/templates/app_template/node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.43 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.42 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.41 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.40 node_modules/lodash/_createPartial.js
sumomo-0.10.8 data/sumomo/api_modules/node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.39 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.38 node_modules/lodash/_createPartial.js
optimacms-0.1.61 spec/dummy/node_modules/lodash/_createPartial.js
boring_generators-0.13.0 tmp/templates/app_template/node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.32 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.31 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.30 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.29 node_modules/lodash/_createPartial.js
immosquare-cleaner-0.1.28 node_modules/lodash/_createPartial.js