timeranges-plus
v1.3.2
Published
Emulated HTML5 Media TimeRanges interface with additional utilitites
Downloads
44
Readme
timeranges-plus
timeranges-plus is a wrapper for HTML5 Media TimeRanges Interface with the main purpose of providing additional functionalities.
timeranges-plus can be used in browsers or as a Node JS module.
Usage
Browsers
Simply include timeranges-plus.min.js on your page.
Node JS
Install latest released version:
npm install timeranges-plus
A simple Node JS code example using timeranges-plus:
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.add(0,10);
trpInstance.add(20,30);
trpInstance.toString();
Instantiate
Basic
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
With initial range
var Trp = require('timeranges-plus');
var trpInstance = new Trp(startValue, endValue);
From HTML 5 Media Timeranges
var Trp = require('timeranges-plus');
var trpInstance = Trp.wrap(html5MediaTimeranges);
Populate
Basic
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.add(startValue, endValue);
During instantiation
var Trp = require('timeranges-plus');
var trpInstance = new Trp(startValue, endValue);
Combining other timeranges
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.merge(timeranges)
Display
String
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.toString();
Duration
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.toDuration();
Under the hood
Auto-sort
var Trp = require('timeranges-plus');
var trpInstance = new Trp();
trpInstance.add(20,30);
trpInstance.add(0,10);
trpInstance.toString(); // yields: [[0,10],[20,30]]
Auto-overlap
var Trp = require('timeranges-plus');
var trpInstance1 = new Trp();
var trpInstance2 = new Trp(5,25);
trpInstance1.add(0,10);
trpInstance1.add(20,30);
trpInstance1.add(40,50);
trpInstance1.merge(trpInstance2);
trpInstance1.toString(); // yields: [[0,30],[40,50]]
Transporting
var trpInstance1 = new Trp();
trpInstance1.add(0, 10);
trpInstance1.add(40, 50);
trpInstance1.add(20, 30);
var trpInstance2 = Trp.unpack(trpInstance1.pack());
Development environment
Linux or similar is assumed.
Dependencies
- Node JS
- mocha (for tests)
- eslint (for linting)
- uglifyjs (for builds)
Unit tests
npm test
Linting
npm run lint
Packaging
npm run build