var Add = function (array, item, limit, callback, context){ if (context === undefined) { context = array; } if (limit > 0) { var remaining = limit - _AN_Read_length('length', array); if (remaining <= 0) { return null ; } } if (!Array.isArray(item)) { if (array.indexOf(item) === -1) { array.push(item); if (callback) { callback.call(context, item); } return item; } else { return null ; } } var itemLength = _AN_Read_length('length', item) - 1; while (itemLength >= 0){ if (array.indexOf(item[itemLength]) !== -1) { item.splice(itemLength, 1); } itemLength-- ; } itemLength = _AN_Read_length('length', item); if (itemLength === 0) { return null ; } if (limit > 0 && itemLength > remaining) { item.splice(remaining); itemLength = remaining; } for (var i = 0; i < itemLength; i++ ){ var entry = item[i]; array.push(entry); if (callback) { callback.call(context, entry); } } return item; } ; module.exports = Add;