Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
fast-unique-numbers
Advanced tools
A module to create a set of unique numbers as fast as possible.
This module is meant to create unique numbers within a given Map or Set. To achieve that as fast as possible the resulting set of numbers will only contain integers. For as long as possible only small integers will be used. This is a special integer representation that V8 uses to store integers more efficiently.
To verify the expected perfomance benefit an expectation test is used to make sure small integers do actually perform better. A complementary test is used to make sure the perfomance gain achieved in Chromium based browsers and Node.js is not negated by causing unexpected behavior when running in Firefox.
This module is available on npm and can be installed by running the following command:
npm install fast-unique-numbers
This module exports two functions.
This function takes a Set
of numbers as argument and appends a new unique number to it. It also returns that number.
import { addUniqueNumber } from 'fast-unique-numbers';
const set = new Set([ 1, 4, 8 ]);
const uniqueNumber = addUniqueNumber(set);
console.log(uniqueNumber); // 3
console.log(set); // Set(4) { 1, 4, 8, 3 }
This function can be used to generate a unique number which is not yet present in the given Set
or is no key in the given Map
. The resulting number gets not appended. It only gets returned.
import { generateUniqueNumber } from 'fast-unique-numbers';
const map = new Map([
[ 1, 'something' ],
[ 4, 'something else' ]
]);
const uniqueNumber = generateUniqueNumber(map);
console.log(uniqueNumber); // 2
FAQs
A module to create a set of unique numbers as fast as possible.
We found that fast-unique-numbers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
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.