Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Convert any range to an exclusive range in natural order
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
LICENSE
README.md
package.json

README.md

natural-range

Convert any range to an exclusive range in natural order.

Installation

npm install natural-range

Example

var assert = require('assert');
var Range = require('natural-range');

var range = new Range({ from: 3, to: 1 });

assert.equal(range.from, 1);
assert.equal(range.to, 4);
assert.equal(range.reversed, true);

See test/test.js for more examples.

API

var range = new Range(options);
  • options - an object literal supports these options:

    • from - the start number
    • to - the end number
    • exclusive - a boolean denoting if the range is exclusive
    • length - if from or to is negative, and this option is provided, the negative number means backwards indexing and is relative to length
  • range - the range object in natural order containing these properties:

    • from - the start number
    • to - the end number
    • reversed - a boolean denoting if the original range is in reversed order
Something went wrong with that request. Please try again.