Last active
August 29, 2015 14:17
-
-
Save Greenie0506/03705dd8a9188ad19d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is where im using the unique function | |
var result = boxxspring.arrayUnique( results[1].concat( artifacts ), function( a, b ) { | |
return a.id == b.id ? 0 : 1; | |
}); | |
// this is the definition of the unique array function | |
boxxspring.arrayUnique = function( array, comparator ) { | |
var comparator = comparator || function( a, b ) { | |
return a == b ? 0 : 1; | |
} | |
var result = new Array(); | |
source: | |
for( var index = 0, length = array.length; index < length; index++ ) { | |
for( var resultIndex = 0, resultLength = result.length; resultIndex < resultLength; resultIndex++ ) { | |
if ( !comparator( result[ resultIndex ], array[ index ] ) ) { | |
continue source; | |
} | |
} | |
result[ result.length ] = array[ index ]; | |
} | |
return result; | |
} | |
jordanorelli
commented
Mar 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment