Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Parses a Range from a string (ex. "0...10")
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.travis.yml
History.md
Makefile
README.md
component.json
index.js
package.json
test.js

README.md

Range

Parses a Range from a string (ex. "0...10")

Build Status

Installation

$ component install publicclass/range

Examples

(generated using mocha)

Integers

0..1

range('0..1').should.be.an.instanceof(Range)
range('0..1').should.have.property('inclusive',true)
range('0..1').should.have.property('exclusive',false)
range('0..1').values.should.include(0)
range('0..1').values.should.include(1)
range('0..1').values.should.not.include(-1)
range('0..1').values.should.not.include(1.5)
range('0..1').values.should.not.include(2)
range('0..1').values.should.not.include('0')
range('0..1').values.should.not.include('1')

10..0

range('10..0').should.be.an.instanceof(Range)
range('10..0').should.have.property('inclusive',true)
range('10..0').should.have.property('exclusive',false)
range('10..0').values.should.include(0)
range('10..0').values.should.include(2)
range('10..0').values.should.include(10)
range('10..0').values.should.not.include(-1)
range('10..0').values.should.not.include(1.5)
range('10..0').values.should.not.include('0')
range('10..0').values.should.not.include('1')

0...1

range('0...1').should.be.an.instanceof(Range)
range('0...1').should.have.property('inclusive',false)
range('0...1').should.have.property('exclusive',true)
range('0...1').values.should.include(0)
range('0...1').values.should.not.include(1)
range('0...1').values.should.not.include(-1)
range('0...1').values.should.not.include(1.5)
range('0...1').values.should.not.include(2)
range('0...1').values.should.not.include('0')
range('0...1').values.should.not.include('1')

0-1

range('0-1').should.be.an.instanceof(Range)
range('0-1').should.have.property('inclusive',true)
range('0-1').should.have.property('exclusive',false)
range('0-1').values.should.include(0)
range('0-1').values.should.include(1)
range('0-1').values.should.not.include(-1)
range('0-1').values.should.not.include(1.5)
range('0-1').values.should.not.include(2)
range('0-1').values.should.not.include('0')
range('0-1').values.should.not.include('1')

0..-1

range('0..-1').should.be.an.instanceof(Range)
range('0..-1').should.have.property('inclusive',true)
range('0..-1').should.have.property('exclusive',false)
range('0..-1').values.should.include(0)
range('0..-1').values.should.include(-1)
range('0..-1').values.should.not.include(1)
range('0..-1').values.should.not.include(1.5)
range('0..-1').values.should.not.include(2)
range('0..-1').values.should.not.include('0')
range('0..-1').values.should.not.include('1')

Floats

0.1..1.0

range('0.1..1.0').should.be.an.instanceof(Range)
range('0.1..1.0').should.have.property('inclusive',true)
range('0.1..1.0').should.have.property('exclusive',false)
range('0.1..1.0').values.should.include(.1)
range('0.1..1.0').values.should.include(.5)
range('0.1..1.0').values.should.include(1)
range('0.1..1.0').values.should.not.include(0)
range('0.1..1.0').values.should.not.include(0.01)
range('0.1..1.0').values.should.not.include(0.15)
range('0.1..1.0').values.should.not.include(-1)
range('0.1..1.0').values.should.not.include(1.5)
range('0.1..1.0').values.should.not.include(2)
range('0.1..1.0').values.should.not.include('0')
range('0.1..1.0').values.should.not.include('1')

0.001...1.0

range('0.001...1.0').should.be.an.instanceof(Range)
range('0.001...1.0').should.have.property('inclusive',false)
range('0.001...1.0').should.have.property('exclusive',true)
range('0.001...1.0').values.should.include(0.001)
range('0.001...1.0').values.should.include(0.01)
range('0.001...1.0').values.should.include(0.15)
range('0.001...1.0').values.should.include(0.9)
range('0.001...1.0').values.should.not.include(1)
range('0.001...1.0').values.should.not.include(0)
range('0.001...1.0').values.should.not.include(-1)
range('0.001...1.0').values.should.not.include(1.5)
range('0.001...1.0').values.should.not.include(2)
range('0.001...1.0').values.should.not.include('0')
range('0.001...1.0').values.should.not.include('1')

0.1-15

range('0.1-15').should.be.an.instanceof(Range)
range('0.1-15').should.have.property('inclusive',true)
range('0.1-15').should.have.property('exclusive',false)
range('0.1-15').values.should.include(0.9)
range('0.1-15').values.should.include(1)
range('0.1-15').values.should.include(1.5)
range('0.1-15').values.should.include(2)
range('0.1-15').values.should.include(15)
range('0.1-15').values.should.not.include(0.001)
range('0.1-15').values.should.not.include(0.01)
range('0.1-15').values.should.not.include(0)
range('0.1-15').values.should.not.include(0.15)
range('0.1-15').values.should.not.include(-1)
range('0.1-15').values.should.not.include('0')
range('0.1-15').values.should.not.include('1')

Alphabetic

a..z

range('a..z').should.be.an.instanceof(Range)
range('a..z').should.have.property('inclusive',true)
range('a..z').should.have.property('exclusive',false)
range('a..z').values.should.include('a')
range('a..z').values.should.include('c')
range('a..z').values.should.include('z')
range('a..z').values.should.not.include(-1)
range('a..z').values.should.not.include(1.5)
range('a..z').values.should.not.include(2)
range('a..z').values.should.not.include('0')
range('a..z').values.should.not.include('1')
range('a..z').values.should.not.include('A')
range('a..z').values.should.not.include('Z')

a...z

range('a...z').should.be.an.instanceof(Range)
range('a...z').should.have.property('inclusive',false)
range('a...z').should.have.property('exclusive',true)
range('a...z').values.should.include('a')
range('a...z').values.should.include('c')
range('a...z').values.should.not.include('z')
range('a...z').values.should.not.include(-1)
range('a...z').values.should.not.include(1.5)
range('a...z').values.should.not.include(2)
range('a...z').values.should.not.include('0')
range('a...z').values.should.not.include('1')
range('a...z').values.should.not.include('A')
range('a...z').values.should.not.include('Z')

a-z

range('a-z').should.be.an.instanceof(Range)
range('a-z').should.have.property('inclusive',true)
range('a-z').should.have.property('exclusive',false)
range('a-z').values.should.include('a')
range('a-z').values.should.include('c')
range('a-z').values.should.include('z')
range('a-z').values.should.not.include(-1)
range('a-z').values.should.not.include(1.5)
range('a-z').values.should.not.include(2)
range('a-z').values.should.not.include('0')
range('a-z').values.should.not.include('1')
range('a-z').values.should.not.include('A')
range('a-z').values.should.not.include('Z')

z-a

range('z-a').should.be.an.instanceof(Range)
range('z-a').should.have.property('inclusive',true)
range('z-a').should.have.property('exclusive',false)
range('z-a').values.should.include('a')
range('z-a').values.should.include('c')
range('z-a').values.should.include('z')
range('z-a').values.should.not.include(-1)
range('z-a').values.should.not.include(1.5)
range('z-a').values.should.not.include(2)
range('z-a').values.should.not.include('0')
range('z-a').values.should.not.include('1')
range('z-a').values.should.not.include('A')
range('z-a').values.should.not.include('Z')

A-Z

range('A-Z').should.be.an.instanceof(Range)
range('A-Z').should.have.property('inclusive',true)
range('A-Z').should.have.property('exclusive',false)
range('A-Z').values.should.include('A')
range('A-Z').values.should.include('C')
range('A-Z').values.should.include('Z')
range('A-Z').values.should.not.include(-1)
range('A-Z').values.should.not.include(1.5)
range('A-Z').values.should.not.include(2)
range('A-Z').values.should.not.include('0')
range('A-Z').values.should.not.include('1')
range('A-Z').values.should.not.include('a')
range('A-Z').values.should.not.include('z')

License

MIT

Something went wrong with that request. Please try again.