Registry / data / quickselect

quickselect

JSON →
library0.2.2jsnpmunverified

quickselect is a highly optimized, tiny JavaScript library implementing the Floyd-Rivest selection algorithm. It efficiently partially sorts an array in-place, ensuring that elements up to a specified index `k` are the smallest in the given range. The current stable version is 3.0.0, which was a significant update dropping CommonJS and UMD builds, making it exclusively ESM and requiring modern ES syntax. Releases appear to be infrequent, driven by significant architectural changes or feature additions. Its primary differentiator is its minimal footprint and speed for selection tasks compared to full sorting algorithms, making it ideal for scenarios where only a subset of sorted elements is needed.

npm install quickselect
INSTALL
IMPORT
SIG · QUICKSELECT
Q
quickselect
datajavascriptv0.2.2
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.

quickselect
import quickselect from 'quickselect';
const quickselect = require('quickselect');
The package is ESM-only since v3.0.0, meaning CommonJS `require()` is no longer supported.

This example demonstrates how to use `quickselect` to partially sort an array in-place, ensuring that elements up to a specific index `k` are the smallest in the given range.

import quickselect from 'quickselect'; const arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39]; // Rearrange the array such that elements up to index 8 are the smallest. // The 8th element (0-indexed) will be the (8 - 0 + 1)th smallest value in the original array. quickselect(arr, 8); console.log(arr); // Expected output similar to: [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95] // Note: The order of elements *before* k is not guaranteed, only that they are smaller than or equal to arr[k].
Debug
Known issues
breakingVersion 3.0.0 dropped UMD build and full support for CommonJS, making the package ESM-only.
fix
Migrate your project to use ES modules or ensure your build configuration transpiles `quickselect` as an ES module. Use `import quickselect from 'quickselect';`.
affects: >=3.0.0
breakingVersion 3.0.0 uses modern ES syntax, which may break compatibility with older environments (e.g., IE11) without transpilation.
fix
Ensure your build process (e.g., Babel) includes `quickselect` in transpilation if targeting environments that do not fully support modern JavaScript.
affects: >=3.0.0
gotchaVersion 1.1.1 had issues with some Webpack builds due to the `module` field in `package.json`, which was later rectified.
fix
Upgrade to `v2.0.0` or later, which correctly reintroduced the `module` field and resolved previous Webpack compatibility problems.
affects: 1.1.1
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use CommonJS `require()` to import `quickselect` version 3.0.0 or later in an ESM environment.
fix
Switch to ES module import syntax: `import quickselect from 'quickselect';`.
SyntaxError: Unexpected token '...' (related to modern JavaScript features)
Running `quickselect` v3.0.0+ in an environment that does not fully support modern ES syntax without proper transpilation.
fix
Ensure your runtime environment supports modern JavaScript or configure your build pipeline (e.g., Babel, esbuild) to transpile `quickselect`.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
quickselect — npm install quickselect · libregistry