Skip to content

Check whether a number, english alphabet character or a date is between two others.

License

Notifications You must be signed in to change notification settings

AlvaroBernalG/in-between

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

in-between

Test whether a number, english alphabet character or a date is between two others.

Build Status npm version JavaScript Style Guide

Augmented version of in-range made by Sindre Sorhus with a more functional taste

Install

$ npm install in-between

Usage

With numbers:

const between = require('in-between')

const between1and10 = between(1, 10)

between1and10(10) //=> false

between1and10(3) //=> true

betweenAandZ('*') //=> throws error

between1and10(1) //=> false

between(100, 200)(101) //=> true

Works with alphabet characters:

const between = require('in-between')

const betweenAandD = between('a', 'd')

betweenAandD('b') //=> true

betweenAandD('z') //=> false

Works with Dates as well:

const between = require('in-between')

let myGraduation = new Date("October 13, 2014 11:13:00")

let myFirstJob =  new Date("September 1, 2015 11:13:00")

let myBirthDay =  new Date("January 10, 2015 10:11:03")

between(myGraduation, myFirstJob)(myBirthDay) //=> true

You can include the boundaries:

const between = require('in-between')

between(3, 4, true)(3) //=> true

between('a', 'b', true)('a') // => true

API

between(number | string | date, number | string | date, boolean) => function(number | string | date) => boolean

License

MIT © Alvaro Bernal

Releases

No releases published

Packages

No packages published