CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
bind.js58 linesDownload Raw Back to lodash-es
1import baseRest from './_baseRest.js';2import createWrap from './_createWrap.js';3import getHolder from './_getHolder.js';4import replaceHolders from './_replaceHolders.js';5 6/** Used to compose bitmasks for function metadata. */7var WRAP_BIND_FLAG = 1,8    WRAP_PARTIAL_FLAG = 32;9 10/**11 * Creates a function that invokes `func` with the `this` binding of `thisArg`12 * and `partials` prepended to the arguments it receives.13 *14 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,15 * may be used as a placeholder for partially applied arguments.16 *17 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"18 * property of bound functions.19 *20 * @static21 * @memberOf _22 * @since 0.1.023 * @category Function24 * @param {Function} func The function to bind.25 * @param {*} thisArg The `this` binding of `func`.26 * @param {...*} [partials] The arguments to be partially applied.27 * @returns {Function} Returns the new bound function.28 * @example29 *30 * function greet(greeting, punctuation) {31 *   return greeting + ' ' + this.user + punctuation;32 * }33 *34 * var object = { 'user': 'fred' };35 *36 * var bound = _.bind(greet, object, 'hi');37 * bound('!');38 * // => 'hi fred!'39 *40 * // Bound with placeholders.41 * var bound = _.bind(greet, object, _, '!');42 * bound('hi');43 * // => 'hi fred!'44 */45var bind = baseRest(function(func, thisArg, partials) {46  var bitmask = WRAP_BIND_FLAG;47  if (partials.length) {48    var holders = replaceHolders(partials, getHolder(bind));49    bitmask |= WRAP_PARTIAL_FLAG;50  }51  return createWrap(func, bitmask, thisArg, partials, holders);52});53 54// Assign default placeholders.55bind.placeholder = {};56 57export default bind;58 
basant307/AI_Governance_Project · CoolFace