fsevents 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (194) hide show
  1. package/node_modules/ansi-styles/index.js +72 -6
  2. package/node_modules/ansi-styles/package.json +19 -12
  3. package/node_modules/ansi-styles/readme.md +36 -8
  4. package/node_modules/are-we-there-yet/CHANGES.md +19 -0
  5. package/node_modules/are-we-there-yet/README.md +12 -2
  6. package/node_modules/are-we-there-yet/index.js +4 -132
  7. package/node_modules/are-we-there-yet/package.json +18 -13
  8. package/node_modules/are-we-there-yet/test/lib/test-event.js +29 -0
  9. package/node_modules/are-we-there-yet/test/tracker.js +44 -43
  10. package/node_modules/are-we-there-yet/test/trackergroup.js +73 -64
  11. package/node_modules/are-we-there-yet/test/trackerstream.js +26 -40
  12. package/node_modules/are-we-there-yet/tracker-base.js +11 -0
  13. package/node_modules/are-we-there-yet/tracker-group.js +107 -0
  14. package/node_modules/are-we-there-yet/tracker-stream.js +35 -0
  15. package/node_modules/are-we-there-yet/tracker.js +30 -0
  16. package/node_modules/asn1/package.json +1 -2
  17. package/node_modules/assert-plus/package.json +1 -3
  18. package/node_modules/async/package.json +1 -1
  19. package/node_modules/aws4/.npmignore +2 -1
  20. package/node_modules/aws4/README.md +4 -0
  21. package/node_modules/aws4/aws4.js +8 -3
  22. package/node_modules/aws4/node_modules/lru-cache/.npmignore +3 -0
  23. package/node_modules/aws4/node_modules/lru-cache/.travis.yml +3 -4
  24. package/node_modules/aws4/node_modules/lru-cache/README.md +29 -24
  25. package/node_modules/aws4/node_modules/lru-cache/benchmarks/insertion-time.js +32 -0
  26. package/node_modules/aws4/node_modules/lru-cache/lib/lru-cache.js +333 -199
  27. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/LICENSE +15 -0
  28. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/README.md +60 -0
  29. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/map.js +9 -0
  30. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/package.json +59 -0
  31. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/pseudomap.js +113 -0
  32. package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/test/basic.js +86 -0
  33. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.npmignore +4 -0
  34. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.travis.yml +7 -0
  35. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/CONTRIBUTING.md +4 -0
  36. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
  37. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
  38. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/package.json +59 -0
  39. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/test/basic.js +188 -0
  40. package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/yallist.js +360 -0
  41. package/node_modules/aws4/node_modules/lru-cache/package.json +16 -12
  42. package/node_modules/aws4/node_modules/lru-cache/test/basic.js +270 -146
  43. package/node_modules/aws4/node_modules/lru-cache/test/foreach.js +39 -25
  44. package/node_modules/aws4/node_modules/lru-cache/test/inspect.js +54 -0
  45. package/node_modules/aws4/node_modules/lru-cache/test/no-symbol.js +3 -0
  46. package/node_modules/aws4/node_modules/lru-cache/test/serialize.js +115 -104
  47. package/node_modules/aws4/package.json +17 -14
  48. package/node_modules/bl/bl.js +9 -3
  49. package/node_modules/bl/package.json +12 -12
  50. package/node_modules/bl/test/test.js +14 -0
  51. package/node_modules/color-convert/README.md +62 -0
  52. package/node_modules/color-convert/conversions.js +594 -0
  53. package/node_modules/color-convert/css-keywords.js +151 -0
  54. package/node_modules/color-convert/index.js +75 -0
  55. package/node_modules/color-convert/package.json +92 -0
  56. package/node_modules/color-convert/route.js +98 -0
  57. package/node_modules/dashdash/lib/dashdash.js +1 -1
  58. package/node_modules/dashdash/node_modules/assert-plus/AUTHORS +6 -0
  59. package/node_modules/dashdash/node_modules/assert-plus/CHANGES.md +14 -0
  60. package/node_modules/dashdash/node_modules/assert-plus/README.md +162 -0
  61. package/node_modules/dashdash/node_modules/assert-plus/assert.js +211 -0
  62. package/node_modules/dashdash/node_modules/assert-plus/package.json +89 -0
  63. package/node_modules/dashdash/package.json +19 -12
  64. package/node_modules/ecc-jsbn/package.json +1 -2
  65. package/node_modules/escape-string-regexp/package.json +15 -11
  66. package/node_modules/extsprintf/package.json +2 -3
  67. package/node_modules/form-data/.dockerignore +7 -0
  68. package/node_modules/form-data/.editorconfig +10 -0
  69. package/node_modules/form-data/.eslintignore +1 -0
  70. package/node_modules/form-data/.eslintrc +64 -0
  71. package/node_modules/form-data/{Readme.md → README.md} +9 -1
  72. package/node_modules/form-data/lib/browser.js +2 -1
  73. package/node_modules/form-data/lib/form_data.js +172 -135
  74. package/node_modules/form-data/lib/populate.js +9 -0
  75. package/node_modules/form-data/package.json +35 -16
  76. package/node_modules/form-data/wercker.yml +36 -0
  77. package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
  78. package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
  79. package/node_modules/gauge/README.md +1 -1
  80. package/node_modules/gauge/package.json +18 -14
  81. package/node_modules/gauge/progress-bar.js +2 -2
  82. package/node_modules/http-signature/package.json +1 -2
  83. package/node_modules/is-my-json-valid/README.md +2 -2
  84. package/node_modules/is-my-json-valid/index.js +15 -6
  85. package/node_modules/is-my-json-valid/package.json +11 -7
  86. package/node_modules/is-my-json-valid/test/json-schema-draft4/multipleOf.json +36 -0
  87. package/node_modules/is-my-json-valid/test/misc.js +18 -0
  88. package/node_modules/is-typedarray/package.json +1 -2
  89. package/node_modules/isarray/.npmignore +1 -0
  90. package/node_modules/isarray/.travis.yml +4 -0
  91. package/node_modules/isarray/Makefile +6 -0
  92. package/node_modules/isarray/README.md +6 -0
  93. package/node_modules/isarray/index.js +3 -1
  94. package/node_modules/isarray/package.json +28 -10
  95. package/node_modules/isarray/test.js +20 -0
  96. package/node_modules/jodid25519/package.json +1 -2
  97. package/node_modules/jsbn/package.json +1 -2
  98. package/node_modules/json-schema/package.json +1 -1
  99. package/node_modules/jsprim/package.json +1 -2
  100. package/node_modules/lodash.pad/LICENSE +17 -16
  101. package/node_modules/lodash.pad/README.md +2 -2
  102. package/node_modules/lodash.pad/index.js +3 -94
  103. package/node_modules/lodash.pad/package.json +12 -12
  104. package/node_modules/lodash.padend/LICENSE +23 -0
  105. package/node_modules/lodash.padend/README.md +18 -0
  106. package/node_modules/lodash.padend/index.js +285 -0
  107. package/node_modules/lodash.padend/package.json +91 -0
  108. package/node_modules/lodash.padstart/LICENSE +23 -0
  109. package/node_modules/lodash.padstart/README.md +18 -0
  110. package/node_modules/lodash.padstart/index.js +285 -0
  111. package/node_modules/lodash.padstart/package.json +91 -0
  112. package/node_modules/lodash.repeat/LICENSE +17 -16
  113. package/node_modules/lodash.repeat/README.md +2 -2
  114. package/node_modules/lodash.repeat/index.js +3 -94
  115. package/node_modules/lodash.repeat/package.json +14 -13
  116. package/node_modules/lodash.tostring/LICENSE +23 -0
  117. package/node_modules/lodash.tostring/README.md +18 -0
  118. package/node_modules/lodash.tostring/index.js +164 -0
  119. package/node_modules/lodash.tostring/package.json +91 -0
  120. package/node_modules/mime-db/HISTORY.md +14 -0
  121. package/node_modules/mime-db/db.json +26 -3
  122. package/node_modules/mime-db/package.json +23 -18
  123. package/node_modules/mime-types/HISTORY.md +8 -0
  124. package/node_modules/mime-types/README.md +1 -1
  125. package/node_modules/mime-types/package.json +21 -16
  126. package/node_modules/node-pre-gyp/CHANGELOG.md +11 -0
  127. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +44 -4
  128. package/node_modules/node-pre-gyp/package.json +16 -16
  129. package/node_modules/npmlog/.nyc_output/64996.json +1 -0
  130. package/node_modules/npmlog/.nyc_output/64998.json +1 -0
  131. package/node_modules/npmlog/.nyc_output/65000.json +1 -0
  132. package/node_modules/npmlog/log.js +3 -2
  133. package/node_modules/npmlog/package.json +15 -11
  134. package/node_modules/npmlog/test/progress.js +25 -8
  135. package/node_modules/once/package.json +1 -1
  136. package/node_modules/qs/package.json +1 -2
  137. package/node_modules/readable-stream/.travis.yml +18 -16
  138. package/node_modules/readable-stream/README.md +1 -1
  139. package/node_modules/readable-stream/doc/stream.markdown +435 -405
  140. package/node_modules/readable-stream/lib/_stream_duplex.js +13 -20
  141. package/node_modules/readable-stream/lib/_stream_passthrough.js +3 -4
  142. package/node_modules/readable-stream/lib/_stream_readable.js +110 -205
  143. package/node_modules/readable-stream/lib/_stream_transform.js +21 -38
  144. package/node_modules/readable-stream/lib/_stream_writable.js +108 -121
  145. package/node_modules/readable-stream/package.json +19 -15
  146. package/node_modules/request/package.json +1 -2
  147. package/node_modules/rimraf/node_modules/glob/README.md +6 -0
  148. package/node_modules/rimraf/node_modules/glob/common.js +12 -3
  149. package/node_modules/rimraf/node_modules/glob/glob.js +20 -3
  150. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
  151. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
  152. package/node_modules/rimraf/node_modules/glob/package.json +15 -11
  153. package/node_modules/rimraf/node_modules/glob/sync.js +8 -1
  154. package/node_modules/rimraf/package.json +14 -10
  155. package/node_modules/semver/package.json +1 -2
  156. package/node_modules/sshpk/lib/formats/rfc4253.js +2 -1
  157. package/node_modules/sshpk/package.json +13 -10
  158. package/node_modules/strip-ansi/package.json +21 -16
  159. package/node_modules/strip-ansi/readme.md +5 -5
  160. package/node_modules/tough-cookie/lib/cookie.js +2 -2
  161. package/node_modules/tough-cookie/package.json +13 -9
  162. package/node_modules/tweetnacl/CHANGELOG.md +53 -0
  163. package/node_modules/tweetnacl/COPYING.txt +9 -0
  164. package/node_modules/tweetnacl/README.md +14 -40
  165. package/node_modules/tweetnacl/nacl-fast.js +21 -51
  166. package/node_modules/tweetnacl/nacl-fast.min.js +2 -2
  167. package/node_modules/tweetnacl/nacl.js +21 -51
  168. package/node_modules/tweetnacl/nacl.min.js +1 -1
  169. package/node_modules/tweetnacl/package.json +28 -38
  170. package/node_modules/verror/package.json +2 -3
  171. package/package.json +2 -2
  172. package/node_modules/aws4/example.js +0 -372
  173. package/node_modules/aws4/node_modules/lru-cache/test/memory-leak.js +0 -51
  174. package/node_modules/isarray/build/build.js +0 -209
  175. package/node_modules/lodash._basetostring/LICENSE +0 -22
  176. package/node_modules/lodash._basetostring/README.md +0 -20
  177. package/node_modules/lodash._basetostring/index.js +0 -22
  178. package/node_modules/lodash._basetostring/package.json +0 -99
  179. package/node_modules/lodash._createpadding/LICENSE +0 -22
  180. package/node_modules/lodash._createpadding/README.md +0 -20
  181. package/node_modules/lodash._createpadding/index.js +0 -37
  182. package/node_modules/lodash._createpadding/package.json +0 -101
  183. package/node_modules/lodash._root/LICENSE +0 -22
  184. package/node_modules/lodash._root/README.md +0 -18
  185. package/node_modules/lodash._root/index.js +0 -53
  186. package/node_modules/lodash._root/package.json +0 -77
  187. package/node_modules/lodash.padleft/LICENSE.txt +0 -22
  188. package/node_modules/lodash.padleft/README.md +0 -20
  189. package/node_modules/lodash.padleft/index.js +0 -50
  190. package/node_modules/lodash.padleft/package.json +0 -107
  191. package/node_modules/lodash.padright/LICENSE.txt +0 -22
  192. package/node_modules/lodash.padright/README.md +0 -20
  193. package/node_modules/lodash.padright/index.js +0 -50
  194. package/node_modules/lodash.padright/package.json +0 -107
@@ -6,12 +6,10 @@ module.exports = Readable;
6
6
  var processNextTick = require('process-nextick-args');
7
7
  /*</replacement>*/
8
8
 
9
-
10
9
  /*<replacement>*/
11
10
  var isArray = require('isarray');
12
11
  /*</replacement>*/
13
12
 
14
-
15
13
  /*<replacement>*/
16
14
  var Buffer = require('buffer').Buffer;
17
15
  /*</replacement>*/
@@ -21,21 +19,20 @@ Readable.ReadableState = ReadableState;
21
19
  var EE = require('events');
22
20
 
23
21
  /*<replacement>*/
24
- var EElistenerCount = function(emitter, type) {
22
+ var EElistenerCount = function (emitter, type) {
25
23
  return emitter.listeners(type).length;
26
24
  };
27
25
  /*</replacement>*/
28
26
 
29
-
30
-
31
27
  /*<replacement>*/
32
28
  var Stream;
33
- (function (){try{
34
- Stream = require('st' + 'ream');
35
- }catch(_){}finally{
36
- if (!Stream)
37
- Stream = require('events').EventEmitter;
38
- }}())
29
+ (function () {
30
+ try {
31
+ Stream = require('st' + 'ream');
32
+ } catch (_) {} finally {
33
+ if (!Stream) Stream = require('events').EventEmitter;
34
+ }
35
+ })();
39
36
  /*</replacement>*/
40
37
 
41
38
  var Buffer = require('buffer').Buffer;
@@ -45,11 +42,9 @@ var util = require('core-util-is');
45
42
  util.inherits = require('inherits');
46
43
  /*</replacement>*/
47
44
 
48
-
49
-
50
45
  /*<replacement>*/
51
46
  var debugUtil = require('util');
52
- var debug;
47
+ var debug = undefined;
53
48
  if (debugUtil && debugUtil.debuglog) {
54
49
  debug = debugUtil.debuglog('stream');
55
50
  } else {
@@ -71,17 +66,16 @@ function ReadableState(options, stream) {
71
66
  // make all the buffer merging and length checks go away
72
67
  this.objectMode = !!options.objectMode;
73
68
 
74
- if (stream instanceof Duplex)
75
- this.objectMode = this.objectMode || !!options.readableObjectMode;
69
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
76
70
 
77
71
  // the point at which it stops calling _read() to fill the buffer
78
72
  // Note: 0 is a valid value, means "don't call _read preemptively ever"
79
73
  var hwm = options.highWaterMark;
80
74
  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
81
- this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
75
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
82
76
 
83
77
  // cast to ints.
84
- this.highWaterMark = ~~this.highWaterMark;
78
+ this.highWaterMark = ~ ~this.highWaterMark;
85
79
 
86
80
  this.buffer = [];
87
81
  this.length = 0;
@@ -103,6 +97,7 @@ function ReadableState(options, stream) {
103
97
  this.needReadable = false;
104
98
  this.emittedReadable = false;
105
99
  this.readableListening = false;
100
+ this.resumeScheduled = false;
106
101
 
107
102
  // Crypto is kind of old and crusty. Historically, its default string
108
103
  // encoding is 'binary' so we have to make this configurable.
@@ -122,8 +117,7 @@ function ReadableState(options, stream) {
122
117
  this.decoder = null;
123
118
  this.encoding = null;
124
119
  if (options.encoding) {
125
- if (!StringDecoder)
126
- StringDecoder = require('string_decoder/').StringDecoder;
120
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
127
121
  this.decoder = new StringDecoder(options.encoding);
128
122
  this.encoding = options.encoding;
129
123
  }
@@ -133,16 +127,14 @@ var Duplex;
133
127
  function Readable(options) {
134
128
  Duplex = Duplex || require('./_stream_duplex');
135
129
 
136
- if (!(this instanceof Readable))
137
- return new Readable(options);
130
+ if (!(this instanceof Readable)) return new Readable(options);
138
131
 
139
132
  this._readableState = new ReadableState(options, this);
140
133
 
141
134
  // legacy
142
135
  this.readable = true;
143
136
 
144
- if (options && typeof options.read === 'function')
145
- this._read = options.read;
137
+ if (options && typeof options.read === 'function') this._read = options.read;
146
138
 
147
139
  Stream.call(this);
148
140
  }
@@ -151,7 +143,7 @@ function Readable(options) {
151
143
  // This returns true if the highWaterMark has not been hit yet,
152
144
  // similar to how Writable.write() returns true if you should
153
145
  // write() some more.
154
- Readable.prototype.push = function(chunk, encoding) {
146
+ Readable.prototype.push = function (chunk, encoding) {
155
147
  var state = this._readableState;
156
148
 
157
149
  if (!state.objectMode && typeof chunk === 'string') {
@@ -166,12 +158,12 @@ Readable.prototype.push = function(chunk, encoding) {
166
158
  };
167
159
 
168
160
  // Unshift should *always* be something directly out of read()
169
- Readable.prototype.unshift = function(chunk) {
161
+ Readable.prototype.unshift = function (chunk) {
170
162
  var state = this._readableState;
171
163
  return readableAddChunk(this, state, chunk, '', true);
172
164
  };
173
165
 
174
- Readable.prototype.isPaused = function() {
166
+ Readable.prototype.isPaused = function () {
175
167
  return this._readableState.flowing === false;
176
168
  };
177
169
 
@@ -190,26 +182,28 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
190
182
  var e = new Error('stream.unshift() after end event');
191
183
  stream.emit('error', e);
192
184
  } else {
193
- if (state.decoder && !addToFront && !encoding)
185
+ var skipAdd;
186
+ if (state.decoder && !addToFront && !encoding) {
194
187
  chunk = state.decoder.write(chunk);
188
+ skipAdd = !state.objectMode && chunk.length === 0;
189
+ }
195
190
 
196
- if (!addToFront)
197
- state.reading = false;
198
-
199
- // if we want the data now, just emit it.
200
- if (state.flowing && state.length === 0 && !state.sync) {
201
- stream.emit('data', chunk);
202
- stream.read(0);
203
- } else {
204
- // update the buffer info.
205
- state.length += state.objectMode ? 1 : chunk.length;
206
- if (addToFront)
207
- state.buffer.unshift(chunk);
208
- else
209
- state.buffer.push(chunk);
210
-
211
- if (state.needReadable)
212
- emitReadable(stream);
191
+ if (!addToFront) state.reading = false;
192
+
193
+ // Don't add to the buffer if we've decoded to an empty string chunk and
194
+ // we're not in object mode
195
+ if (!skipAdd) {
196
+ // if we want the data now, just emit it.
197
+ if (state.flowing && state.length === 0 && !state.sync) {
198
+ stream.emit('data', chunk);
199
+ stream.read(0);
200
+ } else {
201
+ // update the buffer info.
202
+ state.length += state.objectMode ? 1 : chunk.length;
203
+ if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
204
+
205
+ if (state.needReadable) emitReadable(stream);
206
+ }
213
207
  }
214
208
 
215
209
  maybeReadMore(stream, state);
@@ -221,7 +215,6 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
221
215
  return needMoreData(state);
222
216
  }
223
217
 
224
-
225
218
  // if it's past the high water mark, we can push in some more.
226
219
  // Also, if we have no data yet, we can stand some
227
220
  // more bytes. This is to work around cases where hwm=0,
@@ -230,16 +223,12 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
230
223
  // needReadable was set, then we ought to push more, so that another
231
224
  // 'readable' event will be triggered.
232
225
  function needMoreData(state) {
233
- return !state.ended &&
234
- (state.needReadable ||
235
- state.length < state.highWaterMark ||
236
- state.length === 0);
226
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
237
227
  }
238
228
 
239
229
  // backwards compatibility.
240
- Readable.prototype.setEncoding = function(enc) {
241
- if (!StringDecoder)
242
- StringDecoder = require('string_decoder/').StringDecoder;
230
+ Readable.prototype.setEncoding = function (enc) {
231
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
243
232
  this._readableState.decoder = new StringDecoder(enc);
244
233
  this._readableState.encoding = enc;
245
234
  return this;
@@ -264,29 +253,22 @@ function computeNewHighWaterMark(n) {
264
253
  }
265
254
 
266
255
  function howMuchToRead(n, state) {
267
- if (state.length === 0 && state.ended)
268
- return 0;
256
+ if (state.length === 0 && state.ended) return 0;
269
257
 
270
- if (state.objectMode)
271
- return n === 0 ? 0 : 1;
258
+ if (state.objectMode) return n === 0 ? 0 : 1;
272
259
 
273
260
  if (n === null || isNaN(n)) {
274
261
  // only flow one buffer at a time
275
- if (state.flowing && state.buffer.length)
276
- return state.buffer[0].length;
277
- else
278
- return state.length;
262
+ if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length;
279
263
  }
280
264
 
281
- if (n <= 0)
282
- return 0;
265
+ if (n <= 0) return 0;
283
266
 
284
267
  // If we're asking for more than the target buffer level,
285
268
  // then raise the water mark. Bump up to the next highest
286
269
  // power of 2, to prevent increasing it excessively in tiny
287
270
  // amounts.
288
- if (n > state.highWaterMark)
289
- state.highWaterMark = computeNewHighWaterMark(n);
271
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
290
272
 
291
273
  // don't have that much. return null, unless we've ended.
292
274
  if (n > state.length) {
@@ -302,25 +284,19 @@ function howMuchToRead(n, state) {
302
284
  }
303
285
 
304
286
  // you can override either this method, or the async _read(n) below.
305
- Readable.prototype.read = function(n) {
287
+ Readable.prototype.read = function (n) {
306
288
  debug('read', n);
307
289
  var state = this._readableState;
308
290
  var nOrig = n;
309
291
 
310
- if (typeof n !== 'number' || n > 0)
311
- state.emittedReadable = false;
292
+ if (typeof n !== 'number' || n > 0) state.emittedReadable = false;
312
293
 
313
294
  // if we're doing read(0) to trigger a readable event, but we
314
295
  // already have a bunch of data in the buffer, then just trigger
315
296
  // the 'readable' event and move on.
316
- if (n === 0 &&
317
- state.needReadable &&
318
- (state.length >= state.highWaterMark || state.ended)) {
297
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
319
298
  debug('read: emitReadable', state.length, state.ended);
320
- if (state.length === 0 && state.ended)
321
- endReadable(this);
322
- else
323
- emitReadable(this);
299
+ if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
324
300
  return null;
325
301
  }
326
302
 
@@ -328,8 +304,7 @@ Readable.prototype.read = function(n) {
328
304
 
329
305
  // if we've ended, and we're now clear, then finish it up.
330
306
  if (n === 0 && state.ended) {
331
- if (state.length === 0)
332
- endReadable(this);
307
+ if (state.length === 0) endReadable(this);
333
308
  return null;
334
309
  }
335
310
 
@@ -377,8 +352,7 @@ Readable.prototype.read = function(n) {
377
352
  state.reading = true;
378
353
  state.sync = true;
379
354
  // if the length is currently zero, then we *need* a readable event.
380
- if (state.length === 0)
381
- state.needReadable = true;
355
+ if (state.length === 0) state.needReadable = true;
382
356
  // call internal read method
383
357
  this._read(state.highWaterMark);
384
358
  state.sync = false;
@@ -386,14 +360,10 @@ Readable.prototype.read = function(n) {
386
360
 
387
361
  // If _read pushed data synchronously, then `reading` will be false,
388
362
  // and we need to re-evaluate how much data we can return to the user.
389
- if (doRead && !state.reading)
390
- n = howMuchToRead(nOrig, state);
363
+ if (doRead && !state.reading) n = howMuchToRead(nOrig, state);
391
364
 
392
365
  var ret;
393
- if (n > 0)
394
- ret = fromList(n, state);
395
- else
396
- ret = null;
366
+ if (n > 0) ret = fromList(n, state);else ret = null;
397
367
 
398
368
  if (ret === null) {
399
369
  state.needReadable = true;
@@ -404,32 +374,24 @@ Readable.prototype.read = function(n) {
404
374
 
405
375
  // If we have nothing in the buffer, then we want to know
406
376
  // as soon as we *do* get something into the buffer.
407
- if (state.length === 0 && !state.ended)
408
- state.needReadable = true;
377
+ if (state.length === 0 && !state.ended) state.needReadable = true;
409
378
 
410
379
  // If we tried to read() past the EOF, then emit end on the next tick.
411
- if (nOrig !== n && state.ended && state.length === 0)
412
- endReadable(this);
380
+ if (nOrig !== n && state.ended && state.length === 0) endReadable(this);
413
381
 
414
- if (ret !== null)
415
- this.emit('data', ret);
382
+ if (ret !== null) this.emit('data', ret);
416
383
 
417
384
  return ret;
418
385
  };
419
386
 
420
387
  function chunkInvalid(state, chunk) {
421
388
  var er = null;
422
- if (!(Buffer.isBuffer(chunk)) &&
423
- typeof chunk !== 'string' &&
424
- chunk !== null &&
425
- chunk !== undefined &&
426
- !state.objectMode) {
389
+ if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
427
390
  er = new TypeError('Invalid non-string/buffer chunk');
428
391
  }
429
392
  return er;
430
393
  }
431
394
 
432
-
433
395
  function onEofChunk(stream, state) {
434
396
  if (state.ended) return;
435
397
  if (state.decoder) {
@@ -454,10 +416,7 @@ function emitReadable(stream) {
454
416
  if (!state.emittedReadable) {
455
417
  debug('emitReadable', state.flowing);
456
418
  state.emittedReadable = true;
457
- if (state.sync)
458
- processNextTick(emitReadable_, stream);
459
- else
460
- emitReadable_(stream);
419
+ if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
461
420
  }
462
421
  }
463
422
 
@@ -467,7 +426,6 @@ function emitReadable_(stream) {
467
426
  flow(stream);
468
427
  }
469
428
 
470
-
471
429
  // at this point, the user has presumably seen the 'readable' event,
472
430
  // and called read() to consume some data. that may have triggered
473
431
  // in turn another _read(n) call, in which case reading = true if
@@ -483,15 +441,12 @@ function maybeReadMore(stream, state) {
483
441
 
484
442
  function maybeReadMore_(stream, state) {
485
443
  var len = state.length;
486
- while (!state.reading && !state.flowing && !state.ended &&
487
- state.length < state.highWaterMark) {
444
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
488
445
  debug('maybeReadMore read 0');
489
446
  stream.read(0);
490
447
  if (len === state.length)
491
448
  // didn't get any data, stop spinning.
492
- break;
493
- else
494
- len = state.length;
449
+ break;else len = state.length;
495
450
  }
496
451
  state.readingMore = false;
497
452
  }
@@ -500,11 +455,11 @@ function maybeReadMore_(stream, state) {
500
455
  // call cb(er, data) where data is <= n in length.
501
456
  // for virtual (non-string, non-buffer) streams, "length" is somewhat
502
457
  // arbitrary, and perhaps not very meaningful.
503
- Readable.prototype._read = function(n) {
458
+ Readable.prototype._read = function (n) {
504
459
  this.emit('error', new Error('not implemented'));
505
460
  };
506
461
 
507
- Readable.prototype.pipe = function(dest, pipeOpts) {
462
+ Readable.prototype.pipe = function (dest, pipeOpts) {
508
463
  var src = this;
509
464
  var state = this._readableState;
510
465
 
@@ -522,15 +477,10 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
522
477
  state.pipesCount += 1;
523
478
  debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
524
479
 
525
- var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
526
- dest !== process.stdout &&
527
- dest !== process.stderr;
480
+ var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
528
481
 
529
482
  var endFn = doEnd ? onend : cleanup;
530
- if (state.endEmitted)
531
- processNextTick(endFn);
532
- else
533
- src.once('end', endFn);
483
+ if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
534
484
 
535
485
  dest.on('unpipe', onunpipe);
536
486
  function onunpipe(readable) {
@@ -572,9 +522,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
572
522
  // flowing again.
573
523
  // So, if this is awaiting a drain, then we just call it now.
574
524
  // If we don't know, then assume that we are waiting for one.
575
- if (state.awaitDrain &&
576
- (!dest._writableState || dest._writableState.needDrain))
577
- ondrain();
525
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
578
526
  }
579
527
 
580
528
  src.on('data', ondata);
@@ -585,10 +533,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
585
533
  // If the user unpiped during `dest.write()`, it is possible
586
534
  // to get stuck in a permanently paused state if that write
587
535
  // also returned false.
588
- if (state.pipesCount === 1 &&
589
- state.pipes[0] === dest &&
590
- src.listenerCount('data') === 1 &&
591
- !cleanedUp) {
536
+ if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) {
592
537
  debug('false write response, pause', src._readableState.awaitDrain);
593
538
  src._readableState.awaitDrain++;
594
539
  }
@@ -602,18 +547,11 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
602
547
  debug('onerror', er);
603
548
  unpipe();
604
549
  dest.removeListener('error', onerror);
605
- if (EElistenerCount(dest, 'error') === 0)
606
- dest.emit('error', er);
550
+ if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
607
551
  }
608
552
  // This is a brutally ugly hack to make sure that our error handler
609
553
  // is attached before any userland ones. NEVER DO THIS.
610
- if (!dest._events || !dest._events.error)
611
- dest.on('error', onerror);
612
- else if (isArray(dest._events.error))
613
- dest._events.error.unshift(onerror);
614
- else
615
- dest._events.error = [onerror, dest._events.error];
616
-
554
+ if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error];
617
555
 
618
556
  // Both close and finish should trigger unpipe, but only once.
619
557
  function onclose() {
@@ -646,11 +584,10 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
646
584
  };
647
585
 
648
586
  function pipeOnDrain(src) {
649
- return function() {
587
+ return function () {
650
588
  var state = src._readableState;
651
589
  debug('pipeOnDrain', state.awaitDrain);
652
- if (state.awaitDrain)
653
- state.awaitDrain--;
590
+ if (state.awaitDrain) state.awaitDrain--;
654
591
  if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
655
592
  state.flowing = true;
656
593
  flow(src);
@@ -658,29 +595,24 @@ function pipeOnDrain(src) {
658
595
  };
659
596
  }
660
597
 
661
-
662
- Readable.prototype.unpipe = function(dest) {
598
+ Readable.prototype.unpipe = function (dest) {
663
599
  var state = this._readableState;
664
600
 
665
601
  // if we're not piping anywhere, then do nothing.
666
- if (state.pipesCount === 0)
667
- return this;
602
+ if (state.pipesCount === 0) return this;
668
603
 
669
604
  // just one destination. most common case.
670
605
  if (state.pipesCount === 1) {
671
606
  // passed in one, but it's not the right one.
672
- if (dest && dest !== state.pipes)
673
- return this;
607
+ if (dest && dest !== state.pipes) return this;
674
608
 
675
- if (!dest)
676
- dest = state.pipes;
609
+ if (!dest) dest = state.pipes;
677
610
 
678
611
  // got a match.
679
612
  state.pipes = null;
680
613
  state.pipesCount = 0;
681
614
  state.flowing = false;
682
- if (dest)
683
- dest.emit('unpipe', this);
615
+ if (dest) dest.emit('unpipe', this);
684
616
  return this;
685
617
  }
686
618
 
@@ -694,20 +626,18 @@ Readable.prototype.unpipe = function(dest) {
694
626
  state.pipesCount = 0;
695
627
  state.flowing = false;
696
628
 
697
- for (var i = 0; i < len; i++)
698
- dests[i].emit('unpipe', this);
699
- return this;
629
+ for (var _i = 0; _i < len; _i++) {
630
+ dests[_i].emit('unpipe', this);
631
+ }return this;
700
632
  }
701
633
 
702
634
  // try to find the right one.
703
635
  var i = indexOf(state.pipes, dest);
704
- if (i === -1)
705
- return this;
636
+ if (i === -1) return this;
706
637
 
707
638
  state.pipes.splice(i, 1);
708
639
  state.pipesCount -= 1;
709
- if (state.pipesCount === 1)
710
- state.pipes = state.pipes[0];
640
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
711
641
 
712
642
  dest.emit('unpipe', this);
713
643
 
@@ -716,7 +646,7 @@ Readable.prototype.unpipe = function(dest) {
716
646
 
717
647
  // set up data events if they are asked for
718
648
  // Ensure readable listeners eventually get something
719
- Readable.prototype.on = function(ev, fn) {
649
+ Readable.prototype.on = function (ev, fn) {
720
650
  var res = Stream.prototype.on.call(this, ev, fn);
721
651
 
722
652
  // If listening to data, and it has not explicitly been paused,
@@ -725,7 +655,7 @@ Readable.prototype.on = function(ev, fn) {
725
655
  this.resume();
726
656
  }
727
657
 
728
- if (ev === 'readable' && this.readable) {
658
+ if (ev === 'readable' && !this._readableState.endEmitted) {
729
659
  var state = this._readableState;
730
660
  if (!state.readableListening) {
731
661
  state.readableListening = true;
@@ -750,7 +680,7 @@ function nReadingNextTick(self) {
750
680
 
751
681
  // pause() and resume() are remnants of the legacy readable stream API
752
682
  // If the user uses them, then switch into old mode.
753
- Readable.prototype.resume = function() {
683
+ Readable.prototype.resume = function () {
754
684
  var state = this._readableState;
755
685
  if (!state.flowing) {
756
686
  debug('resume');
@@ -776,11 +706,10 @@ function resume_(stream, state) {
776
706
  state.resumeScheduled = false;
777
707
  stream.emit('resume');
778
708
  flow(stream);
779
- if (state.flowing && !state.reading)
780
- stream.read(0);
709
+ if (state.flowing && !state.reading) stream.read(0);
781
710
  }
782
711
 
783
- Readable.prototype.pause = function() {
712
+ Readable.prototype.pause = function () {
784
713
  debug('call pause flowing=%j', this._readableState.flowing);
785
714
  if (false !== this._readableState.flowing) {
786
715
  debug('pause');
@@ -803,32 +732,27 @@ function flow(stream) {
803
732
  // wrap an old-style stream as the async data source.
804
733
  // This is *not* part of the readable stream interface.
805
734
  // It is an ugly unfortunate mess of history.
806
- Readable.prototype.wrap = function(stream) {
735
+ Readable.prototype.wrap = function (stream) {
807
736
  var state = this._readableState;
808
737
  var paused = false;
809
738
 
810
739
  var self = this;
811
- stream.on('end', function() {
740
+ stream.on('end', function () {
812
741
  debug('wrapped end');
813
742
  if (state.decoder && !state.ended) {
814
743
  var chunk = state.decoder.end();
815
- if (chunk && chunk.length)
816
- self.push(chunk);
744
+ if (chunk && chunk.length) self.push(chunk);
817
745
  }
818
746
 
819
747
  self.push(null);
820
748
  });
821
749
 
822
- stream.on('data', function(chunk) {
750
+ stream.on('data', function (chunk) {
823
751
  debug('wrapped data');
824
- if (state.decoder)
825
- chunk = state.decoder.write(chunk);
752
+ if (state.decoder) chunk = state.decoder.write(chunk);
826
753
 
827
754
  // don't skip over falsy values in objectMode
828
- if (state.objectMode && (chunk === null || chunk === undefined))
829
- return;
830
- else if (!state.objectMode && (!chunk || !chunk.length))
831
- return;
755
+ if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
832
756
 
833
757
  var ret = self.push(chunk);
834
758
  if (!ret) {
@@ -841,21 +765,23 @@ Readable.prototype.wrap = function(stream) {
841
765
  // important when wrapping filters and duplexes.
842
766
  for (var i in stream) {
843
767
  if (this[i] === undefined && typeof stream[i] === 'function') {
844
- this[i] = function(method) { return function() {
845
- return stream[method].apply(stream, arguments);
846
- }; }(i);
768
+ this[i] = function (method) {
769
+ return function () {
770
+ return stream[method].apply(stream, arguments);
771
+ };
772
+ }(i);
847
773
  }
848
774
  }
849
775
 
850
776
  // proxy certain important events.
851
777
  var events = ['error', 'close', 'destroy', 'pause', 'resume'];
852
- forEach(events, function(ev) {
778
+ forEach(events, function (ev) {
853
779
  stream.on(ev, self.emit.bind(self, ev));
854
780
  });
855
781
 
856
782
  // when we try to consume some more bytes, simply unpause the
857
783
  // underlying stream.
858
- self._read = function(n) {
784
+ self._read = function (n) {
859
785
  debug('wrapped _read', n);
860
786
  if (paused) {
861
787
  paused = false;
@@ -866,7 +792,6 @@ Readable.prototype.wrap = function(stream) {
866
792
  return self;
867
793
  };
868
794
 
869
-
870
795
  // exposed for testing purposes only.
871
796
  Readable._fromList = fromList;
872
797
 
@@ -880,21 +805,11 @@ function fromList(n, state) {
880
805
  var ret;
881
806
 
882
807
  // nothing in the list, definitely empty.
883
- if (list.length === 0)
884
- return null;
808
+ if (list.length === 0) return null;
885
809
 
886
- if (length === 0)
887
- ret = null;
888
- else if (objectMode)
889
- ret = list.shift();
890
- else if (!n || n >= length) {
810
+ if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) {
891
811
  // read it all, truncate the array.
892
- if (stringMode)
893
- ret = list.join('');
894
- else if (list.length === 1)
895
- ret = list[0];
896
- else
897
- ret = Buffer.concat(list, length);
812
+ if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length);
898
813
  list.length = 0;
899
814
  } else {
900
815
  // read just some of it.
@@ -910,25 +825,16 @@ function fromList(n, state) {
910
825
  } else {
911
826
  // complex case.
912
827
  // we have enough to cover it, but it spans past the first buffer.
913
- if (stringMode)
914
- ret = '';
915
- else
916
- ret = new Buffer(n);
828
+ if (stringMode) ret = '';else ret = new Buffer(n);
917
829
 
918
830
  var c = 0;
919
831
  for (var i = 0, l = list.length; i < l && c < n; i++) {
920
832
  var buf = list[0];
921
833
  var cpy = Math.min(n - c, buf.length);
922
834
 
923
- if (stringMode)
924
- ret += buf.slice(0, cpy);
925
- else
926
- buf.copy(ret, c, 0, cpy);
835
+ if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy);
927
836
 
928
- if (cpy < buf.length)
929
- list[0] = buf.slice(cpy);
930
- else
931
- list.shift();
837
+ if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift();
932
838
 
933
839
  c += cpy;
934
840
  }
@@ -943,8 +849,7 @@ function endReadable(stream) {
943
849
 
944
850
  // If we get here before consuming all the bytes, then that is a
945
851
  // bug in node. Should never happen.
946
- if (state.length > 0)
947
- throw new Error('endReadable called on non-empty stream');
852
+ if (state.length > 0) throw new Error('endReadable called on non-empty stream');
948
853
 
949
854
  if (!state.endEmitted) {
950
855
  state.ended = true;
@@ -961,15 +866,15 @@ function endReadableNT(state, stream) {
961
866
  }
962
867
  }
963
868
 
964
- function forEach (xs, f) {
869
+ function forEach(xs, f) {
965
870
  for (var i = 0, l = xs.length; i < l; i++) {
966
871
  f(xs[i], i);
967
872
  }
968
873
  }
969
874
 
970
- function indexOf (xs, x) {
875
+ function indexOf(xs, x) {
971
876
  for (var i = 0, l = xs.length; i < l; i++) {
972
877
  if (xs[i] === x) return i;
973
878
  }
974
879
  return -1;
975
- }
880
+ }