@bemoje/numeric-range

A class with min and max properties and exposes methods for determining if a value is inside or outside the range between the min and max values.

Usage no npm install needed!

<script type="module">
  import bemojeNumericRange from 'https://cdn.skypack.dev/@bemoje/numeric-range';
</script>

README

@bemoje/numeric-range

A class with min and max properties and exposes methods for determining if a value is inside or outside the range between the min and max values.

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

Installation

npm install @bemoje/numeric-range
npm install --save @bemoje/numeric-range
npm install --save-dev @bemoje/numeric-range

Usage

import NumericRange from '@bemoje/numeric-range'

const range = new NumericRange(1, 10)

range.isInside(4)
//=> true
range.isInside(0)
//=> false

range.isOutside(4)
//=> false
range.isOutside(0)
//=> true

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

NumericRange

A class with min and max properties and exposes methods for determining if a value is inside or outside the range between the min and max values.

Parameters
  • min number The minimum value of the range (optional, default Number.MIN_SAFE_INTEGER)

  • max number The maximum value of the range (optional, default Number.MAX_SAFE_INTEGER)

isInside

Parameters
  • value number The numeric value to determine whether or not is inside the range.
Returns

boolean boolean

isOutside

Parameters
  • value number The numeric value to determine whether or not is outside the range.
Returns

boolean boolean