range-within

1.1.0 • Public • Published

range-within - Check that one range is entirely contained within another range

Checks that one range of numbers, like [1, 5] is enirely contained within another range of numbers, like [0, 10].

Usage

The function takes two arguments, each of which is an object containing the start and end properties, which must be numbers.

The order of the ranges doesn't matter; you can put the larger or the shorter range first.

const within = require('range-within');
 
let range1 = {start: 1, end: 10};
let range2 = {start: 5, end: 10};
 
let result = within(range1, range2); // returns true

Package Sidebar

Install

npm i range-within

Weekly Downloads

1

Version

1.1.0

License

Unlicense

Unpacked Size

2.42 kB

Total Files

3

Last publish

Collaborators

  • anton-ivanov