Limit fix

This commit is contained in:
Richard Davey 2018-04-11 17:12:40 +01:00
parent 223c94a783
commit 68d2526d69
2 changed files with 4 additions and 4 deletions

View file

@ -31,7 +31,7 @@ var Add = function (array, item, limit, callback, context)
{
if (context === undefined) { context = array; }
if (limit)
if (limit > 0)
{
var remaining = limit - array.length;
@ -86,7 +86,7 @@ var Add = function (array, item, limit, callback, context)
return null;
}
if (limit && itemLength > remaining)
if (limit > 0 && itemLength > remaining)
{
item.splice(remaining);

View file

@ -35,7 +35,7 @@ var AddAt = function (array, item, index, limit, callback, context)
if (index === undefined) { index = 0; }
if (context === undefined) { context = array; }
if (limit)
if (limit > 0)
{
var remaining = limit - array.length;
@ -91,7 +91,7 @@ var AddAt = function (array, item, index, limit, callback, context)
}
// Truncate to the limit
if (limit && itemLength > remaining)
if (limit > 0 && itemLength > remaining)
{
item.splice(remaining);