
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
min-max-range
Advanced tools
Implementation of range data structures using plain JavaScript arrays. Built with a functional programming approach in mind.
npm install min-max-range<script src="https://cdn.jsdelivr.net/npm/min-max-range@1/dist/min-max-range.umd.min.js"></script> in the head of your HTML file.minMaxRangetype EmptyRange = [];
type Range1D = [number, number];
type Range2D = [Range1D, Range1D];
type MultiDimRange = [Range1D, Range1D, ...Range1D[]];
type NonEmptyRange = Range1D | MultiDimRange;
type Range = EmptyRange | NonEmptyRange;
type Coordinates2D = [number, number];
type Transform<Input, Output> = (value: Input) => Output;
Check if value is range.
value (any): Value to test.Check if value is empty range.
value (any): Value to test.Check if value is non-empty range.
value (any): Value to test.Check if value is one-dimensional range.
value (any): Value to test.Check if value is two-dimensional range.
value (any): Value to test.Check if value is multi-dimensional range.
value (any): Value to test.Return minimum value of each dimension of a range.
range (Range): The range.Example
var minOfRange = min([-1, 1]);
console.log(minOfRange);
// expected output: -1
Return maximum value of each dimension of a range.
range (Range): The range.Example
var maxOfRange = max([1, -1]);
console.log(maxOfRange);
// expected output: 1
Return mean of each dimension of a range.
range (Range): The range.Example
var meanOfRange = mean([-1, 1]);
console.log(meanOfRange);
// expected output: 0
Return the first value of each dimension of a range.
range (Range): The range.Example
var firstOfRange = first([0, 1]);
console.log(firstOfRange);
// expected output: 0
Return the last value of each dimension of a range.
range: (Range): The range.Example
var lastOfRange = last([0, 1]);
console.log(lastOfRange);
// expected output: 1
Return length of each dimension of a range.
range (Range): The range.Example
var lengthOfRange = length([-1, 1]);
console.log(lengthOfRange);
// expected output: 2
Return bottom-left coordinates of two-dimensional range.
range (Range2D): Two-dimensional range.Example
var coords = bottomLeft([[0, 1], [0, 1]]);
console.log(coords);
// expected output: Array [0, 0]
Return bottom-right coordinates of two-dimensional range.
range (Range2D): Two-dimensional range.Example
var coords = bottomRight([[0, 1], [0, 1]]);
console.log(coords);
// expected output: Array [1, 0]
Return top-left coordinates of two-dimensional range.
range (Range2D): Two-dimensional range.Example
var coords = topLeft([[0, 1], [0, 1]]);
console.log(coords);
// expected output: Array [0, 1]
Return top-right coordinates of two-dimensional range.
range (Range2D): Two-dimensional range.Example
var coords = topRight([[0, 1], [0, 1]]);
console.log(coords);
// expected output: Array [1, 1]
Move range by a specified delta.
range (Range): Range to move.delta (number | number[]): Delta to move range by. Has to have equal length as range in case of multi-dimensional ranges.Example
var shiftedRange = shift([0, 1], -0.5);
console.log(shiftedRange);
// expected output: Array [-0.5, 0.5]
Return range with values in each dimension sorted from lowest to highest.
range: (Range): The range.Example
var sortedRange = sort([1, -1]);
console.log(sortedRange);
// expected output: Array [-1, 1]
Return range with values in each dimensions swapped.
range (Range): The range.Example
var reversedRange = reverse([0, 1]);
console.log(reversedRange);
// expected output: Array [1, 0]
Return method to check if value is included in range.
range (Range): Reference range.Example
var isInside = inside([0, 1]);
console.log(isInside(0.5));
// expected output: true
Return method to check if one range is included in another.
range (Range): Reference range.Example
var isIncluded = includes([-1, 1]);
console.log(isIncluded([0, 1]));
// expected output: true
Return method to check if range is part of another.
range (Range): Reference range.Example
var isPartOf = partOf([0, 1]);
console.log(isPartOf([-1, 1]));
// expected output: true
Return method to determine intersection of range with reference.
range (Range): Reference range.Example
var intersection = intersect([-1, 1]);
console.log(intersection([0, 2]));
// expected output: Array [0, 1]
npm install: Install dependenciesnpm test: Run test suitenpm start: Run npm run build in watch modenpm run test:watch: Run test suite in interactive watch modenpm run test:prod: Run linting and generate coveragenpm run build: Generate bundles and typings, create docsnpm run lint: Lints codePull requests are welcome! Please include new tests for your code and make sure that all tests succeed running npm test.
FAQs
Implementation of range data structures using plain JavaScript arrays.
We found that min-max-range 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.