/** * lodash 4.0.0 (Custom Build) * Build: `lodash modularize exports="npm" -o ./` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ var arrayEach = require('lodash._arrayeach'), baseFlatten = require('lodash._baseflatten'), bind = require('lodash.bind'), rest = require('lodash.rest'); /** * 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 * @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, * specified individually or in arrays. * @returns {Object} Returns `object`. * @example * * var view = { * 'label': 'docs', * 'onClick': function() { * console.log('clicked ' + this.label); * } * }; * * _.bindAll(view, 'onClick'); * jQuery(element).on('click', view.onClick); * // => logs 'clicked docs' when clicked */ var bindAll = rest(function(object, methodNames) { arrayEach(baseFlatten(methodNames), function(key) { object[key] = bind(object[key], object); }); return object; }); module.exports = bindAll;