Skip to content

Commit 1fa0109

Browse files
committed
v5.0.1 - update validator to 13.6.0
1 parent c703faf commit 1fa0109

File tree

4 files changed

+758
-520
lines changed

4 files changed

+758
-520
lines changed

Diff for: dist/ZSchema-browser-test.js

+57-16
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ function fromByteArray (uint8) {
126126

127127
// go through the array every three bytes, we'll deal with trailing stuff later
128128
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
129-
parts.push(encodeChunk(
130-
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
131-
))
129+
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
132130
}
133131

134132
// pad the end with zeros, but make sure to not forget the extra bytes
@@ -3097,6 +3095,7 @@ function validateParams (params) {
30973095
}
30983096

30993097
},{"http":17,"url":37}],8:[function(require,module,exports){
3098+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
31003099
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
31013100
var e, m
31023101
var eLen = (nBytes * 8) - mLen - 1
@@ -6639,6 +6638,8 @@ var ClientRequest = module.exports = function (opts) {
66396638
}
66406639
self._mode = decideMode(preferBinary, useFetch)
66416640
self._fetchTimer = null
6641+
self._socketTimeout = null
6642+
self._socketTimer = null
66426643

66436644
self.on('finish', function () {
66446645
self._onFinish()
@@ -6681,6 +6682,10 @@ ClientRequest.prototype._onFinish = function () {
66816682
return
66826683
var opts = self._opts
66836684

6685+
if ('timeout' in opts && opts.timeout !== 0) {
6686+
self.setTimeout(opts.timeout)
6687+
}
6688+
66846689
var headersObj = self._headers
66856690
var body = null
66866691
if (opts.method !== 'GET' && opts.method !== 'HEAD') {
@@ -6728,9 +6733,10 @@ ClientRequest.prototype._onFinish = function () {
67286733
signal: signal
67296734
}).then(function (response) {
67306735
self._fetchResponse = response
6736+
self._resetTimers(false)
67316737
self._connect()
67326738
}, function (reason) {
6733-
global.clearTimeout(self._fetchTimer)
6739+
self._resetTimers(true)
67346740
if (!self._destroyed)
67356741
self.emit('error', reason)
67366742
})
@@ -6786,6 +6792,7 @@ ClientRequest.prototype._onFinish = function () {
67866792
xhr.onerror = function () {
67876793
if (self._destroyed)
67886794
return
6795+
self._resetTimers(true)
67896796
self.emit('error', new Error('XHR error'))
67906797
}
67916798

@@ -6817,13 +6824,15 @@ function statusValid (xhr) {
68176824
ClientRequest.prototype._onXHRProgress = function () {
68186825
var self = this
68196826

6827+
self._resetTimers(false)
6828+
68206829
if (!statusValid(self._xhr) || self._destroyed)
68216830
return
68226831

68236832
if (!self._response)
68246833
self._connect()
68256834

6826-
self._response._onXHRProgress()
6835+
self._response._onXHRProgress(self._resetTimers.bind(self))
68276836
}
68286837

68296838
ClientRequest.prototype._connect = function () {
@@ -6832,7 +6841,7 @@ ClientRequest.prototype._connect = function () {
68326841
if (self._destroyed)
68336842
return
68346843

6835-
self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
6844+
self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._resetTimers.bind(self))
68366845
self._response.on('error', function(err) {
68376846
self.emit('error', err)
68386847
})
@@ -6847,16 +6856,35 @@ ClientRequest.prototype._write = function (chunk, encoding, cb) {
68476856
cb()
68486857
}
68496858

6850-
ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
6859+
ClientRequest.prototype._resetTimers = function (done) {
6860+
var self = this
6861+
6862+
global.clearTimeout(self._socketTimer)
6863+
self._socketTimer = null
6864+
6865+
if (done) {
6866+
global.clearTimeout(self._fetchTimer)
6867+
self._fetchTimer = null
6868+
} else if (self._socketTimeout) {
6869+
self._socketTimer = global.setTimeout(function () {
6870+
self.emit('timeout')
6871+
}, self._socketTimeout)
6872+
}
6873+
}
6874+
6875+
ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function (err) {
68516876
var self = this
68526877
self._destroyed = true
6853-
global.clearTimeout(self._fetchTimer)
6878+
self._resetTimers(true)
68546879
if (self._response)
68556880
self._response._destroyed = true
68566881
if (self._xhr)
68576882
self._xhr.abort()
68586883
else if (self._fetchAbortController)
68596884
self._fetchAbortController.abort()
6885+
6886+
if (err)
6887+
self.emit('error', err)
68606888
}
68616889

68626890
ClientRequest.prototype.end = function (data, encoding, cb) {
@@ -6869,8 +6897,17 @@ ClientRequest.prototype.end = function (data, encoding, cb) {
68696897
stream.Writable.prototype.end.call(self, data, encoding, cb)
68706898
}
68716899

6900+
ClientRequest.prototype.setTimeout = function (timeout, cb) {
6901+
var self = this
6902+
6903+
if (cb)
6904+
self.once('timeout', cb)
6905+
6906+
self._socketTimeout = timeout
6907+
self._resetTimers(false)
6908+
}
6909+
68726910
ClientRequest.prototype.flushHeaders = function () {}
6873-
ClientRequest.prototype.setTimeout = function () {}
68746911
ClientRequest.prototype.setNoDelay = function () {}
68756912
ClientRequest.prototype.setSocketKeepAlive = function () {}
68766913

@@ -6913,7 +6950,7 @@ var rStates = exports.readyStates = {
69136950
DONE: 4
69146951
}
69156952

6916-
var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
6953+
var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, resetTimers) {
69176954
var self = this
69186955
stream.Readable.call(self)
69196956

@@ -6946,6 +6983,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
69466983
if (capability.writableStream) {
69476984
var writable = new WritableStream({
69486985
write: function (chunk) {
6986+
resetTimers(false)
69496987
return new Promise(function (resolve, reject) {
69506988
if (self._destroyed) {
69516989
reject()
@@ -6957,19 +6995,20 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
69576995
})
69586996
},
69596997
close: function () {
6960-
global.clearTimeout(fetchTimer)
6998+
resetTimers(true)
69616999
if (!self._destroyed)
69627000
self.push(null)
69637001
},
69647002
abort: function (err) {
7003+
resetTimers(true)
69657004
if (!self._destroyed)
69667005
self.emit('error', err)
69677006
}
69687007
})
69697008

69707009
try {
69717010
response.body.pipeTo(writable).catch(function (err) {
6972-
global.clearTimeout(fetchTimer)
7011+
resetTimers(true)
69737012
if (!self._destroyed)
69747013
self.emit('error', err)
69757014
})
@@ -6982,15 +7021,15 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, f
69827021
reader.read().then(function (result) {
69837022
if (self._destroyed)
69847023
return
7024+
resetTimers(result.done)
69857025
if (result.done) {
6986-
global.clearTimeout(fetchTimer)
69877026
self.push(null)
69887027
return
69897028
}
69907029
self.push(Buffer.from(result.value))
69917030
read()
69927031
}).catch(function (err) {
6993-
global.clearTimeout(fetchTimer)
7032+
resetTimers(true)
69947033
if (!self._destroyed)
69957034
self.emit('error', err)
69967035
})
@@ -7049,7 +7088,7 @@ IncomingMessage.prototype._read = function () {
70497088
}
70507089
}
70517090

7052-
IncomingMessage.prototype._onXHRProgress = function () {
7091+
IncomingMessage.prototype._onXHRProgress = function (resetTimers) {
70537092
var self = this
70547093

70557094
var xhr = self._xhr
@@ -7096,6 +7135,7 @@ IncomingMessage.prototype._onXHRProgress = function () {
70967135
}
70977136
}
70987137
reader.onload = function () {
7138+
resetTimers(true)
70997139
self.push(null)
71007140
}
71017141
// reader.onerror = ??? // TODO: this
@@ -7105,6 +7145,7 @@ IncomingMessage.prototype._onXHRProgress = function () {
71057145

71067146
// The ms-stream case handles end separately in reader.onload()
71077147
if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
7148+
resetTimers(true)
71087149
self.push(null)
71097150
}
71107151
}
@@ -21936,7 +21977,7 @@ module.exports = {
2193621977
data: null,
2193721978
valid: false,
2193821979
after: function (err) {
21939-
expect(err.message).toBe("Invalid .validate call - schema must be an string or object but null was passed!");
21980+
expect(err.message).toBe("Invalid .validate call - schema must be a string or object but null was passed!");
2194021981
}
2194121982
}
2194221983
]

0 commit comments

Comments
 (0)