fsevents 1.2.7 → 1.2.10

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 (152) hide show
  1. package/.travis.yml +1 -2
  2. package/fsevents.cc +8 -11
  3. package/node_modules/abbrev/package.json +2 -3
  4. package/node_modules/ansi-regex/package.json +1 -1
  5. package/node_modules/aproba/package.json +1 -1
  6. package/node_modules/are-we-there-yet/package.json +1 -1
  7. package/node_modules/balanced-match/package.json +1 -1
  8. package/node_modules/brace-expansion/package.json +1 -1
  9. package/node_modules/chownr/chownr.js +47 -10
  10. package/node_modules/chownr/package.json +7 -7
  11. package/node_modules/code-point-at/package.json +1 -1
  12. package/node_modules/concat-map/package.json +1 -1
  13. package/node_modules/console-control-strings/package.json +1 -1
  14. package/node_modules/core-util-is/package.json +1 -1
  15. package/node_modules/debug/CHANGELOG.md +34 -1
  16. package/node_modules/debug/README.md +188 -63
  17. package/node_modules/debug/dist/debug.js +886 -0
  18. package/node_modules/debug/package.json +28 -26
  19. package/node_modules/debug/src/browser.js +77 -82
  20. package/node_modules/debug/src/common.js +249 -0
  21. package/node_modules/debug/src/index.js +5 -3
  22. package/node_modules/debug/src/node.js +72 -146
  23. package/node_modules/deep-extend/package.json +1 -1
  24. package/node_modules/delegates/package.json +1 -1
  25. package/node_modules/detect-libc/package.json +1 -1
  26. package/node_modules/fs-minipass/index.js +2 -1
  27. package/node_modules/fs-minipass/package.json +13 -10
  28. package/node_modules/fs.realpath/package.json +1 -1
  29. package/node_modules/gauge/package.json +1 -1
  30. package/node_modules/glob/LICENSE +6 -0
  31. package/node_modules/glob/README.md +8 -1
  32. package/node_modules/glob/package.json +9 -6
  33. package/node_modules/has-unicode/package.json +1 -1
  34. package/node_modules/iconv-lite/package.json +1 -1
  35. package/node_modules/ignore-walk/README.md +1 -1
  36. package/node_modules/ignore-walk/index.js +9 -5
  37. package/node_modules/ignore-walk/package.json +11 -8
  38. package/node_modules/inflight/package.json +1 -1
  39. package/node_modules/inherits/inherits.js +2 -0
  40. package/node_modules/inherits/inherits_browser.js +18 -14
  41. package/node_modules/inherits/package.json +9 -11
  42. package/node_modules/ini/package.json +1 -1
  43. package/node_modules/is-fullwidth-code-point/package.json +1 -1
  44. package/node_modules/isarray/package.json +1 -1
  45. package/node_modules/minimatch/package.json +1 -1
  46. package/node_modules/minimist/package.json +1 -1
  47. package/node_modules/minipass/README.md +486 -4
  48. package/node_modules/minipass/index.js +190 -28
  49. package/node_modules/minipass/package.json +17 -14
  50. package/node_modules/minizlib/README.md +36 -27
  51. package/node_modules/minizlib/constants.js +73 -4
  52. package/node_modules/minizlib/index.js +137 -152
  53. package/node_modules/minizlib/package.json +12 -12
  54. package/node_modules/mkdirp/package.json +1 -2
  55. package/node_modules/ms/index.js +29 -19
  56. package/node_modules/ms/package.json +17 -17
  57. package/node_modules/ms/readme.md +18 -9
  58. package/node_modules/needle/README.md +1 -2
  59. package/node_modules/needle/examples/multipart-stream.js +1 -1
  60. package/node_modules/needle/lib/auth.js +1 -1
  61. package/node_modules/needle/lib/multipart.js +1 -1
  62. package/node_modules/needle/lib/needle.js +4 -2
  63. package/node_modules/needle/package.json +13 -13
  64. package/node_modules/needle/test/basic_auth_spec.js +1 -1
  65. package/node_modules/needle/test/cookies_spec.js +2 -2
  66. package/node_modules/needle/test/headers_spec.js +1 -1
  67. package/node_modules/needle/test/output_spec.js +1 -1
  68. package/node_modules/needle/test/post_data_spec.js +20 -20
  69. package/node_modules/needle/test/proxy_spec.js +1 -1
  70. package/node_modules/needle/test/utils/test.js +1 -1
  71. package/node_modules/node-pre-gyp/CHANGELOG.md +10 -0
  72. package/node_modules/node-pre-gyp/README.md +41 -6
  73. package/node_modules/node-pre-gyp/lib/build.js +1 -1
  74. package/node_modules/node-pre-gyp/lib/install.js +20 -8
  75. package/node_modules/node-pre-gyp/lib/node-pre-gyp.js +1 -1
  76. package/node_modules/node-pre-gyp/lib/pre-binding.js +5 -5
  77. package/node_modules/node-pre-gyp/lib/rebuild.js +1 -1
  78. package/node_modules/node-pre-gyp/lib/reinstall.js +1 -1
  79. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +48 -0
  80. package/node_modules/node-pre-gyp/lib/util/handle_gyp_opts.js +5 -2
  81. package/node_modules/node-pre-gyp/lib/util/napi.js +70 -22
  82. package/node_modules/node-pre-gyp/lib/util/versioning.js +7 -6
  83. package/node_modules/node-pre-gyp/package.json +11 -11
  84. package/node_modules/nopt/package.json +1 -1
  85. package/node_modules/npm-bundled/index.js +26 -6
  86. package/node_modules/npm-bundled/package.json +9 -6
  87. package/node_modules/npm-normalize-package-bin/.github/settings.yml +2 -0
  88. package/node_modules/npm-normalize-package-bin/.npmignore +24 -0
  89. package/node_modules/npm-normalize-package-bin/LICENSE +15 -0
  90. package/node_modules/npm-normalize-package-bin/README.md +14 -0
  91. package/node_modules/npm-normalize-package-bin/index.js +60 -0
  92. package/node_modules/npm-normalize-package-bin/package-lock.json +3529 -0
  93. package/node_modules/npm-normalize-package-bin/package.json +57 -0
  94. package/node_modules/npm-normalize-package-bin/test/array.js +37 -0
  95. package/node_modules/npm-normalize-package-bin/test/nobin.js +35 -0
  96. package/node_modules/npm-normalize-package-bin/test/object.js +141 -0
  97. package/node_modules/npm-normalize-package-bin/test/string.js +37 -0
  98. package/node_modules/npm-packlist/index.js +76 -16
  99. package/node_modules/npm-packlist/package.json +16 -9
  100. package/node_modules/npmlog/package.json +1 -1
  101. package/node_modules/number-is-nan/package.json +1 -1
  102. package/node_modules/object-assign/package.json +1 -1
  103. package/node_modules/once/package.json +1 -1
  104. package/node_modules/os-homedir/package.json +1 -1
  105. package/node_modules/os-tmpdir/package.json +1 -1
  106. package/node_modules/osenv/package.json +1 -1
  107. package/node_modules/path-is-absolute/package.json +1 -1
  108. package/node_modules/process-nextick-args/index.js +2 -1
  109. package/node_modules/process-nextick-args/package.json +6 -6
  110. package/node_modules/rc/node_modules/minimist/package.json +1 -1
  111. package/node_modules/rc/package.json +1 -1
  112. package/node_modules/readable-stream/package.json +1 -1
  113. package/node_modules/rimraf/package.json +6 -6
  114. package/node_modules/rimraf/rimraf.js +9 -1
  115. package/node_modules/safe-buffer/package.json +1 -1
  116. package/node_modules/safer-buffer/package.json +1 -1
  117. package/node_modules/sax/package.json +1 -1
  118. package/node_modules/semver/CHANGELOG.md +39 -0
  119. package/node_modules/semver/README.md +26 -13
  120. package/node_modules/semver/bin/semver +84 -77
  121. package/node_modules/semver/package.json +14 -8
  122. package/node_modules/semver/semver.js +906 -775
  123. package/node_modules/set-blocking/package.json +1 -1
  124. package/node_modules/signal-exit/package.json +1 -1
  125. package/node_modules/string-width/package.json +1 -1
  126. package/node_modules/string_decoder/package.json +1 -1
  127. package/node_modules/strip-ansi/package.json +1 -1
  128. package/node_modules/strip-json-comments/package.json +1 -1
  129. package/node_modules/tar/lib/large-numbers.js +32 -27
  130. package/node_modules/tar/lib/mkdir.js +2 -2
  131. package/node_modules/tar/lib/parse.js +6 -1
  132. package/node_modules/tar/lib/read-entry.js +4 -0
  133. package/node_modules/tar/lib/write-entry.js +2 -2
  134. package/node_modules/tar/package.json +17 -13
  135. package/node_modules/util-deprecate/package.json +1 -1
  136. package/node_modules/wide-align/package.json +1 -1
  137. package/node_modules/wrappy/package.json +1 -1
  138. package/node_modules/yallist/package.json +11 -11
  139. package/node_modules/yallist/yallist.js +50 -0
  140. package/package.json +5 -8
  141. package/src/constants.cc +20 -20
  142. package/node_modules/debug/.coveralls.yml +0 -1
  143. package/node_modules/debug/.eslintrc +0 -11
  144. package/node_modules/debug/.npmignore +0 -9
  145. package/node_modules/debug/.travis.yml +0 -14
  146. package/node_modules/debug/Makefile +0 -50
  147. package/node_modules/debug/component.json +0 -19
  148. package/node_modules/debug/karma.conf.js +0 -70
  149. package/node_modules/debug/src/debug.js +0 -202
  150. package/node_modules/debug/src/inspector-log.js +0 -15
  151. package/node_modules/needle/note.xml +0 -7
  152. package/node_modules/needle/note.xml.1 +0 -7
@@ -1,39 +1,62 @@
1
1
  'use strict'
2
2
  const EE = require('events')
3
3
  const Yallist = require('yallist')
4
+ const SD = require('string_decoder').StringDecoder
5
+
4
6
  const EOF = Symbol('EOF')
5
7
  const MAYBE_EMIT_END = Symbol('maybeEmitEnd')
6
8
  const EMITTED_END = Symbol('emittedEnd')
9
+ const EMITTING_END = Symbol('emittingEnd')
7
10
  const CLOSED = Symbol('closed')
8
11
  const READ = Symbol('read')
9
12
  const FLUSH = Symbol('flush')
10
- const doIter = process.env._MP_NO_ITERATOR_SYMBOLS_ !== '1'
11
- const ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol('asyncIterator not implemented')
12
- const ITERATOR = doIter && Symbol.iterator || Symbol('iterator not implemented')
13
13
  const FLUSHCHUNK = Symbol('flushChunk')
14
- const SD = require('string_decoder').StringDecoder
15
14
  const ENCODING = Symbol('encoding')
16
15
  const DECODER = Symbol('decoder')
17
16
  const FLOWING = Symbol('flowing')
17
+ const PAUSED = Symbol('paused')
18
18
  const RESUME = Symbol('resume')
19
19
  const BUFFERLENGTH = Symbol('bufferLength')
20
20
  const BUFFERPUSH = Symbol('bufferPush')
21
21
  const BUFFERSHIFT = Symbol('bufferShift')
22
22
  const OBJECTMODE = Symbol('objectMode')
23
+ const DESTROYED = Symbol('destroyed')
24
+
25
+ // TODO remove when Node v8 support drops
26
+ const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== '1'
27
+ const ASYNCITERATOR = doIter && Symbol.asyncIterator
28
+ || Symbol('asyncIterator not implemented')
29
+ const ITERATOR = doIter && Symbol.iterator
30
+ || Symbol('iterator not implemented')
23
31
 
24
32
  // Buffer in node 4.x < 4.5.0 doesn't have working Buffer.from
25
33
  // or Buffer.alloc, and Buffer in node 10 deprecated the ctor.
26
34
  // .M, this is fine .\^/M..
27
- let B = Buffer
28
- /* istanbul ignore next */
29
- if (!B.alloc) {
30
- B = require('safe-buffer').Buffer
31
- }
32
-
33
- module.exports = class MiniPass extends EE {
35
+ const B = Buffer.alloc ? Buffer
36
+ : /* istanbul ignore next */ require('safe-buffer').Buffer
37
+
38
+ // events that mean 'the stream is over'
39
+ // these are treated specially, and re-emitted
40
+ // if they are listened for after emitting.
41
+ const isEndish = ev =>
42
+ ev === 'end' ||
43
+ ev === 'finish' ||
44
+ ev === 'prefinish'
45
+
46
+ const isArrayBuffer = b => b instanceof ArrayBuffer ||
47
+ typeof b === 'object' &&
48
+ b.constructor &&
49
+ b.constructor.name === 'ArrayBuffer' &&
50
+ b.byteLength >= 0
51
+
52
+ const isArrayBufferView = b => !B.isBuffer(b) && ArrayBuffer.isView(b)
53
+
54
+ module.exports = class Minipass extends EE {
34
55
  constructor (options) {
35
56
  super()
36
57
  this[FLOWING] = false
58
+ // whether we're explicitly paused
59
+ this[PAUSED] = false
37
60
  this.pipes = new Yallist()
38
61
  this.buffer = new Yallist()
39
62
  this[OBJECTMODE] = options && options.objectMode || false
@@ -46,10 +69,12 @@ module.exports = class MiniPass extends EE {
46
69
  this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null
47
70
  this[EOF] = false
48
71
  this[EMITTED_END] = false
72
+ this[EMITTING_END] = false
49
73
  this[CLOSED] = false
50
74
  this.writable = true
51
75
  this.readable = true
52
76
  this[BUFFERLENGTH] = 0
77
+ this[DESTROYED] = false
53
78
  }
54
79
 
55
80
  get bufferLength () { return this[BUFFERLENGTH] }
@@ -76,16 +101,52 @@ module.exports = class MiniPass extends EE {
76
101
  this.encoding = enc
77
102
  }
78
103
 
104
+ get objectMode () { return this[OBJECTMODE] }
105
+ set objectMode (ॐ ) { this[OBJECTMODE] = this[OBJECTMODE] || !!ॐ }
106
+
79
107
  write (chunk, encoding, cb) {
80
108
  if (this[EOF])
81
109
  throw new Error('write after end')
82
110
 
111
+ if (this[DESTROYED]) {
112
+ this.emit('error', Object.assign(
113
+ new Error('Cannot call write after a stream was destroyed'),
114
+ { code: 'ERR_STREAM_DESTROYED' }
115
+ ))
116
+ return true
117
+ }
118
+
83
119
  if (typeof encoding === 'function')
84
120
  cb = encoding, encoding = 'utf8'
85
121
 
86
122
  if (!encoding)
87
123
  encoding = 'utf8'
88
124
 
125
+ // convert array buffers and typed array views into buffers
126
+ // at some point in the future, we may want to do the opposite!
127
+ // leave strings and buffers as-is
128
+ // anything else switches us into object mode
129
+ if (!this[OBJECTMODE] && !B.isBuffer(chunk)) {
130
+ if (isArrayBufferView(chunk))
131
+ chunk = B.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)
132
+ else if (isArrayBuffer(chunk))
133
+ chunk = B.from(chunk)
134
+ else if (typeof chunk !== 'string')
135
+ // use the setter so we throw if we have encoding set
136
+ this.objectMode = true
137
+ }
138
+
139
+ // this ensures at this point that the chunk is a buffer or string
140
+ // don't buffer it up or send it to the decoder
141
+ if (!this.objectMode && !chunk.length) {
142
+ const ret = this.flowing
143
+ if (this[BUFFERLENGTH] !== 0)
144
+ this.emit('readable')
145
+ if (cb)
146
+ cb()
147
+ return ret
148
+ }
149
+
89
150
  // fast-path writing strings of same encoding to a stream with
90
151
  // an empty buffer, skipping the buffer/decoder dance
91
152
  if (typeof chunk === 'string' && !this[OBJECTMODE] &&
@@ -102,13 +163,17 @@ module.exports = class MiniPass extends EE {
102
163
  ? (this.emit('data', chunk), this.flowing)
103
164
  : (this[BUFFERPUSH](chunk), false)
104
165
  } finally {
105
- this.emit('readable')
166
+ if (this[BUFFERLENGTH] !== 0)
167
+ this.emit('readable')
106
168
  if (cb)
107
169
  cb()
108
170
  }
109
171
  }
110
172
 
111
173
  read (n) {
174
+ if (this[DESTROYED])
175
+ return null
176
+
112
177
  try {
113
178
  if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH])
114
179
  return null
@@ -161,12 +226,22 @@ module.exports = class MiniPass extends EE {
161
226
  this.once('end', cb)
162
227
  this[EOF] = true
163
228
  this.writable = false
164
- if (this.flowing)
229
+
230
+ // if we haven't written anything, then go ahead and emit,
231
+ // even if we're not reading.
232
+ // we'll re-emit if a new 'end' listener is added anyway.
233
+ // This makes MP more suitable to write-only use cases.
234
+ if (this.flowing || !this[PAUSED])
165
235
  this[MAYBE_EMIT_END]()
236
+ return this
166
237
  }
167
238
 
168
239
  // don't let the internal resume be overwritten
169
240
  [RESUME] () {
241
+ if (this[DESTROYED])
242
+ return
243
+
244
+ this[PAUSED] = false
170
245
  this[FLOWING] = true
171
246
  this.emit('resume')
172
247
  if (this.buffer.length)
@@ -183,12 +258,21 @@ module.exports = class MiniPass extends EE {
183
258
 
184
259
  pause () {
185
260
  this[FLOWING] = false
261
+ this[PAUSED] = true
262
+ }
263
+
264
+ get destroyed () {
265
+ return this[DESTROYED]
186
266
  }
187
267
 
188
268
  get flowing () {
189
269
  return this[FLOWING]
190
270
  }
191
271
 
272
+ get paused () {
273
+ return this[PAUSED]
274
+ }
275
+
192
276
  [BUFFERPUSH] (chunk) {
193
277
  if (this[OBJECTMODE])
194
278
  this[BUFFERLENGTH] += 1
@@ -219,13 +303,24 @@ module.exports = class MiniPass extends EE {
219
303
  }
220
304
 
221
305
  pipe (dest, opts) {
306
+ if (this[DESTROYED])
307
+ return
308
+
309
+ const ended = this[EMITTED_END]
310
+ opts = opts || {}
222
311
  if (dest === process.stdout || dest === process.stderr)
223
- (opts = opts || {}).end = false
312
+ opts.end = false
313
+ else
314
+ opts.end = opts.end !== false
315
+
224
316
  const p = { dest: dest, opts: opts, ondrain: _ => this[RESUME]() }
225
317
  this.pipes.push(p)
226
318
 
227
319
  dest.on('drain', p.ondrain)
228
320
  this[RESUME]()
321
+ // piping an ended stream ends immediately
322
+ if (ended && p.opts.end)
323
+ p.dest.end()
229
324
  return dest
230
325
  }
231
326
 
@@ -239,9 +334,9 @@ module.exports = class MiniPass extends EE {
239
334
  } finally {
240
335
  if (ev === 'data' && !this.pipes.length && !this.flowing)
241
336
  this[RESUME]()
242
- else if (ev === 'end' && this[EMITTED_END]) {
243
- super.emit('end')
244
- this.removeAllListeners('end')
337
+ else if (isEndish(ev) && this[EMITTED_END]) {
338
+ super.emit(ev)
339
+ this.removeAllListeners(ev)
245
340
  }
246
341
  }
247
342
  }
@@ -251,23 +346,34 @@ module.exports = class MiniPass extends EE {
251
346
  }
252
347
 
253
348
  [MAYBE_EMIT_END] () {
254
- if (!this[EMITTED_END] && this.buffer.length === 0 && this[EOF]) {
349
+ if (!this[EMITTING_END] &&
350
+ !this[EMITTED_END] &&
351
+ !this[DESTROYED] &&
352
+ this.buffer.length === 0 &&
353
+ this[EOF]) {
354
+ this[EMITTING_END] = true
255
355
  this.emit('end')
256
356
  this.emit('prefinish')
257
357
  this.emit('finish')
258
358
  if (this[CLOSED])
259
359
  this.emit('close')
360
+ this[EMITTING_END] = false
260
361
  }
261
362
  }
262
363
 
263
364
  emit (ev, data) {
264
- if (ev === 'data') {
365
+ // error and close are only events allowed after calling destroy()
366
+ if (ev !== 'error' && ev !== 'close' && ev !== DESTROYED && this[DESTROYED])
367
+ return
368
+ else if (ev === 'data') {
265
369
  if (!data)
266
370
  return
267
371
 
268
372
  if (this.pipes.length)
269
- this.pipes.forEach(p => p.dest.write(data) || this.pause())
373
+ this.pipes.forEach(p =>
374
+ p.dest.write(data) === false && this.pause())
270
375
  } else if (ev === 'end') {
376
+ // only actual end gets this treatment
271
377
  if (this[EMITTED_END] === true)
272
378
  return
273
379
 
@@ -284,16 +390,17 @@ module.exports = class MiniPass extends EE {
284
390
 
285
391
  this.pipes.forEach(p => {
286
392
  p.dest.removeListener('drain', p.ondrain)
287
- if (!p.opts || p.opts.end !== false)
393
+ if (p.opts.end)
288
394
  p.dest.end()
289
395
  })
290
396
  } else if (ev === 'close') {
291
397
  this[CLOSED] = true
292
398
  // don't emit close before 'end' and 'finish'
293
- if (!this[EMITTED_END])
399
+ if (!this[EMITTED_END] && !this[DESTROYED])
294
400
  return
295
401
  }
296
402
 
403
+ // TODO: replace with a spread operator when Node v4 support drops
297
404
  const args = new Array(arguments.length)
298
405
  args[0] = ev
299
406
  args[1] = data
@@ -306,20 +413,40 @@ module.exports = class MiniPass extends EE {
306
413
  try {
307
414
  return super.emit.apply(this, args)
308
415
  } finally {
309
- if (ev !== 'end')
416
+ if (!isEndish(ev))
310
417
  this[MAYBE_EMIT_END]()
311
418
  else
312
- this.removeAllListeners('end')
419
+ this.removeAllListeners(ev)
313
420
  }
314
421
  }
315
422
 
316
423
  // const all = await stream.collect()
317
424
  collect () {
425
+ const buf = []
426
+ buf.dataLength = 0
427
+ this.on('data', c => {
428
+ buf.push(c)
429
+ buf.dataLength += c.length
430
+ })
431
+ return this.promise().then(() => buf)
432
+ }
433
+
434
+ // const data = await stream.concat()
435
+ concat () {
436
+ return this[OBJECTMODE]
437
+ ? Promise.reject(new Error('cannot concat in objectMode'))
438
+ : this.collect().then(buf =>
439
+ this[OBJECTMODE]
440
+ ? Promise.reject(new Error('cannot concat in objectMode'))
441
+ : this[ENCODING] ? buf.join('') : B.concat(buf, buf.dataLength))
442
+ }
443
+
444
+ // stream.promise().then(() => done, er => emitted error)
445
+ promise () {
318
446
  return new Promise((resolve, reject) => {
319
- const buf = []
320
- this.on('data', c => buf.push(c))
321
- this.on('end', () => resolve(buf))
322
- this.on('error', reject)
447
+ this.on(DESTROYED, () => reject(new Error('stream destroyed')))
448
+ this.on('end', () => resolve())
449
+ this.on('error', er => reject(er))
323
450
  })
324
451
  }
325
452
 
@@ -351,9 +478,11 @@ module.exports = class MiniPass extends EE {
351
478
  this.removeListener('data', ondata)
352
479
  resolve({ done: true })
353
480
  }
481
+ const ondestroy = () => onerr(new Error('stream destroyed'))
354
482
  return new Promise((res, rej) => {
355
483
  reject = rej
356
484
  resolve = res
485
+ this.once(DESTROYED, ondestroy)
357
486
  this.once('error', onerr)
358
487
  this.once('end', onend)
359
488
  this.once('data', ondata)
@@ -372,4 +501,37 @@ module.exports = class MiniPass extends EE {
372
501
  }
373
502
  return { next }
374
503
  }
504
+
505
+ destroy (er) {
506
+ if (this[DESTROYED]) {
507
+ if (er)
508
+ this.emit('error', er)
509
+ else
510
+ this.emit(DESTROYED)
511
+ return this
512
+ }
513
+
514
+ this[DESTROYED] = true
515
+
516
+ // throw away all buffered data, it's never coming out
517
+ this.buffer = new Yallist()
518
+ this[BUFFERLENGTH] = 0
519
+
520
+ if (typeof this.close === 'function' && !this[CLOSED])
521
+ this.close()
522
+
523
+ if (er)
524
+ this.emit('error', er)
525
+ else // if no error to emit, still reject pending promises
526
+ this.emit(DESTROYED)
527
+
528
+ return this
529
+ }
530
+
531
+ static isStream (s) {
532
+ return !!s && (s instanceof Minipass || s instanceof EE && (
533
+ typeof s.pipe === 'function' || // readable
534
+ (typeof s.write === 'function' && typeof s.end === 'function') // writable
535
+ ))
536
+ }
375
537
  }
@@ -1,29 +1,29 @@
1
1
  {
2
- "_from": "minipass@^2.3.4",
3
- "_id": "minipass@2.3.5",
2
+ "_from": "minipass@^2.8.6",
3
+ "_id": "minipass@2.9.0",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
5
+ "_integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==",
6
6
  "_location": "/minipass",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "range",
10
10
  "registry": true,
11
- "raw": "minipass@^2.3.4",
11
+ "raw": "minipass@^2.8.6",
12
12
  "name": "minipass",
13
13
  "escapedName": "minipass",
14
- "rawSpec": "^2.3.4",
14
+ "rawSpec": "^2.8.6",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^2.3.4"
16
+ "fetchSpec": "^2.8.6"
17
17
  },
18
18
  "_requiredBy": [
19
19
  "/fs-minipass",
20
20
  "/minizlib",
21
21
  "/tar"
22
22
  ],
23
- "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz",
24
- "_shasum": "cacebe492022497f656b0f0f51e2682a9ed2d848",
25
- "_spec": "minipass@^2.3.4",
26
- "_where": "/Users/pdunkel1/Office/fsevents/fsevents/node_modules/tar",
23
+ "_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz",
24
+ "_shasum": "e713762e7d3e32fed803115cf93e04bca9fcc9a6",
25
+ "_spec": "minipass@^2.8.6",
26
+ "_where": "/Users/pipobscure/fsevents/node_modules/tar",
27
27
  "author": {
28
28
  "name": "Isaac Z. Schlueter",
29
29
  "email": "i@izs.me",
@@ -41,7 +41,7 @@
41
41
  "description": "minimal implementation of a PassThrough stream",
42
42
  "devDependencies": {
43
43
  "end-of-stream": "^1.4.0",
44
- "tap": "^12.0.1",
44
+ "tap": "^14.6.5",
45
45
  "through2": "^2.0.3"
46
46
  },
47
47
  "files": [
@@ -60,10 +60,13 @@
60
60
  "url": "git+https://github.com/isaacs/minipass.git"
61
61
  },
62
62
  "scripts": {
63
- "postpublish": "git push origin --all; git push origin --tags",
63
+ "postpublish": "git push origin --follow-tags",
64
64
  "postversion": "npm publish",
65
65
  "preversion": "npm test",
66
- "test": "tap test/*.js --100"
66
+ "test": "tap"
67
67
  },
68
- "version": "2.3.5"
68
+ "tap": {
69
+ "check-coverage": true
70
+ },
71
+ "version": "2.9.0"
69
72
  }
@@ -1,44 +1,53 @@
1
1
  # minizlib
2
2
 
3
- A tiny fast zlib stream built on [minipass](http://npm.im/minipass)
4
- and Node.js's zlib binding.
3
+ A fast zlib stream built on [minipass](http://npm.im/minipass) and
4
+ Node.js's zlib binding.
5
5
 
6
6
  This module was created to serve the needs of
7
- [node-tar](http://npm.im/tar) v2. If your needs are different, then
8
- it may not be for you.
7
+ [node-tar](http://npm.im/tar) and
8
+ [minipass-fetch](http://npm.im/minipass-fetch).
9
+
10
+ Brotli is supported in versions of node with a Brotli binding.
9
11
 
10
12
  ## How does this differ from the streams in `require('zlib')`?
11
13
 
12
14
  First, there are no convenience methods to compress or decompress a
13
15
  buffer. If you want those, use the built-in `zlib` module. This is
14
- only streams.
16
+ only streams. That being said, Minipass streams to make it fairly easy to
17
+ use as one-liners: `new zlib.Deflate().end(data).read()` will return the
18
+ deflate compressed result.
15
19
 
16
20
  This module compresses and decompresses the data as fast as you feed
17
21
  it in. It is synchronous, and runs on the main process thread. Zlib
18
- operations can be high CPU, but they're very fast, and doing it this
19
- way means much less bookkeeping and artificial deferral.
22
+ and Brotli operations can be high CPU, but they're very fast, and doing it
23
+ this way means much less bookkeeping and artificial deferral.
20
24
 
21
25
  Node's built in zlib streams are built on top of `stream.Transform`.
22
26
  They do the maximally safe thing with respect to consistent
23
27
  asynchrony, buffering, and backpressure.
24
28
 
25
- This module _does_ support backpressure, and will buffer output chunks
26
- that are not consumed, but is less of a mediator between the input and
27
- output. There is no high or low watermarks, no state objects, and so
28
- artificial async deferrals. It will not protect you from Zalgo.
29
-
30
- If you write, data will be emitted right away. If you write
31
- everything synchronously in one tick, and you are listening to the
32
- `data` event to consume it, then it'll all be emitted right away in
33
- that same tick. If you want data to be emitted in the next tick, then
34
- write it in the next tick.
35
-
36
- It is thus the responsibility of the reader and writer to manage their
37
- own consumption and process execution flow.
38
-
39
- The goal is to compress and decompress as fast as possible, even for
40
- files that are too large to store all in one buffer.
41
-
42
- The API is very similar to the built-in zlib module. There are
43
- classes that you instantiate with `new` and they are streams that can
44
- be piped together.
29
+ See [Minipass](http://npm.im/minipass) for more on the differences between
30
+ Node.js core streams and Minipass streams, and the convenience methods
31
+ provided by that class.
32
+
33
+ ## Classes
34
+
35
+ - Deflate
36
+ - Inflate
37
+ - Gzip
38
+ - Gunzip
39
+ - DeflateRaw
40
+ - InflateRaw
41
+ - Unzip
42
+ - BrotliCompress (Node v10 and higher)
43
+ - BrotliDecompress (Node v10 and higher)
44
+
45
+ ## USAGE
46
+
47
+ ```js
48
+ const zlib = require('minizlib')
49
+ const input = sourceOfCompressedData()
50
+ const decode = new zlib.BrotliDecompress()
51
+ const output = whereToWriteTheDecodedData()
52
+ input.pipe(decode).pipe(output)
53
+ ```
@@ -1,4 +1,11 @@
1
- module.exports = Object.freeze({
1
+ // Update with any zlib constants that are added or changed in the future.
2
+ // Node v6 didn't export this, so we just hard code the version and rely
3
+ // on all the other hard-coded values from zlib v4736. When node v6
4
+ // support drops, we can just export the realZlibConstants object.
5
+ const realZlibConstants = require('zlib').constants ||
6
+ /* istanbul ignore next */ { ZLIB_VERNUM: 4736 }
7
+
8
+ module.exports = Object.freeze(Object.assign(Object.create(null), {
2
9
  Z_NO_FLUSH: 0,
3
10
  Z_PARTIAL_FLUSH: 1,
4
11
  Z_SYNC_FLUSH: 2,
@@ -23,7 +30,6 @@ module.exports = Object.freeze({
23
30
  Z_RLE: 3,
24
31
  Z_FIXED: 4,
25
32
  Z_DEFAULT_STRATEGY: 0,
26
- ZLIB_VERNUM: 4736,
27
33
  DEFLATE: 1,
28
34
  INFLATE: 2,
29
35
  GZIP: 3,
@@ -31,6 +37,8 @@ module.exports = Object.freeze({
31
37
  DEFLATERAW: 5,
32
38
  INFLATERAW: 6,
33
39
  UNZIP: 7,
40
+ BROTLI_DECODE: 8,
41
+ BROTLI_ENCODE: 9,
34
42
  Z_MIN_WINDOWBITS: 8,
35
43
  Z_MAX_WINDOWBITS: 15,
36
44
  Z_DEFAULT_WINDOWBITS: 15,
@@ -42,5 +50,66 @@ module.exports = Object.freeze({
42
50
  Z_DEFAULT_MEMLEVEL: 8,
43
51
  Z_MIN_LEVEL: -1,
44
52
  Z_MAX_LEVEL: 9,
45
- Z_DEFAULT_LEVEL: -1
46
- })
53
+ Z_DEFAULT_LEVEL: -1,
54
+ BROTLI_OPERATION_PROCESS: 0,
55
+ BROTLI_OPERATION_FLUSH: 1,
56
+ BROTLI_OPERATION_FINISH: 2,
57
+ BROTLI_OPERATION_EMIT_METADATA: 3,
58
+ BROTLI_MODE_GENERIC: 0,
59
+ BROTLI_MODE_TEXT: 1,
60
+ BROTLI_MODE_FONT: 2,
61
+ BROTLI_DEFAULT_MODE: 0,
62
+ BROTLI_MIN_QUALITY: 0,
63
+ BROTLI_MAX_QUALITY: 11,
64
+ BROTLI_DEFAULT_QUALITY: 11,
65
+ BROTLI_MIN_WINDOW_BITS: 10,
66
+ BROTLI_MAX_WINDOW_BITS: 24,
67
+ BROTLI_LARGE_MAX_WINDOW_BITS: 30,
68
+ BROTLI_DEFAULT_WINDOW: 22,
69
+ BROTLI_MIN_INPUT_BLOCK_BITS: 16,
70
+ BROTLI_MAX_INPUT_BLOCK_BITS: 24,
71
+ BROTLI_PARAM_MODE: 0,
72
+ BROTLI_PARAM_QUALITY: 1,
73
+ BROTLI_PARAM_LGWIN: 2,
74
+ BROTLI_PARAM_LGBLOCK: 3,
75
+ BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
76
+ BROTLI_PARAM_SIZE_HINT: 5,
77
+ BROTLI_PARAM_LARGE_WINDOW: 6,
78
+ BROTLI_PARAM_NPOSTFIX: 7,
79
+ BROTLI_PARAM_NDIRECT: 8,
80
+ BROTLI_DECODER_RESULT_ERROR: 0,
81
+ BROTLI_DECODER_RESULT_SUCCESS: 1,
82
+ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
83
+ BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
84
+ BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
85
+ BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
86
+ BROTLI_DECODER_NO_ERROR: 0,
87
+ BROTLI_DECODER_SUCCESS: 1,
88
+ BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
89
+ BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
90
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
91
+ BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
92
+ BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
93
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
94
+ BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
95
+ BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
96
+ BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
97
+ BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
98
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
99
+ BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
100
+ BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
101
+ BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
102
+ BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
103
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
104
+ BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
105
+ BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
106
+ BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
107
+ BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
108
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
109
+ BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
110
+ BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
111
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
112
+ BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
113
+ BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
114
+ BROTLI_DECODER_ERROR_UNREACHABLE: -31,
115
+ }, realZlibConstants))