Simplify _.toArray and wrapper methods.

Former-commit-id: b0440d401bd58cfa2d7aaf213549a824963474c3
This commit is contained in:
John-David Dalton
2012-12-25 17:06:51 -06:00
parent ef7cb26b01
commit e3b80a5e09
6 changed files with 87 additions and 90 deletions

View File

@@ -2241,8 +2241,7 @@
* // => [2, 3, 4]
*/
function toArray(collection) {
var length = collection ? collection.length : 0;
if (typeof length == 'number') {
if (collection && typeof collection.length == 'number') {
return slice(collection);
}
return values(collection);
@@ -3298,7 +3297,7 @@
lodash.prototype[methodName] = function() {
var args = [this.__wrapped__];
push.apply(args, arguments);
var result = func.apply(lodash, args);
if (this.__chain__) {
result = new lodash(result);