lodash.bindall
Advanced tools
Comparing version 3.0.0 to 3.1.0
50
index.js
/** | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.1.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
@@ -11,3 +11,4 @@ * Available under MIT license <https://lodash.com/license> | ||
createWrapper = require('lodash._createwrapper'), | ||
functions = require('lodash.functions'); | ||
functions = require('lodash.functions'), | ||
restParam = require('lodash.restparam'); | ||
@@ -18,22 +19,2 @@ /** Used to compose bitmasks for wrapper metadata. */ | ||
/** | ||
* The base implementation of `_.bindAll` without support for individual | ||
* method name arguments. | ||
* | ||
* @private | ||
* @param {Object} object The object to bind and assign the bound methods to. | ||
* @param {string[]} methodNames The object method names to bind. | ||
* @returns {Object} Returns `object`. | ||
*/ | ||
function baseBindAll(object, methodNames) { | ||
var index = -1, | ||
length = methodNames.length; | ||
while (++index < length) { | ||
var key = methodNames[index]; | ||
object[key] = createWrapper(object[key], BIND_FLAG, object); | ||
} | ||
return object; | ||
} | ||
/** | ||
* Binds methods of an object to the object itself, overwriting the existing | ||
@@ -57,3 +38,5 @@ * method. Method names may be specified as individual arguments or as arrays | ||
* 'label': 'docs', | ||
* 'onClick': function() { console.log('clicked ' + this.label); } | ||
* 'onClick': function() { | ||
* console.log('clicked ' + this.label); | ||
* } | ||
* }; | ||
@@ -65,10 +48,15 @@ * | ||
*/ | ||
function bindAll(object) { | ||
return baseBindAll(object, | ||
arguments.length > 1 | ||
? baseFlatten(arguments, false, false, 1) | ||
: functions(object) | ||
); | ||
} | ||
var bindAll = restParam(function(object, methodNames) { | ||
methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object); | ||
var index = -1, | ||
length = methodNames.length; | ||
while (++index < length) { | ||
var key = methodNames[index]; | ||
object[key] = createWrapper(object[key], BIND_FLAG, object); | ||
} | ||
return object; | ||
}); | ||
module.exports = bindAll; |
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, | ||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | ||
@@ -4,0 +4,0 @@ |
{ | ||
"name": "lodash.bindall", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "The modern build of lodash’s `_.bindAll` as a module.", | ||
@@ -22,4 +22,5 @@ "homepage": "https://lodash.com/", | ||
"lodash._createwrapper": "^3.0.0", | ||
"lodash.functions": "^3.0.0" | ||
"lodash.functions": "^3.0.0", | ||
"lodash.restparam": "^3.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.bindall v3.0.0 | ||
# lodash.bindall v3.1.0 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.bindAll` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#bindAll) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.bindall) for more details. | ||
See the [documentation](https://lodash.com/docs#bindAll) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.bindall) for more details. |
4873
4
53
+ Addedlodash.restparam@^3.0.0
+ Addedlodash.restparam@3.6.1(transitive)