Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
extra-rand
Advanced tools
Changelog
0.3.0 (2024-04-18)
randomIntByModel
, randomIntInclusiveByModel
randomByModel
randomByWeight
to randomIndexByWeight
Readme
Yet another random library.
npm install --save extra-rand
# or
yarn add extra-rand
function random(min: number, max: number): number
The function returns a number in the range [min, max)
.
function randomInt(min: number, max: number): number
The function returns an integer in the range [Math.ceil(min), Math.floor(max))
.
function randomIntInclusive(min: number, max: number): number
The function returns an integer in the range [Math.ceil(min), Math.floor(max)]
.
function randomBool(probabilityOfTrue: number): boolean
function randomIndexByWeight(weights: NonEmptyArray<number>): number
The function returns an index of one of weights.
interface IWeighted {
weight: number
}
function randomWeighted<T extends IWeighted>(values: NonEmptyArray<T>): T
type IWeightModel<T> = NonEmptyArray<{
weight: number
value: T
}>
function randomByWeightModel<T>(model: IWeightModel<T>): number
enum Type {
Float
, Integer
, IntegerInclusive
}
type IRandomModel =
| number
| Getter<number>
| {
type: Type
min: number
max: number
}
| NonEmptyArray<{
weight: number
value: IRandomModel
}>
function randomByModel(model: IRandomModel): number
function mapToRange(
value: number
, oldMin: number, oldMax: number
, newMin: number, newMax: number
): number
A low-level function helps you to use random number generators other than Math.random()
.
function mapToIndexByWeight(
value: number
, oldMin: number, oldMax: number
, weights: NonEmptyArray<number>
): number
A low-level function helps you to use random number generators other than Math.random()
.
FAQs
Yet another random library
The npm package extra-rand receives a total of 464 weekly downloads. As such, extra-rand popularity was classified as not popular.
We found that extra-rand demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.