functionunique(array, isSorted) { var res = []; var seen = [];
for (var i = 0, len = array.length; i < len; i++) { var value = array[i]; if (isSorted) { if (!i || seen !== value) { res.push(value) } seen = value; } elseif (res.indexOf(value) === -1) { res.push(value); } } return res; }