mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Update vendors, minified files, and docs.
Former-commit-id: 018dfcade1386aa84492f60c8404ea00c01cbe11
This commit is contained in:
7
vendor/underscore/test/collections.js
vendored
7
vendor/underscore/test/collections.js
vendored
@@ -418,6 +418,13 @@ $(document).ready(function() {
|
||||
|
||||
var numbers = _.toArray({one : 1, two : 2, three : 3});
|
||||
equal(numbers.join(', '), '1, 2, 3', 'object flattened into array');
|
||||
|
||||
// test in IE < 9
|
||||
try {
|
||||
var actual = _.toArray(document.childNodes);
|
||||
} catch(ex) { }
|
||||
|
||||
ok(_.isArray(actual), 'should not throw converting a node list');
|
||||
});
|
||||
|
||||
test('size', function() {
|
||||
|
||||
4
vendor/underscore/test/functions.js
vendored
4
vendor/underscore/test/functions.js
vendored
@@ -34,8 +34,10 @@ $(document).ready(function() {
|
||||
// To test this with a modern browser, set underscore's nativeBind to undefined
|
||||
var F = function () { return this; };
|
||||
var Boundf = _.bind(F, {hello: "moe curly"});
|
||||
equal(new Boundf().hello, undefined, "function should not be bound to the context, to comply with ECMAScript 5");
|
||||
var newBoundf = new Boundf();
|
||||
equal(newBoundf.hello, undefined, "function should not be bound to the context, to comply with ECMAScript 5");
|
||||
equal(Boundf().hello, "moe curly", "When called without the new operator, it's OK to be bound to the context");
|
||||
ok(newBoundf instanceof Boundf && newBoundf instanceof F, "a bound instance is an instance of the bound and original function");
|
||||
});
|
||||
|
||||
test("bindAll", function() {
|
||||
|
||||
2
vendor/underscore/underscore-min.js
vendored
2
vendor/underscore/underscore-min.js
vendored
File diff suppressed because one or more lines are too long
22
vendor/underscore/underscore.js
vendored
22
vendor/underscore/underscore.js
vendored
@@ -358,7 +358,8 @@
|
||||
// Safely convert anything iterable into a real, live array.
|
||||
_.toArray = function(obj) {
|
||||
if (!obj) return [];
|
||||
if (obj.length === +obj.length) return slice.call(obj);
|
||||
if (_.isArray(obj)) return slice.call(obj);
|
||||
if (obj.length === +obj.length) return _.map(obj, _.identity);
|
||||
return _.values(obj);
|
||||
};
|
||||
|
||||
@@ -408,7 +409,7 @@
|
||||
|
||||
// Trim out all falsy values from an array.
|
||||
_.compact = function(array) {
|
||||
return _.filter(array, function(value){ return !!value; });
|
||||
return _.filter(array, _.identity);
|
||||
};
|
||||
|
||||
// Internal implementation of a recursive `flatten` function.
|
||||
@@ -573,18 +574,21 @@
|
||||
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
|
||||
// We check for `func.bind` first, to fail fast when `func` is undefined.
|
||||
_.bind = function bind(func, context) {
|
||||
var bound, args;
|
||||
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
|
||||
if (!_.isFunction(func)) throw new TypeError;
|
||||
args = slice.call(arguments, 2);
|
||||
return bound = function() {
|
||||
var args = slice.call(arguments, 2);
|
||||
var bound = function() {
|
||||
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
|
||||
ctor.prototype = func.prototype;
|
||||
var self = new ctor;
|
||||
var result = func.apply(self, args.concat(slice.call(arguments)));
|
||||
var result = func.apply(this, args.concat(slice.call(arguments)));
|
||||
if (Object(result) === result) return result;
|
||||
return self;
|
||||
return this;
|
||||
};
|
||||
if (func && func.prototype) {
|
||||
ctor.prototype = func.prototype;
|
||||
bound.prototype = new ctor;
|
||||
ctor.prototype = null;
|
||||
}
|
||||
return bound;
|
||||
};
|
||||
|
||||
// Bind all of an object's methods to that object. Useful for ensuring that
|
||||
|
||||
Reference in New Issue
Block a user