{"id":15010,"library":"uniqs","title":"uniqs: Unique and Union Utility","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/fgnass/uniqs","tags":["javascript","unique","uniq","dedupe","union"],"install":[{"cmd":"npm install uniqs","lang":"bash","label":"npm"},{"cmd":"yarn add uniqs","lang":"bash","label":"yarn"},{"cmd":"pnpm add uniqs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import { uniqs } from 'uniqs';","symbol":"uniqs","correct":"const uniqs = require('uniqs');"},{"note":"For ESM environments, assuming a default export, this is the standard import. Attempting to destructure it as a named export from CommonJS will fail.","wrong":"const { uniqs } = require('uniqs');","symbol":"uniqs","correct":"import uniqs from 'uniqs';"}],"quickstart":{"code":"const uniqs = require('uniqs');\n\n// Example usage to deduplicate a list\nconst foo = { id: 23 };\nconst list = [3, 2, 2, 1, foo, foo];\nconst uniqueList = uniqs(list);\nconsole.log('Unique list:', uniqueList);\n// Expected: [3, 2, 1, { id: 23 }]\n\n// Example usage to create a union of multiple lists\nconst listA = [2, 1, 1];\nconst listB = [2, 3, 3, 4];\nconst listC = [4, 3, 2];\nconst unionList = uniqs(listA, listB, listC);\nconsole.log('Union list:', unionList);\n// Expected: [2, 1, 3, 4]\n\n// Example with individual items and a list\nconst mixedInput = uniqs(3, 2, 2, [1, 1, 2]);\nconsole.log('Mixed input:', mixedInput);\n// Expected: [3, 2, 1]","lang":"javascript","description":"Demonstrates deduplication of a single list, union of multiple lists, and handling of mixed individual items and lists."},"warnings":[{"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)).","message":"uniqs 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).","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Uniqueness 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the package's changelog or release notes for version 2.0.0 to understand specific breaking changes and update your codebase accordingly.","message":"The 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.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"`uniqs` uses strict (===) equality, so two different object instances, even with identical content, are considered unique.","error":"Expected [ { a: 1 }, { a: 1 } ] to be unique, but got two distinct objects."},{"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.","cause":"The internal implementation of `uniqs` has O(n^2) complexity, making it inefficient for very large input arrays due to repeated `indexOf` calls.","error":"Application hangs or runs very slowly when processing a large array with `uniqs`."}],"ecosystem":"npm"}