range-utils

1.1.0 • Public • Published

range-utils

Javascript utilities to work with ranges. A range is an object with a least two property: offset and length.

Build Status NPM version

Installation

$ npm install range-utils

Usage

// Initialize a range
 
var from0To10 = Range(0, 10);
var from5To20 = Range(5, 15);
var withProperty = Range(0, 10, { hello: 'world' });
 
// Check if a range contains another range
Range.contains(
    Range(0, 10),
    Range(5, 2)
);
 
// Check that two ranges are collapsing
Range.areCollapsing(
    Range(0, 10),
    Range(9, 10)
);
 
// Translate a range
Range.moveBy(a, 10);
 
// Enlarge a range
Range.enlarge(a, 10);

Readme

Keywords

none

Package Sidebar

Install

npm i range-utils

Weekly Downloads

382

Version

1.1.0

License

Apache-2.0

Last publish

Collaborators

  • samypesse