@@ -3278,6 +3278,7 @@ function EventEmitter() {
3278
3278
EventEmitter . init . call ( this ) ;
3279
3279
}
3280
3280
module . exports = EventEmitter ;
3281
+ module . exports . once = once ;
3281
3282
3282
3283
// Backwards-compat with node 0.10.x
3283
3284
EventEmitter . EventEmitter = EventEmitter ;
@@ -3669,6 +3670,35 @@ function unwrapListeners(arr) {
3669
3670
return ret ;
3670
3671
}
3671
3672
3673
+ function once ( emitter , name ) {
3674
+ return new Promise ( function ( resolve , reject ) {
3675
+ function eventListener ( ) {
3676
+ if ( errorListener !== undefined ) {
3677
+ emitter . removeListener ( 'error' , errorListener ) ;
3678
+ }
3679
+ resolve ( [ ] . slice . call ( arguments ) ) ;
3680
+ } ;
3681
+ var errorListener ;
3682
+
3683
+ // Adding an error listener is not optional because
3684
+ // if an error is thrown on an event emitter we cannot
3685
+ // guarantee that the actual event we are waiting will
3686
+ // be fired. The result could be a silent way to create
3687
+ // memory or file descriptor leaks, which is something
3688
+ // we should avoid.
3689
+ if ( name !== 'error' ) {
3690
+ errorListener = function errorListener ( err ) {
3691
+ emitter . removeListener ( name , eventListener ) ;
3692
+ reject ( err ) ;
3693
+ } ;
3694
+
3695
+ emitter . once ( 'error' , errorListener ) ;
3696
+ }
3697
+
3698
+ emitter . once ( name , eventListener ) ;
3699
+ } ) ;
3700
+ }
3701
+
3672
3702
3673
3703
/***/ } ) ,
3674
3704
/* 10 */
@@ -6668,6 +6698,7 @@ function EventSource (url, eventSourceInitDict) {
6668
6698
var buf
6669
6699
var startingPos = 0
6670
6700
var startingFieldLength = - 1
6701
+
6671
6702
res . on ( 'data' , function ( chunk ) {
6672
6703
buf = buf ? Buffer . concat ( [ buf , chunk ] ) : chunk
6673
6704
if ( isFirst && hasBom ( buf ) ) {
@@ -6726,6 +6757,10 @@ function EventSource (url, eventSourceInitDict) {
6726
6757
} )
6727
6758
} )
6728
6759
6760
+ if ( config . readTimeoutMillis ) {
6761
+ req . setTimeout ( config . readTimeoutMillis )
6762
+ }
6763
+
6729
6764
if ( config . body ) {
6730
6765
req . write ( config . body )
6731
6766
}
@@ -6734,6 +6769,11 @@ function EventSource (url, eventSourceInitDict) {
6734
6769
failed ( { message : err . message } )
6735
6770
} )
6736
6771
6772
+ req . on ( 'timeout' , function ( ) {
6773
+ failed ( { message : 'Read timeout, received no data in ' + config . readTimeoutMillis +
6774
+ 'ms, assuming connection is dead' } )
6775
+ } )
6776
+
6737
6777
if ( req . setNoDelay ) req . setNoDelay ( true )
6738
6778
req . end ( )
6739
6779
}
@@ -7100,9 +7140,7 @@ function fromByteArray (uint8) {
7100
7140
7101
7141
// go through the array every three bytes, we'll deal with trailing stuff later
7102
7142
for ( var i = 0 , len2 = len - extraBytes ; i < len2 ; i += maxChunkLength ) {
7103
- parts . push ( encodeChunk (
7104
- uint8 , i , ( i + maxChunkLength ) > len2 ? len2 : ( i + maxChunkLength )
7105
- ) )
7143
+ parts . push ( encodeChunk ( uint8 , i , ( i + maxChunkLength ) > len2 ? len2 : ( i + maxChunkLength ) ) )
7106
7144
}
7107
7145
7108
7146
// pad the end with zeros, but make sure to not forget the extra bytes
@@ -7131,6 +7169,7 @@ function fromByteArray (uint8) {
7131
7169
/* 24 */
7132
7170
/***/ ( function ( module , exports ) {
7133
7171
7172
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
7134
7173
exports . read = function ( buffer , offset , isLE , mLen , nBytes ) {
7135
7174
var e , m
7136
7175
var eLen = ( nBytes * 8 ) - mLen - 1
@@ -7882,7 +7921,7 @@ function encode(input) {
7882
7921
* @api public
7883
7922
*/
7884
7923
function querystring ( query ) {
7885
- var parser = / ( [ ^ = ? & ] + ) = ? ( [ ^ & ] * ) / g
7924
+ var parser = / ( [ ^ = ? # & ] + ) = ? ( [ ^ & ] * ) / g
7886
7925
, result = { }
7887
7926
, part ;
7888
7927
@@ -7937,8 +7976,8 @@ function querystringify(obj, prefix) {
7937
7976
value = '' ;
7938
7977
}
7939
7978
7940
- key = encodeURIComponent ( key ) ;
7941
- value = encodeURIComponent ( value ) ;
7979
+ key = encode ( key ) ;
7980
+ value = encode ( value ) ;
7942
7981
7943
7982
//
7944
7983
// If we failed to encode the strings, we should bail out as we don't
0 commit comments