Sha256: ea77e9cca1fe05b7308662d1564723fb83d46b3502e2eb76dae6f845a2ad5c2a

Contents?: true

Size: 1.86 KB

Versions: 23

Compression:

Stored size: 1.86 KB

Contents

/**
 * lodash 3.0.1 (Custom Build) <https://lodash.com/>
 * Build: `lodash modern modularize exports="npm" -o ./`
 * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 * Available under MIT license <https://lodash.com/license>
 */

/**
 * A specialized version of `baseCallback` which only supports `this` binding
 * and specifying the number of arguments to provide to `func`.
 *
 * @private
 * @param {Function} func The function to bind.
 * @param {*} thisArg The `this` binding of `func`.
 * @param {number} [argCount] The number of arguments to provide to `func`.
 * @returns {Function} Returns the callback.
 */
function bindCallback(func, thisArg, argCount) {
  if (typeof func != 'function') {
    return identity;
  }
  if (thisArg === undefined) {
    return func;
  }
  switch (argCount) {
    case 1: return function(value) {
      return func.call(thisArg, value);
    };
    case 3: return function(value, index, collection) {
      return func.call(thisArg, value, index, collection);
    };
    case 4: return function(accumulator, value, index, collection) {
      return func.call(thisArg, accumulator, value, index, collection);
    };
    case 5: return function(value, other, key, object, source) {
      return func.call(thisArg, value, other, key, object, source);
    };
  }
  return function() {
    return func.apply(thisArg, arguments);
  };
}

/**
 * This method returns the first argument provided to it.
 *
 * @static
 * @memberOf _
 * @category Utility
 * @param {*} value Any value.
 * @returns {*} Returns `value`.
 * @example
 *
 * var object = { 'user': 'fred' };
 *
 * _.identity(object) === object;
 * // => true
 */
function identity(value) {
  return value;
}

module.exports = bindCallback;

Version data entries

23 entries across 18 versions & 8 rubygems

Version Path
ilog-0.4.1 node_modules/lodash._bindcallback/index.js
ilog-0.4.0 node_modules/lodash._bindcallback/index.js
ilog-0.3.3 node_modules/lodash._bindcallback/index.js
optimacms-0.4.3 spec/dummy/node_modules/lodash._bindcallback/index.js
optimacms-0.4.2 spec/dummy/node_modules/lodash._bindcallback/index.js
cortex-0.1.3 spec/dummy/node_modules/lodash._bindcallback/index.js
lanes-0.8.0 node_modules/lodash._bindcallback/index.js
node-compiler-0.9.1 vendor/node/deps/npm/node_modules/lodash._bindcallback/index.js
node-compiler-0.9.0 vendor/node-v7.2.1/deps/npm/node_modules/lodash._bindcallback/index.js
node-compiler-0.8.0 vendor/node-v7.2.0/deps/npm/node_modules/lodash._bindcallback/index.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash._bindcallback/index.js
node-compiler-0.7.0 vendor/node-v7.1.0/deps/npm/node_modules/lodash._bindcallback/index.js
node-compiler-0.7.0 vendor/node-v6.9.1/deps/npm/node_modules/lodash._bindcallback/index.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/lodash.merge/node_modules/lodash._createassigner/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/lodash.omit/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/lodash.clonedeep/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/lodash.clonedeep/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/lodash.omit/node_modules/lodash._bindcallback/index.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/lodash.merge/node_modules/lodash._createassigner/node_modules/lodash._bindcallback/index.js