typescript-array-utils
Version:
Immutable array manipulation methods
15 lines (14 loc) • 410 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var identityCompare = function (a, b) {
return a === b;
};
function unique(arr, compare) {
if (compare === void 0) { compare = identityCompare; }
return arr.filter(function (e, index) {
return index === arr.findIndex(function (v) {
return compare(e, v);
});
});
}
exports.unique = unique;