Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-07-14 04:31:02 +03:00
parent 096f13f30d
commit c93d069006

View File

@ -127,9 +127,7 @@ Array.prototype.toMap = function(normalize){
// Return an array with duplicate elements removed...
//
// NOTE: we are not using an Object as an index here as an Array can
// contain any type of item while Object keys can only be strings...
// NOTE: this may not work on IE...
// NOTE: order is preserved...
Array.prototype.unique = function(normalize){
return normalize ?
[...new Map(this.map(function(e){ return [normalize(e), e] })).values()]