Update builds and docs.

This commit is contained in:
John-David Dalton
2013-09-09 08:54:39 -07:00
parent 21a45a940e
commit f949bdcfe4
8 changed files with 298 additions and 308 deletions

View File

@@ -2469,11 +2469,12 @@
* // => [3, 1]
*/
function sample(collection, n, guard) {
if (!isArray(collection)) {
collection = toArray(collection);
var length = collection ? collection.length : 0;
if (typeof length != 'number') {
collection = values(collection);
}
if (n == null || guard) {
return collection[random(collection.length - 1)];
return collection ? collection[random(length - 1)] : undefined;
}
var result = shuffle(collection);
result.length = nativeMin(nativeMax(0, n), result.length);
@@ -2824,24 +2825,22 @@
* // => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]
*/
function first(array, callback, thisArg) {
if (array) {
var n = 0,
length = array.length;
var n = 0,
length = array ? array.length : 0;
if (typeof callback != 'number' && callback != null) {
var index = -1;
callback = createCallback(callback, thisArg, 3);
while (++index < length && callback(array[index], index, array)) {
n++;
}
} else {
n = callback;
if (n == null || thisArg) {
return array[0];
}
if (typeof callback != 'number' && callback != null) {
var index = -1;
callback = createCallback(callback, thisArg, 3);
while (++index < length && callback(array[index], index, array)) {
n++;
}
} else {
n = callback;
if (n == null || thisArg) {
return array ? array[0] : undefined;
}
return nativeSlice.call(array, 0, nativeMin(nativeMax(0, n), length));
}
return nativeSlice.call(array, 0, nativeMin(nativeMax(0, n), length));
}
/**
@@ -2980,11 +2979,8 @@
* // => [{ 'name': 'banana', 'type': 'fruit' }]
*/
function initial(array, callback, thisArg) {
if (!array) {
return [];
}
var n = 0,
length = array.length;
length = array ? array.length : 0;
if (typeof callback != 'number' && callback != null) {
var index = length;
@@ -3092,24 +3088,22 @@
* // => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }]
*/
function last(array, callback, thisArg) {
if (array) {
var n = 0,
length = array.length;
var n = 0,
length = array ? array.length : 0;
if (typeof callback != 'number' && callback != null) {
var index = length;
callback = createCallback(callback, thisArg, 3);
while (index-- && callback(array[index], index, array)) {
n++;
}
} else {
n = callback;
if (n == null || thisArg) {
return array[length - 1];
}
if (typeof callback != 'number' && callback != null) {
var index = length;
callback = createCallback(callback, thisArg, 3);
while (index-- && callback(array[index], index, array)) {
n++;
}
} else {
n = callback;
if (n == null || thisArg) {
return array ? array[length - 1] : undefined;
}
return nativeSlice.call(array, nativeMax(0, length - n));
}
return nativeSlice.call(array, nativeMax(0, length - n));
}
/**
@@ -3402,7 +3396,7 @@
// juggle arguments
if (typeof isSorted != 'boolean' && isSorted != null) {
thisArg = callback;
callback = !(thisArg && thisArg[isSorted] === array) ? isSorted : undefined;
callback = !(thisArg && thisArg[isSorted] === array) ? isSorted : null;
isSorted = false;
}
if (callback != null) {
@@ -4218,8 +4212,10 @@
* // => 'nonsense'
*/
function result(object, property) {
var value = object ? object[property] : undefined;
return isFunction(value) ? object[property]() : value;
if (object) {
var value = object[property];
return isFunction(value) ? object[property]() : value;
}
}
/**