Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
binary-search-with-index
Advanced tools
Fork of `binary-search` module that passes indexes to comparators
This is a fork of the binary-search npm package. The only difference is that this package is sublicensed under MIT, and that the comparators are passed the current index and array.
This is a really tiny, stupid, simple binary search library for Node.JS. We wrote it because existing solutions were bloated and incorrect.
This version is a straight port of the Java version mentioned by Joshua Bloch in his article, Nearly All Binary Searches and Merge Sorts are Broken.
Thanks to Conrad Irwin and Michael Marino for, ironically, pointing out bugs.
var bs = require("binary-search-with-index");
bs([1, 2, 3, 4], 3, function(a, b, index, array) { return a - b; }); // => 2
bs([1, 2, 4, 5], 3, function(a, b, index, array) { return a - b; }); // => -3
Be advised that passing in a comparator function is required. Since you're probably using one for your sort function anyway, this isn't a big deal.
The 3rd and 4th arguments to the comparator are the current index and array, respectively. You shouldn't normally need the index or array to compare values, but it's there if you do.
You may also, optionally, specify an input range as the final two parameters, in case you want to limit the search to a particular range of inputs. However, be advised that this is generally a bad idea (but sometimes bad ideas are necessary).
To the extent possible by law, The Dark Sky Company, LLC has waived all copyright and related or neighboring rights to the original library. This fork is licensed under MIT.
FAQs
Fork of `binary-search` module that passes indexes to comparators
The npm package binary-search-with-index receives a total of 0 weekly downloads. As such, binary-search-with-index popularity was classified as not popular.
We found that binary-search-with-index demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.