Comparing version 14.1.0 to 14.1.1
@@ -341,2 +341,3 @@ 'use strict'; | ||
}; | ||
const onSocketConnect = () => { | ||
@@ -347,2 +348,3 @@ | ||
}; | ||
const onStreamError = (err) => { | ||
@@ -369,2 +371,3 @@ | ||
} | ||
break; | ||
@@ -371,0 +374,0 @@ |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const Hoek = require('hoek'); | ||
const Stream = require('stream'); | ||
@@ -15,31 +14,31 @@ | ||
module.exports = internals.Payload = function (payload, encoding) { | ||
module.exports = internals.Payload = class extends Stream.Readable { | ||
Stream.Readable.call(this); | ||
constructor(payload, encoding) { | ||
const data = [].concat(payload || ''); | ||
let size = 0; | ||
for (let i = 0; i < data.length; ++i) { | ||
const chunk = data[i]; | ||
size = size + chunk.length; | ||
data[i] = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk); | ||
} | ||
super(); | ||
this._data = Buffer.concat(data, size); | ||
this._position = 0; | ||
this._encoding = encoding || 'utf8'; | ||
}; | ||
const data = [].concat(payload || ''); | ||
let size = 0; | ||
for (let i = 0; i < data.length; ++i) { | ||
const chunk = data[i]; | ||
size = size + chunk.length; | ||
data[i] = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk); | ||
} | ||
Hoek.inherits(internals.Payload, Stream.Readable); | ||
this._data = Buffer.concat(data, size); | ||
this._position = 0; | ||
this._encoding = encoding || 'utf8'; | ||
} | ||
_read(size) { | ||
internals.Payload.prototype._read = function (size) { | ||
const chunk = this._data.slice(this._position, this._position + size); | ||
this.push(chunk, this._encoding); | ||
this._position = this._position + chunk.length; | ||
const chunk = this._data.slice(this._position, this._position + size); | ||
this.push(chunk, this._encoding); | ||
this._position = this._position + chunk.length; | ||
if (this._position >= this._data.length) { | ||
this.push(null); | ||
if (this._position >= this._data.length) { | ||
this.push(null); | ||
} | ||
} | ||
}; |
@@ -5,7 +5,7 @@ 'use strict'; | ||
const Boom = require('boom'); | ||
const Hoek = require('hoek'); | ||
const Stream = require('stream'); | ||
const Boom = require('boom'); | ||
// Declare internals | ||
@@ -16,32 +16,31 @@ | ||
module.exports = internals.Recorder = function (options) { | ||
module.exports = internals.Recorder = class extends Stream.Writable { | ||
Stream.Writable.call(this); | ||
constructor(options) { | ||
this.settings = options; // No need to clone since called internally with new object | ||
this.buffers = []; | ||
this.length = 0; | ||
}; | ||
super(); | ||
Hoek.inherits(internals.Recorder, Stream.Writable); | ||
this.settings = options; // No need to clone since called internally with new object | ||
this.buffers = []; | ||
this.length = 0; | ||
} | ||
_write(chunk, encoding, next) { | ||
internals.Recorder.prototype._write = function (chunk, encoding, next) { | ||
if (this.settings.maxBytes && | ||
this.length + chunk.length > this.settings.maxBytes) { | ||
if (this.settings.maxBytes && | ||
this.length + chunk.length > this.settings.maxBytes) { | ||
return this.emit('error', Boom.entityTooLarge('Payload content length greater than maximum allowed: ' + this.settings.maxBytes)); | ||
} | ||
return this.emit('error', Boom.entityTooLarge('Payload content length greater than maximum allowed: ' + this.settings.maxBytes)); | ||
this.length = this.length + chunk.length; | ||
this.buffers.push(chunk); | ||
next(); | ||
} | ||
this.length = this.length + chunk.length; | ||
this.buffers.push(chunk); | ||
next(); | ||
}; | ||
collect() { | ||
internals.Recorder.prototype.collect = function () { | ||
const buffer = (this.buffers.length === 0 ? Buffer.alloc(0) : (this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length))); | ||
return buffer; | ||
const buffer = (this.buffers.length === 0 ? Buffer.alloc(0) : (this.buffers.length === 1 ? this.buffers[0] : Buffer.concat(this.buffers, this.length))); | ||
return buffer; | ||
} | ||
}; |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const Hoek = require('hoek'); | ||
const Stream = require('stream'); | ||
@@ -16,21 +15,20 @@ const Payload = require('./payload'); | ||
module.exports = internals.Tap = function () { | ||
module.exports = internals.Tap = class extends Stream.Transform { | ||
Stream.Transform.call(this); | ||
this.buffers = []; | ||
}; | ||
constructor() { | ||
Hoek.inherits(internals.Tap, Stream.Transform); | ||
super(); | ||
this.buffers = []; | ||
} | ||
_transform(chunk, encoding, next) { | ||
internals.Tap.prototype._transform = function (chunk, encoding, next) { | ||
this.buffers.push(chunk); | ||
next(null, chunk); | ||
} | ||
this.buffers.push(chunk); | ||
next(null, chunk); | ||
}; | ||
collect() { | ||
internals.Tap.prototype.collect = function () { | ||
return new Payload(this.buffers); | ||
return new Payload(this.buffers); | ||
} | ||
}; |
{ | ||
"name": "wreck", | ||
"description": "HTTP Client Utilities", | ||
"version": "14.1.0", | ||
"version": "14.1.1", | ||
"repository": "git://github.com/hapijs/wreck", | ||
@@ -13,3 +13,3 @@ "main": "lib/index", | ||
"engines": { | ||
"node": ">=8.9.0" | ||
"node": ">=8.12.0" | ||
}, | ||
@@ -23,3 +23,3 @@ "dependencies": { | ||
"eslint-plugin-markdown": "1.0.0-beta.6", | ||
"lab": "15.x.x" | ||
"lab": "17.x.x" | ||
}, | ||
@@ -26,0 +26,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
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
41168