Efficiently merges 2 or more sorted arrays using a priority queue (min-heap). Version 3.0.0 requires Node.js >=20. Ships TypeScript types. Key differentiators: supports custom comparator, output metadata (array index and value index), and deduplication via unique option. Uses a heap-based approach for O(n log k) time complexity. No external runtime dependencies.
npm install merge-k-sorted-arraysNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic merge, custom comparator, output metadata, and unique/dedupe usage with TypeScript.
Use 'import' syntax instead of 'require()'. Ensure your project is configured for ESM.
Upgrade Node.js to version 20 or later.
Wrap arrays in an array: merge([arr1, arr2, ...]) instead of merge(arr1, arr2, ...).
Destructure as [arrIdx, valIdx, value] to access the actual value.
If you need a specific occurrence, preprocess arrays to ensure uniqueness.
Add "type": "module" to package.json, use .mjs extension, or use dynamic import(). For Node.js <20, upgrade to Node >=20.
Use ESM import: import merge from 'merge-k-sorted-arrays'. For v3, call merge([arr1, arr2, ...]).
Ensure first argument is an array of arrays, e.g., merge([[1,2], [3,4]]).
Pass a function as comparator: e.g., { comparator: (a, b) => a - b }.No dependency data recorded yet.