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
disco_app-0.18.2 test/dummy/node_modules/lodash/bindAll.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/lodash/bindAll.js
trusty-cms-5.0.7 node_modules/lodash/bindAll.js
appmap-0.72.2 ./node_modules/lodash/bindAll.js
trusty-cms-5.0.6 node_modules/lodash/bindAll.js
appmap-0.72.1 ./node_modules/lodash/bindAll.js
appmap-0.72.0 ./node_modules/lodash/bindAll.js
trusty-cms-5.0.5 node_modules/lodash/bindAll.js
trusty-cms-5.0.4 node_modules/lodash/bindAll.js
appmap-0.71.0 ./node_modules/lodash/bindAll.js
disco_app-0.16.1 test/dummy/node_modules/lodash/bindAll.js
appmap-0.70.2 ./node_modules/lodash/bindAll.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/lodash/bindAll.js
appmap-0.70.1 ./node_modules/lodash/bindAll.js
appmap-0.70.0 ./node_modules/lodash/bindAll.js
appmap-0.69.0 ./node_modules/lodash/bindAll.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/lodash/bindAll.js
appmap-0.68.2 ./node_modules/lodash/bindAll.js
appmap-0.68.1 ./node_modules/lodash/bindAll.js
disco_app-0.15.2 test/dummy/node_modules/lodash/bindAll.js