mjpeg-consumer
Advanced tools
Comparing version 1.1.0 to 2.0.0
var util = require('util'); | ||
var Transform = require('stream').Transform; | ||
require("buffertools").extend(); | ||
@@ -8,8 +7,6 @@ var lengthRegex = /Content-Length:\s*(\d+)/i; | ||
// Start of Image | ||
var soi = new Buffer(2); | ||
soi.writeUInt16LE(0xd8ff, 0); | ||
var soi = Buffer.from([0xff, 0xd8]); | ||
// End of Image | ||
var eoi = new Buffer(2); | ||
eoi.writeUInt16LE(0xd9ff, 0); | ||
var eoi = Buffer.from([0xff, 0xd9]); | ||
@@ -25,3 +22,2 @@ function MjpegConsumer(options) { | ||
this.oldBufferType = process.version.split('.')[0] === 'v0'; | ||
this.reading = false; | ||
@@ -43,9 +39,3 @@ this.contentLength = null; | ||
this.contentLength = len; | ||
this.buffer = new Buffer(len); | ||
if (this.oldBufferType) { | ||
this.buffer = new Buffer(0); | ||
} | ||
// Fill the buffer so we don't leak random bytes | ||
// more info: https://nodejs.org/api/buffer.html#buffer_new_buffer_size | ||
this.buffer.fill(0); | ||
this.buffer = Buffer.alloc(len); | ||
this.bytesWritten = 0; | ||
@@ -63,7 +53,3 @@ | ||
if (this.oldBufferType) { | ||
this.buffer = this.buffer.concat(chunk.slice(start, bufEnd)); | ||
} else { | ||
chunk.copy(this.buffer, 0, start, bufEnd); | ||
} | ||
chunk.copy(this.buffer, 0, start, bufEnd); | ||
@@ -90,7 +76,3 @@ this.bytesWritten = chunk.length - start; | ||
if (this.oldBufferType) { | ||
this.buffer = this.buffer.concat(chunk.slice(bufStart, bufEnd)); | ||
} else { | ||
chunk.copy(this.buffer, this.bytesWritten, bufStart, bufEnd); | ||
} | ||
chunk.copy(this.buffer, this.bytesWritten, bufStart, bufEnd); | ||
@@ -97,0 +79,0 @@ this.bytesWritten += bufEnd - bufStart; |
{ | ||
"name": "mjpeg-consumer", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "a stream implementation that consumes http mjpeg streams and emits jpegs as buffers", | ||
@@ -10,14 +10,11 @@ "main": "index.js", | ||
}, | ||
"dependencies": { | ||
"buffertools": "~2.1.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.4", | ||
"coveralls": "^2.13.3", | ||
"file-on-write": "~0.2.0", | ||
"jscoverage": "^0.6.0", | ||
"nodeunit": "^0.9.1", | ||
"request": "^2.67.0" | ||
"nodeunit": "^0.11.3", | ||
"request": "^2.88.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=8.0.0" | ||
}, | ||
@@ -24,0 +21,0 @@ "repository": "https://github.com/mmaelzer/mjpeg-consumer", |
@@ -76,5 +76,5 @@ var MjpegConsumer = (function(coverage) { | ||
var consumer = new MjpegConsumer(); | ||
var buf = new Buffer("Content-Length: " + IMG.length + "\n\n"); | ||
var fhalfImg = new Buffer(500); | ||
var shalfImg = new Buffer(IMG.length - 500); | ||
var buf = Buffer.from("Content-Length: " + IMG.length + "\n\n"); | ||
var fhalfImg = Buffer.alloc(500); | ||
var shalfImg = Buffer.alloc(IMG.length - 500); | ||
@@ -99,5 +99,5 @@ IMG.copy(fhalfImg, 0, 0, fhalfImg.length); | ||
var consumer = new MjpegConsumer(); | ||
var buf = new Buffer("Content-Length: " + IMG.length + "\n\n"); | ||
var fhalfImg = new Buffer(500); | ||
var shalfImg = new Buffer(IMG.length - 500); | ||
var buf = Buffer.from("Content-Length: " + IMG.length + "\n\n"); | ||
var fhalfImg = Buffer.alloc(500); | ||
var shalfImg = Buffer.alloc(IMG.length - 500); | ||
@@ -120,4 +120,4 @@ IMG.copy(fhalfImg, 0, 0, fhalfImg.length); | ||
var chunkHeaders = new Buffer('Content-Type: image/jpeg\nContent-Length: '+ IMG.length + '\n\n'); | ||
var chunkBoundary = new Buffer(boundary + '\n'); | ||
var chunkHeaders = Buffer.from('Content-Type: image/jpeg\nContent-Length: '+ IMG.length + '\n\n'); | ||
var chunkBoundary = Buffer.from(boundary + '\n'); | ||
@@ -124,0 +124,0 @@ function getTestConsumer(t) { |
Sorry, the diff of this file is not supported yet
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
0
10926
8
245
- Removedbuffertools@~2.1.0
- Removedbuffertools@2.1.6(transitive)