Registry / serialization / uniqs
library2.0.0jsnpmunverified

uniqs is a lightweight JavaScript utility designed to create unique lists and unions of multiple lists, defining uniqueness based on strict object equality. Currently at version 2.0.0, this package distinguishes itself by prioritizing simplicity and a minimal footprint over raw performance, making it a suitable alternative to more comprehensive libraries like Lodash or Underscore for basic deduplication tasks. Its primary purpose is to provide a straightforward function for de-duplicating items and combining arrays without complex features or external dependencies, making it ideal for scenarios where bundle size and directness are critical. Items are maintained in their first-appearance order, reflecting their initial encounter in the input lists.

npm install uniqs
INSTALL
IMPORT
SIG · UNIQS
U
uniqs
serializationjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

uniqs
const uniqs = require('uniqs');
import { uniqs } from 'uniqs';
The package primarily uses CommonJS `require` for its default function export. While ESM `import uniqs from 'uniqs'` may work in some environments, it's not explicitly stated or guaranteed by the README.
uniqs
import uniqs from 'uniqs';
const { uniqs } = require('uniqs');
For ESM environments, assuming a default export, this is the standard import. Attempting to destructure it as a named export from CommonJS will fail.

Demonstrates deduplication of a single list, union of multiple lists, and handling of mixed individual items and lists.

const uniqs = require('uniqs'); // Example usage to deduplicate a list const foo = { id: 23 }; const list = [3, 2, 2, 1, foo, foo]; const uniqueList = uniqs(list); console.log('Unique list:', uniqueList); // Expected: [3, 2, 1, { id: 23 }] // Example usage to create a union of multiple lists const listA = [2, 1, 1]; const listB = [2, 3, 3, 4]; const listC = [4, 3, 2]; const unionList = uniqs(listA, listB, listC); console.log('Union list:', unionList); // Expected: [2, 1, 3, 4] // Example with individual items and a list const mixedInput = uniqs(3, 2, 2, [1, 1, 2]); console.log('Mixed input:', mixedInput); // Expected: [3, 2, 1]
Debug
Known issues
gotchauniqs uses a simple `indexOf`-based deduplication, resulting in O(n^2) time complexity for the combined list. This can lead to significant performance degradation on large arrays (thousands of items or more).
fix
For performance-critical applications or very large datasets, consider alternatives like JavaScript's native `Set` or `Lodash.uniq` which offer better time complexity (O(n)).
affects: >=1.0.0
gotchaUniqueness is determined solely by strict (`===`) object equality. This means two objects with identical properties but different references (e.g., `{a: 1}` and another `{a: 1}`) will be considered distinct items.
fix
To deduplicate objects based on deep equality, you must implement custom serialization (e.g., `JSON.stringify`) or a custom comparison logic before passing them to `uniqs`, or use a library that supports deep comparisons.
affects: >=1.0.0
breakingThe transition to version 2.0.0 implies potential breaking changes as per semantic versioning. While specific details are not provided in the excerpt, developers upgrading from 1.x should expect behavioral shifts.
fix
Review the package's changelog or release notes for version 2.0.0 to understand specific breaking changes and update your codebase accordingly.
affects: >=2.0.0
Errors
Common errors & fixes
Expected [ { a: 1 }, { a: 1 } ] to be unique, but got two distinct objects.
`uniqs` uses strict (===) equality, so two different object instances, even with identical content, are considered unique.
fix
If you need deep equality, serialize objects (e.g., `JSON.stringify`) or use a custom comparison function before passing them to `uniqs`, or switch to a library that supports deep equality.
Application hangs or runs very slowly when processing a large array with `uniqs`.
The internal implementation of `uniqs` has O(n^2) complexity, making it inefficient for very large input arrays due to repeated `indexOf` calls.
fix
For performance-critical applications with large datasets, use JavaScript's built-in `Set` for O(n) performance with primitive values, or a more optimized library function like Lodash's `uniq` for objects.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
uniqs — npm install uniqs · libregistry