Refactor unique to optionally take comparator. closes troopjs/troopjs-utils#6