We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uniqueItems
Currently, uniqueItems on non-primitives is O(n^2) both here and in ajv. It should be safe as complexityChecks catch unbounded uniqueItems.
O(n^2)
complexityChecks
But there is no reason for uniqueItems to be O(n^2), even when dealing with complex objects.
See implementation in https://github.com/ChALkeR/array-is-unique/blob/main/sorting.js -- that reaches O(n * log n). That shouldn't exceed O(n * log n) even in worst-case on modern JS engines which use Timsort.
O(n * log n)
Also, sort-based implementation is faster than hash/set-based even on primitives, and has significantly lower memory consumption.
sort
The text was updated successfully, but these errors were encountered:
That impl can be made faster in non-unique cases by stopping sorting of large arrays with a throw.
Sorry, something went wrong.
Seems to be non-trivial due to certain limitations. Will revisit for 1.x
ChALkeR
No branches or pull requests
Currently,
uniqueItems
on non-primitives isO(n^2)
both here and in ajv.It should be safe as
complexityChecks
catch unboundeduniqueItems
.But there is no reason for
uniqueItems
to beO(n^2)
, even when dealing with complex objects.See implementation in https://github.com/ChALkeR/array-is-unique/blob/main/sorting.js -- that reaches
O(n * log n)
.That shouldn't exceed
O(n * log n)
even in worst-case on modern JS engines which use Timsort.Also,
sort
-based implementation is faster than hash/set-based even on primitives, and has significantly lower memory consumption.The text was updated successfully, but these errors were encountered: