src/array.js
function unique( arr, sort, uniqueFn ){
	var rtn = [];

	if ( arr.length ){
		if ( sort ){
			// more efficient because I can presort
			if ( bmoor.isFunction(sort) ){
				arr = arr.slice(0).sort(sort);
			}

			let last;
			
			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn ? uniqueFn(d) : d;

				if ( v !== last ){
					last = v;
					rtn.push( d );
				}
			}
		}else if ( uniqueFn ){
			let hash = {};

			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn(d);

				if ( !hash[v] ){
					hash[v] = true;
					rtn.push( d );
				}
			}
		}else{
			// greedy and inefficient
			for( let i = 0, c = arr.length; i < c; i++ ){
			 	let d = arr[i];

			 	if ( rtn.indexOf(d) === -1 ){
			 		rtn.push( d );
			 	}
			}
		}
	}

	return rtn;
}
function unique( arr, sort, uniqueFn ){
	var rtn = [];

	if ( arr.length ){
		if ( sort ){
			// more efficient because I can presort
			if ( bmoor.isFunction(sort) ){
				arr = arr.slice(0).sort(sort);
			}

			let last;
			
			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn ? uniqueFn(d) : d;

				if ( v !== last ){
					last = v;
					rtn.push( d );
				}
			}
		}else if ( uniqueFn ){
			let hash = {};

			for( let i = 0, c = arr.length; i < c; i++ ){
				let d = arr[i],
					v = uniqueFn(d);

				if ( !hash[v] ){
					hash[v] = true;
					rtn.push( d );
				}
			}
		}else{
			// greedy and inefficient
			for( let i = 0, c = arr.length; i < c; i++ ){
			 	let d = arr[i];

			 	if ( rtn.indexOf(d) === -1 ){
			 		rtn.push( d );
			 	}
			}
		}
	}

	return rtn;
}
function unique ( arr , sort , uniqueFn ) { var rtn = [ ] ; if ( arr . length ) { if ( sort ) { // more efficient because I can presort if ( bmoor . isFunction ( sort ) ) { arr = arr . slice ( 0 ) . sort ( sort ) ; } let last ; for ( let i = 0 , c = arr . length ; i < c ; i ++ ) { let d = arr [ i ] , v = uniqueFn ? uniqueFn ( d ) : d ; if ( v !== last ) { last = v ; rtn . push ( d ) ; } } } else if ( uniqueFn ) { let hash = { } ; for ( let i = 0 , c = arr . length ; i < c ; i ++ ) { let d = arr [ i ] , v = uniqueFn ( d ) ; if ( ! hash [ v ] ) { hash [ v ] = true ; rtn . push ( d ) ; } } } else { // greedy and inefficient for ( let i = 0 , c = arr . length ; i < c ; i ++ ) { let d = arr [ i ] ; if ( rtn . indexOf ( d ) === - 1 ) { rtn . push ( d ) ; } } } } return rtn ; }
Create a new array that is completely unique

@function unique
@param {array} arr The array to be made unique
@param {function|boolean} sort If boolean === true, array is presorted.  If function, use to sort
Create a new array that is completely unique