in-range
Check if a number is in a given range
Last updated 2 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install in-range 
SYNC missed versions from official npm registry.

in-range Build Status

Check if a number is in a given range

Install

$ npm install in-range

Usage

const inRange = require('in-range');

inRange(30, {end: 100}); // 0..100
//=> true

inRange(30, {start: 10, end: 100}); // 10..100
//=> true

inRange(30, {start: 100, end: 10}); // 10..100
//=> true

inRange(30, {end: 10}); // 0..10
//=> false

API

inRange(number, range)

number

Type: number

Number to check.

range

Type: Object

start

Type: number
Default: 0

Start of the range.

end

Type: number

End of the range.

License

MIT © Sindre Sorhus

Current Tags

  • 2.0.0                                ...           latest (2 years ago)

2 Versions

  • 2.0.0                                ...           2 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 3
Last Day 0
Last Week 0
Last Month 16
Dependencies (0)
None
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |