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
clapton-0.0.1 lib/clapton/javascripts/node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.47 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.46 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.45 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.44 node_modules/lodash/bindAll.js
boring_generators-0.14.0 tmp/templates/app_template/node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.43 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.42 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.41 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.40 node_modules/lodash/bindAll.js
sumomo-0.10.8 data/sumomo/api_modules/node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.39 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.38 node_modules/lodash/bindAll.js
optimacms-0.1.61 spec/dummy/node_modules/lodash/bindAll.js
boring_generators-0.13.0 tmp/templates/app_template/node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.32 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.31 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.30 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.29 node_modules/lodash/bindAll.js
immosquare-cleaner-0.1.28 node_modules/lodash/bindAll.js