Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Uniform and weighted shuffling and sampling, just like
deck, but utilizing
Alea instead of Math.random
.
var deck = require('alea-deck');
deck.shuffle([1, 2, 3, 4]);
// => [1, 4, 2, 3]
deck.pick([1, 2, 3, 4]);
// => 2
deck.shuffle({
a: 10,
b: 8,
c: 2,
d: 1,
e: 1
});
// => ['b', 'a', 'c', 'd', 'e']
deck.pick({
a: 10,
b: 8,
c: 2,
d: 1,
e: 1
});
// => a
$ npm install alea-deck
var deck = require('alea-deck');
deck.shuffle(collection)
If collection
is an Array, returns a new shuffled Array based on a unifrom
distributionm without mutating the original Array.
Otherwise, if collection
is an Object, returns a new shuffled Array of
collection
's visible keys based on the value weights of collection
.
deck.pick(collection)
Samples collection
without mutating collection
.
If collection
is an Array, returns a random element from collection
with a
uniform distribution.
Otherwise, if collection
is an Object, returns a random key from
collection
biased by its normalized value.
deck.normalize(obj)
Return a new obj
Object where the values have been divided by the sum of all
the values such that the sum of all the values in the returned Object is 1.
If any weights are < 0
, an Error is thrown.
FAQs
Uniform and weighted shuffling and sampling with Alea
The npm package alea-deck receives a total of 20 weekly downloads. As such, alea-deck popularity was classified as not popular.
We found that alea-deck 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.