Comparing version 0.0.6 to 0.0.7
@@ -44,2 +44,10 @@ var M3U = module.exports = function M3U() { | ||
M3U.prototype.removePlaylistItem = function removePlaylistItem(index) { | ||
if (index < this.items.PlaylistItem.length && index >= 0){ | ||
this.items.PlaylistItem.splice(index, 1); | ||
} else { | ||
throw new RangeError('M3U PlaylistItem out of range'); | ||
} | ||
}; | ||
M3U.prototype.addMediaItem = function addMediaItem(data) { | ||
@@ -46,0 +54,0 @@ this.items.MediaItem.push(M3U.MediaItem.create(data)); |
{ | ||
"name" : "m3u8", | ||
"version" : "0.0.6", | ||
"version" : "0.0.7", | ||
"description" : "streaming m3u8 parser for Apple's HTTP Live Streaming protocol", | ||
@@ -22,3 +22,4 @@ "main" : "./parser.js", | ||
"mocha" : "~1.6.0", | ||
"sinon" : "~1.5.0" | ||
"sinon" : "~1.5.0", | ||
"should" : "7.1.1" | ||
}, | ||
@@ -25,0 +26,0 @@ "engine" : { |
@@ -80,4 +80,12 @@ var util = require('util'), | ||
this.currentItem.set('title', data[1]); | ||
if (this.playlistDiscontinuity) { | ||
this.currentItem.set('discontinuity', true); | ||
this.playlistDiscontinuity = false; | ||
} | ||
}; | ||
m3uParser.prototype['EXT-X-DISCONTINUITY'] = function parseInf() { | ||
this.playlistDiscontinuity = true; | ||
} | ||
m3uParser.prototype['EXT-X-BYTERANGE'] = function parseByteRange(data) { | ||
@@ -84,0 +92,0 @@ this.currentItem.set('byteRange', data); |
@@ -44,2 +44,24 @@ var fs = require('fs'), | ||
describe('#removePlaylistItem', function() { | ||
it('should remove a PlaylistItem at a specifed index', function() { | ||
var m3u = getM3u(); | ||
m3u.addPlaylistItem({}); | ||
m3u.removePlaylistItem(0); | ||
m3u.items.PlaylistItem.length.should.eql(0); | ||
}); | ||
}); | ||
describe('#removePlaylistItemOutOfRange', function() { | ||
it('should thow an error when trying to remove a playlist item out of range', function() { | ||
var m3u = getM3u(); | ||
m3u.addPlaylistItem({}); | ||
m3u.addPlaylistItem({}); | ||
m3u.removePlaylistItem.bind(m3u, 3).should.throw(RangeError); | ||
}); | ||
}); | ||
describe('#addMediaItem', function() { | ||
@@ -46,0 +68,0 @@ it('should create and add a MediaItem', function() { |
@@ -10,3 +10,3 @@ var m3u8 = require('../parser'), | ||
parser.on('error', function(error) { | ||
error.message.should.include('Non-valid M3U file. First line: '); | ||
error.message.should.containEql('Non-valid M3U file. First line: '); | ||
done(); | ||
@@ -73,2 +73,15 @@ }); | ||
describe('#EXT-X-DISCONTINUITY', function() { | ||
it('should indicate discontinuation on subsequent playlist item', function() { | ||
var parser = getParser(); | ||
parser['EXT-X-DISCONTINUITY'](); | ||
parser.EXTINF('4.5,some title'); | ||
parser.currentItem.constructor.name.should.eql('PlaylistItem'); | ||
parser.currentItem.get('duration').should.eql(4.5); | ||
parser.currentItem.get('title').should.eql('some title'); | ||
parser.currentItem.get('discontinuity').should.eql(true); | ||
}); | ||
}); | ||
describe('#EXT-X-STREAM-INF', function() { | ||
@@ -75,0 +88,0 @@ it('should create a new Stream item', function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44677
1072
3