// uniq <https://github.com/mikolalysenko/uniq>
// Copyright (c) 2013 Mikola Lysenko (MIT)

'use strict'

function unique (list, compare, sorted) {
  if (list.length === 0) return list

  if (compare) {
    if (!sorted) list.sort(compare)
    return unique_pred(list, compare)
  }

  if (!sorted) list.sort()
  return unique_eq(list)
}

function unique_pred (list, compare) {
  var ptr = 1
  var len = list.length
  var a = list[0]
  var b = list[0]

  for (var i = 1; i < len; ++i) {
    b = a
    a = list[i]

    if (compare(a, b)) {
      if (i === ptr) {
        ptr++
        continue
      }
      list[ptr++] = a
    }
  }

  list.length = ptr
  return list
}

function unique_eq (list) {
  var ptr = 1
  var len = list.length
  var a = list[0]
  var b = list[0]

  for (var i = 1; i < len; ++i) {
    b = a
    a = list[i]

    if (a !== b) {
      if (i === ptr) {
        ptr++
        continue
      }
      list[ptr++] = a
    }
  }

  list.length = ptr
  return list
}

module.exports = unique

@@ -99,16 +99,593 @@
 trict'%0A%0A
+/*%0A%0A  Removes all duplicates from a sorted array in place.%0A    - array is the array to remove items from%0A    - compare is an optional comparison function that returns 0 when two items are equal, and something non-zero when they are different. If unspecified, then the default equals will be used.%0A    - sorted if true, then assume array is already sorted%0A%0A  This library updates the array in place without making an extra copy (and so it is faster for large arrays)%0A  It also accepts a custom comparison function so you can remove duplicates from arrays containing object%0A%0A*/%0A%0A
 function
@@ -724,24 +724,40 @@
 %7B%0A  if (list
+ == null %7C%7C list
 .length === 
@@ -766,20 +766,18 @@
  return 
-list
+%5B%5D
 %0A%0A  if (

update array/uneek — add notes, check for null/undefined