array-hyper-unique
Advanced tools
Comparing version 1.0.0 to 1.0.1
17
index.js
@@ -20,9 +20,14 @@ "use strict"; | ||
if (options.overwrite) { | ||
arr.forEach(function (val, index, array) { | ||
let i = array.findIndex(a => checker(a, val, array, arr)); | ||
if (i !== index) { | ||
arr.splice(i, 1); | ||
let index = 0; | ||
while (index in arr) { | ||
let val = arr[index]; | ||
let i = arr.findIndex(a => checker(a, val, arr, arr)); | ||
if (i != index) { | ||
let j = Math.max(index, i); | ||
arr.splice(j, 1); | ||
} | ||
return i === index; | ||
}); | ||
else { | ||
index++; | ||
} | ||
} | ||
return arr; | ||
@@ -29,0 +34,0 @@ } |
24
index.ts
@@ -38,16 +38,22 @@ /** | ||
{ | ||
// @ts-ignore | ||
arr.forEach(function (val, index, array) | ||
let index = 0; | ||
while (index in arr) | ||
{ | ||
// @ts-ignore | ||
let i = array.findIndex(a => checker(a, val, array, arr)); | ||
let val = arr[index]; | ||
if (i !== index) | ||
let i = arr.findIndex(a => checker(a, val, arr, arr)); | ||
if (i != index) | ||
{ | ||
arr.splice(i, 1); | ||
let j = Math.max(index, i); | ||
arr.splice(j, 1); | ||
} | ||
else | ||
{ | ||
index++; | ||
} | ||
} | ||
return i === index; | ||
}); | ||
return arr; | ||
@@ -54,0 +60,0 @@ } |
{ | ||
"name": "array-hyper-unique", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Get unique values of an array. Really, like deeply unique.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -10,2 +10,3 @@ # array-hyper-unique | ||
3. also add option control | ||
4. see [_data.ts](test/_data.ts) and [test.test.ts](test/test.test.ts) | ||
@@ -12,0 +13,0 @@ ## demo |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7272
117
159