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