Sha256: bd995daba5ea5981970c265e76e2beba26e27008fab1dbd13692e6e234edbe84

Contents?: true

Size: 1.1 KB

Versions: 273

Compression:

Stored size: 1.1 KB

Contents

var arrayEach = require('./_arrayEach'),
    baseAssignValue = require('./_baseAssignValue'),
    bind = require('./bind'),
    flatRest = require('./_flatRest'),
    toKey = require('./_toKey');

/**
 * Binds methods of an object to the object itself, overwriting the existing
 * method.
 *
 * **Note:** This method doesn't set the "length" property of bound functions.
 *
 * @static
 * @since 0.1.0
 * @memberOf _
 * @category Util
 * @param {Object} object The object to bind and assign the bound methods to.
 * @param {...(string|string[])} methodNames The object method names to bind.
 * @returns {Object} Returns `object`.
 * @example
 *
 * var view = {
 *   'label': 'docs',
 *   'click': function() {
 *     console.log('clicked ' + this.label);
 *   }
 * };
 *
 * _.bindAll(view, ['click']);
 * jQuery(element).on('click', view.click);
 * // => Logs 'clicked docs' when clicked.
 */
var bindAll = flatRest(function(object, methodNames) {
  arrayEach(methodNames, function(key) {
    key = toKey(key);
    baseAssignValue(object, key, bind(object[key], object));
  });
  return object;
});

module.exports = bindAll;

Version data entries

273 entries across 271 versions & 29 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.59 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.58 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.57 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.56 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.55 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.54 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.53 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.52 node_modules/lodash/bindAll.js
trusty-cms-6.3.1 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.51 node_modules/lodash/bindAll.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/bindAll.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/bindAll.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.50 node_modules/lodash/bindAll.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/bindAll.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/bindAll.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/bindAll.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/bindAll.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/bindAll.js