function unique( arr, sorted ) {
	var len = arr.length;
	var val;
	var i;
	var j;

	if ( !len ) {
		return;
	}
	if ( !sorted ) {
		arr.sort( ascending );
	}
	// Loop through the array, only incrementing a pointer when successive values are different. When a succeeding value is different, move the pointer and set the next value. In the trivial case where all array elements are unique, we incur a slight penalty in resetting the element value for each unique value. In other cases, we simply move a unique value to a new position in the array. The end result is a sorted array with unique values.
	for ( i = 1, j = 0; i < len; i++ ) {
		val = arr[ i ];
		if ( arr[ j ] !== val ) {
			j += 1;
			arr[ j ] = val;
		}
	}
	// Truncate the array:
	arr.length = j+1;
}
Removes duplicate values from a numeric array.

## Notes

-   The input array is mutated.

@private
@param {Array} arr - array to be deduped
@param {boolean} sorted - boolean flag indicating if the input array is sorted