CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
bindAll.js42 linesDownload Raw Back to lodash
1var arrayEach = require('./_arrayEach'),2    baseAssignValue = require('./_baseAssignValue'),3    bind = require('./bind'),4    flatRest = require('./_flatRest'),5    toKey = require('./_toKey');6 7/**8 * Binds methods of an object to the object itself, overwriting the existing9 * method.10 *11 * **Note:** This method doesn't set the "length" property of bound functions.12 *13 * @static14 * @since 0.1.015 * @memberOf _16 * @category Util17 * @param {Object} object The object to bind and assign the bound methods to.18 * @param {...(string|string[])} methodNames The object method names to bind.19 * @returns {Object} Returns `object`.20 * @example21 *22 * var view = {23 *   'label': 'docs',24 *   'click': function() {25 *     console.log('clicked ' + this.label);26 *   }27 * };28 *29 * _.bindAll(view, ['click']);30 * jQuery(element).on('click', view.click);31 * // => Logs 'clicked docs' when clicked.32 */33var bindAll = flatRest(function(object, methodNames) {34  arrayEach(methodNames, function(key) {35    key = toKey(key);36    baseAssignValue(object, key, bind(object[key], object));37  });38  return object;39});40 41module.exports = bindAll;42 
basant307/AI_Governance_Project · CoolFace