pnpm 7.3.0 → 7.4.0-2

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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Fast, disk space efficient package manager:
18
18
  * **Works as a Node.js version manager.** See [pnpm env use](https://pnpm.io/cli/env).
19
19
  * **Works everywhere.** Supports Windows, Linux, and macOS.
20
20
  * **Battle-tested.** Used in production by teams of [all sizes](https://pnpm.io/users) since 2016.
21
-
21
+
22
22
  To quote the [Rush](https://rushjs.io/) team:
23
23
 
24
24
  > Microsoft uses pnpm in Rush repos with hundreds of projects and hundreds of PRs per day, and we’ve found it to be very fast and reliable.
@@ -29,7 +29,7 @@ To quote the [Rush](https://rushjs.io/) team:
29
29
  [![OpenCollective](https://opencollective.com/pnpm/sponsors/badge.svg)](#sponsors)
30
30
  [![Twitter Follow](https://img.shields.io/twitter/follow/pnpmjs.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=pnpmjs&region=follow_link)
31
31
 
32
- ## Sponsors
32
+ ## Gold Sponsors
33
33
 
34
34
  <table>
35
35
  <tbody>
@@ -37,6 +37,17 @@ To quote the [Rush](https://rushjs.io/) team:
37
37
  <td align="center" valign="middle">
38
38
  <a href="https://bit.dev/?utm_source=pnpm&utm_medium=readme" target="_blank"><img src="https://raw.githubusercontent.com/pnpm/pnpm.github.io/main/static/img/users/bit.svg" width="80"></a>
39
39
  </td>
40
+ <td align="center" valign="middle">
41
+ <a href="https://nhost.io/?utm_source=pnpm&utm_medium=readme" target="_blank"><img src="https://raw.githubusercontent.com/pnpm/pnpm.github.io/main/static/img/users/nhost.svg" width="180"></a>
42
+ </td>
43
+ </tr>
44
+ </table>
45
+
46
+ ## Silver Sponsors
47
+
48
+ <table>
49
+ <tbody>
50
+ <tr>
40
51
  <td align="center" valign="middle">
41
52
  <a href="https://prisma.io/?utm_source=pnpm&utm_medium=readme" target="_blank"><img src="https://raw.githubusercontent.com/pnpm/pnpm.github.io/main/static/img/users/prisma.svg" width="180"></a>
42
53
  </td>
@@ -7,11 +7,11 @@ included:
7
7
  injectedDeps: {}
8
8
  layoutVersion: 5
9
9
  nodeLinker: hoisted
10
- packageManager: pnpm@7.2.1
10
+ packageManager: pnpm@7.4.0-1
11
11
  pendingBuilds:
12
12
  - /node-gyp/8.4.1
13
13
  - /encoding/0.1.13
14
- prunedAt: Sat, 18 Jun 2022 20:56:14 GMT
14
+ prunedAt: Sun, 26 Jun 2022 22:37:49 GMT
15
15
  publicHoistPattern:
16
16
  - '*eslint*'
17
17
  - '*prettier*'
@@ -116,7 +116,7 @@ packages:
116
116
  glob: 7.2.3
117
117
  infer-owner: 1.0.4
118
118
  lru-cache: 6.0.0
119
- minipass: 3.1.6
119
+ minipass: 3.3.3
120
120
  minipass-collect: 1.0.2
121
121
  minipass-flush: 1.0.5
122
122
  minipass-pipeline: 1.2.4
@@ -212,7 +212,7 @@ packages:
212
212
  resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
213
213
  engines: {node: '>= 8'}
214
214
  dependencies:
215
- minipass: 3.1.6
215
+ minipass: 3.3.3
216
216
  dev: false
217
217
  optional: true
218
218
 
@@ -371,7 +371,7 @@ packages:
371
371
  https-proxy-agent: 5.0.1
372
372
  is-lambda: 1.0.1
373
373
  lru-cache: 6.0.0
374
- minipass: 3.1.6
374
+ minipass: 3.3.3
375
375
  minipass-collect: 1.0.2
376
376
  minipass-fetch: 1.4.1
377
377
  minipass-flush: 1.0.5
@@ -397,7 +397,7 @@ packages:
397
397
  resolution: {integrity: sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==}
398
398
  engines: {node: '>= 8'}
399
399
  dependencies:
400
- minipass: 3.1.6
400
+ minipass: 3.3.3
401
401
  dev: false
402
402
  optional: true
403
403
 
@@ -405,7 +405,7 @@ packages:
405
405
  resolution: {integrity: sha512-CGH1eblLq26Y15+Azk7ey4xh0J/XfJfrCox5LDJiKqI2Q2iwOLOKrlmIaODiSQS8d18jalF6y2K2ePUm0CmShw==}
406
406
  engines: {node: '>=8'}
407
407
  dependencies:
408
- minipass: 3.1.6
408
+ minipass: 3.3.3
409
409
  minipass-sized: 1.0.3
410
410
  minizlib: 2.1.2
411
411
  optionalDependencies:
@@ -417,7 +417,7 @@ packages:
417
417
  resolution: {integrity: sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==}
418
418
  engines: {node: '>= 8'}
419
419
  dependencies:
420
- minipass: 3.1.6
420
+ minipass: 3.3.3
421
421
  dev: false
422
422
  optional: true
423
423
 
@@ -425,7 +425,7 @@ packages:
425
425
  resolution: {integrity: sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==}
426
426
  engines: {node: '>=8'}
427
427
  dependencies:
428
- minipass: 3.1.6
428
+ minipass: 3.3.3
429
429
  dev: false
430
430
  optional: true
431
431
 
@@ -433,12 +433,12 @@ packages:
433
433
  resolution: {integrity: sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==}
434
434
  engines: {node: '>=8'}
435
435
  dependencies:
436
- minipass: 3.1.6
436
+ minipass: 3.3.3
437
437
  dev: false
438
438
  optional: true
439
439
 
440
- /minipass/3.1.6:
441
- resolution: {integrity: sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==}
440
+ /minipass/3.3.3:
441
+ resolution: {integrity: sha512-N0BOsdFAlNRfmwMhjAsLVWOk7Ljmeb39iqFlsV1At+jqRhSUP9yeof8FyJu4imaJiSUp8vQebWD/guZwGQC8iA==}
442
442
  engines: {node: '>=8'}
443
443
  dependencies:
444
444
  yallist: 4.0.0
@@ -449,7 +449,7 @@ packages:
449
449
  resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
450
450
  engines: {node: '>= 8'}
451
451
  dependencies:
452
- minipass: 3.1.6
452
+ minipass: 3.3.3
453
453
  yallist: 4.0.0
454
454
  dev: false
455
455
  optional: true
@@ -643,7 +643,7 @@ packages:
643
643
  resolution: {integrity: sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==}
644
644
  engines: {node: '>= 8'}
645
645
  dependencies:
646
- minipass: 3.1.6
646
+ minipass: 3.3.3
647
647
  dev: false
648
648
  optional: true
649
649
 
@@ -678,7 +678,7 @@ packages:
678
678
  dependencies:
679
679
  chownr: 2.0.0
680
680
  fs-minipass: 2.1.0
681
- minipass: 3.1.6
681
+ minipass: 3.3.3
682
682
  minizlib: 2.1.2
683
683
  mkdirp: 1.0.4
684
684
  yallist: 4.0.0
@@ -1,6 +1,6 @@
1
1
  The ISC License
2
2
 
3
- Copyright (c) npm, Inc. and Contributors
3
+ Copyright (c) 2017-2022 npm, Inc., Isaac Z. Schlueter, and Contributors
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
@@ -5,7 +5,6 @@ const proc = typeof process === 'object' && process ? process : {
5
5
  }
6
6
  const EE = require('events')
7
7
  const Stream = require('stream')
8
- const Yallist = require('yallist')
9
8
  const SD = require('string_decoder').StringDecoder
10
9
 
11
10
  const EOF = Symbol('EOF')
@@ -27,6 +26,12 @@ const BUFFERPUSH = Symbol('bufferPush')
27
26
  const BUFFERSHIFT = Symbol('bufferShift')
28
27
  const OBJECTMODE = Symbol('objectMode')
29
28
  const DESTROYED = Symbol('destroyed')
29
+ const EMITDATA = Symbol('emitData')
30
+ const EMITEND = Symbol('emitEnd')
31
+ const EMITEND2 = Symbol('emitEnd2')
32
+ const ASYNC = Symbol('async')
33
+
34
+ const defer = fn => Promise.resolve().then(fn)
30
35
 
31
36
  // TODO remove when Node v8 support drops
32
37
  const doIter = global._MP_NO_ITERATOR_SYMBOLS_ !== '1'
@@ -51,14 +56,46 @@ const isArrayBuffer = b => b instanceof ArrayBuffer ||
51
56
 
52
57
  const isArrayBufferView = b => !Buffer.isBuffer(b) && ArrayBuffer.isView(b)
53
58
 
59
+ class Pipe {
60
+ constructor (src, dest, opts) {
61
+ this.src = src
62
+ this.dest = dest
63
+ this.opts = opts
64
+ this.ondrain = () => src[RESUME]()
65
+ dest.on('drain', this.ondrain)
66
+ }
67
+ unpipe () {
68
+ this.dest.removeListener('drain', this.ondrain)
69
+ }
70
+ // istanbul ignore next - only here for the prototype
71
+ proxyErrors () {}
72
+ end () {
73
+ this.unpipe()
74
+ if (this.opts.end)
75
+ this.dest.end()
76
+ }
77
+ }
78
+
79
+ class PipeProxyErrors extends Pipe {
80
+ unpipe () {
81
+ this.src.removeListener('error', this.proxyErrors)
82
+ super.unpipe()
83
+ }
84
+ constructor (src, dest, opts) {
85
+ super(src, dest, opts)
86
+ this.proxyErrors = er => dest.emit('error', er)
87
+ src.on('error', this.proxyErrors)
88
+ }
89
+ }
90
+
54
91
  module.exports = class Minipass extends Stream {
55
92
  constructor (options) {
56
93
  super()
57
94
  this[FLOWING] = false
58
95
  // whether we're explicitly paused
59
96
  this[PAUSED] = false
60
- this.pipes = new Yallist()
61
- this.buffer = new Yallist()
97
+ this.pipes = []
98
+ this.buffer = []
62
99
  this[OBJECTMODE] = options && options.objectMode || false
63
100
  if (this[OBJECTMODE])
64
101
  this[ENCODING] = null
@@ -66,6 +103,7 @@ module.exports = class Minipass extends Stream {
66
103
  this[ENCODING] = options && options.encoding || null
67
104
  if (this[ENCODING] === 'buffer')
68
105
  this[ENCODING] = null
106
+ this[ASYNC] = options && !!options.async || false
69
107
  this[DECODER] = this[ENCODING] ? new SD(this[ENCODING]) : null
70
108
  this[EOF] = false
71
109
  this[EMITTED_END] = false
@@ -105,6 +143,9 @@ module.exports = class Minipass extends Stream {
105
143
  get objectMode () { return this[OBJECTMODE] }
106
144
  set objectMode (om) { this[OBJECTMODE] = this[OBJECTMODE] || !!om }
107
145
 
146
+ get ['async'] () { return this[ASYNC] }
147
+ set ['async'] (a) { this[ASYNC] = this[ASYNC] || !!a }
148
+
108
149
  write (chunk, encoding, cb) {
109
150
  if (this[EOF])
110
151
  throw new Error('write after end')
@@ -123,6 +164,8 @@ module.exports = class Minipass extends Stream {
123
164
  if (!encoding)
124
165
  encoding = 'utf8'
125
166
 
167
+ const fn = this[ASYNC] ? defer : f => f()
168
+
126
169
  // convert array buffers and typed array views into buffers
127
170
  // at some point in the future, we may want to do the opposite!
128
171
  // leave strings and buffers as-is
@@ -137,19 +180,40 @@ module.exports = class Minipass extends Stream {
137
180
  this.objectMode = true
138
181
  }
139
182
 
140
- // this ensures at this point that the chunk is a buffer or string
183
+ // handle object mode up front, since it's simpler
184
+ // this yields better performance, fewer checks later.
185
+ if (this[OBJECTMODE]) {
186
+ /* istanbul ignore if - maybe impossible? */
187
+ if (this.flowing && this[BUFFERLENGTH] !== 0)
188
+ this[FLUSH](true)
189
+
190
+ if (this.flowing)
191
+ this.emit('data', chunk)
192
+ else
193
+ this[BUFFERPUSH](chunk)
194
+
195
+ if (this[BUFFERLENGTH] !== 0)
196
+ this.emit('readable')
197
+
198
+ if (cb)
199
+ fn(cb)
200
+
201
+ return this.flowing
202
+ }
203
+
204
+ // at this point the chunk is a buffer or string
141
205
  // don't buffer it up or send it to the decoder
142
- if (!this.objectMode && !chunk.length) {
206
+ if (!chunk.length) {
143
207
  if (this[BUFFERLENGTH] !== 0)
144
208
  this.emit('readable')
145
209
  if (cb)
146
- cb()
210
+ fn(cb)
147
211
  return this.flowing
148
212
  }
149
213
 
150
214
  // fast-path writing strings of same encoding to a stream with
151
215
  // an empty buffer, skipping the buffer/decoder dance
152
- if (typeof chunk === 'string' && !this[OBJECTMODE] &&
216
+ if (typeof chunk === 'string' &&
153
217
  // unless it is a string already ready for us to use
154
218
  !(encoding === this[ENCODING] && !this[DECODER].lastNeed)) {
155
219
  chunk = Buffer.from(chunk, encoding)
@@ -158,27 +222,20 @@ module.exports = class Minipass extends Stream {
158
222
  if (Buffer.isBuffer(chunk) && this[ENCODING])
159
223
  chunk = this[DECODER].write(chunk)
160
224
 
161
- if (this.flowing) {
162
- // if we somehow have something in the buffer, but we think we're
163
- // flowing, then we need to flush all that out first, or we get
164
- // chunks coming in out of order. Can't emit 'drain' here though,
165
- // because we're mid-write, so that'd be bad.
166
- if (this[BUFFERLENGTH] !== 0)
167
- this[FLUSH](true)
225
+ // Note: flushing CAN potentially switch us into not-flowing mode
226
+ if (this.flowing && this[BUFFERLENGTH] !== 0)
227
+ this[FLUSH](true)
168
228
 
169
- // if we are still flowing after flushing the buffer we can emit the
170
- // chunk otherwise we have to buffer it.
171
- this.flowing
172
- ? this.emit('data', chunk)
173
- : this[BUFFERPUSH](chunk)
174
- } else
229
+ if (this.flowing)
230
+ this.emit('data', chunk)
231
+ else
175
232
  this[BUFFERPUSH](chunk)
176
233
 
177
234
  if (this[BUFFERLENGTH] !== 0)
178
235
  this.emit('readable')
179
236
 
180
237
  if (cb)
181
- cb()
238
+ fn(cb)
182
239
 
183
240
  return this.flowing
184
241
  }
@@ -187,35 +244,31 @@ module.exports = class Minipass extends Stream {
187
244
  if (this[DESTROYED])
188
245
  return null
189
246
 
190
- try {
191
- if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH])
192
- return null
247
+ if (this[BUFFERLENGTH] === 0 || n === 0 || n > this[BUFFERLENGTH]) {
248
+ this[MAYBE_EMIT_END]()
249
+ return null
250
+ }
193
251
 
194
- if (this[OBJECTMODE])
195
- n = null
196
-
197
- if (this.buffer.length > 1 && !this[OBJECTMODE]) {
198
- if (this.encoding)
199
- this.buffer = new Yallist([
200
- Array.from(this.buffer).join('')
201
- ])
202
- else
203
- this.buffer = new Yallist([
204
- Buffer.concat(Array.from(this.buffer), this[BUFFERLENGTH])
205
- ])
206
- }
252
+ if (this[OBJECTMODE])
253
+ n = null
207
254
 
208
- return this[READ](n || null, this.buffer.head.value)
209
- } finally {
210
- this[MAYBE_EMIT_END]()
255
+ if (this.buffer.length > 1 && !this[OBJECTMODE]) {
256
+ if (this.encoding)
257
+ this.buffer = [this.buffer.join('')]
258
+ else
259
+ this.buffer = [Buffer.concat(this.buffer, this[BUFFERLENGTH])]
211
260
  }
261
+
262
+ const ret = this[READ](n || null, this.buffer[0])
263
+ this[MAYBE_EMIT_END]()
264
+ return ret
212
265
  }
213
266
 
214
267
  [READ] (n, chunk) {
215
268
  if (n === chunk.length || n === null)
216
269
  this[BUFFERSHIFT]()
217
270
  else {
218
- this.buffer.head.value = chunk.slice(n)
271
+ this.buffer[0] = chunk.slice(n)
219
272
  chunk = chunk.slice(0, n)
220
273
  this[BUFFERLENGTH] -= n
221
274
  }
@@ -291,7 +344,7 @@ module.exports = class Minipass extends Stream {
291
344
  this[BUFFERLENGTH] += 1
292
345
  else
293
346
  this[BUFFERLENGTH] += chunk.length
294
- return this.buffer.push(chunk)
347
+ this.buffer.push(chunk)
295
348
  }
296
349
 
297
350
  [BUFFERSHIFT] () {
@@ -299,7 +352,7 @@ module.exports = class Minipass extends Stream {
299
352
  if (this[OBJECTMODE])
300
353
  this[BUFFERLENGTH] -= 1
301
354
  else
302
- this[BUFFERLENGTH] -= this.buffer.head.value.length
355
+ this[BUFFERLENGTH] -= this.buffer[0].length
303
356
  }
304
357
  return this.buffer.shift()
305
358
  }
@@ -325,35 +378,52 @@ module.exports = class Minipass extends Stream {
325
378
  opts.end = false
326
379
  else
327
380
  opts.end = opts.end !== false
381
+ opts.proxyErrors = !!opts.proxyErrors
328
382
 
329
- const p = { dest: dest, opts: opts, ondrain: _ => this[RESUME]() }
330
- this.pipes.push(p)
331
-
332
- dest.on('drain', p.ondrain)
333
- this[RESUME]()
334
383
  // piping an ended stream ends immediately
335
- if (ended && p.opts.end)
336
- p.dest.end()
384
+ if (ended) {
385
+ if (opts.end)
386
+ dest.end()
387
+ } else {
388
+ this.pipes.push(!opts.proxyErrors ? new Pipe(this, dest, opts)
389
+ : new PipeProxyErrors(this, dest, opts))
390
+ if (this[ASYNC])
391
+ defer(() => this[RESUME]())
392
+ else
393
+ this[RESUME]()
394
+ }
395
+
337
396
  return dest
338
397
  }
339
398
 
399
+ unpipe (dest) {
400
+ const p = this.pipes.find(p => p.dest === dest)
401
+ if (p) {
402
+ this.pipes.splice(this.pipes.indexOf(p), 1)
403
+ p.unpipe()
404
+ }
405
+ }
406
+
340
407
  addListener (ev, fn) {
341
408
  return this.on(ev, fn)
342
409
  }
343
410
 
344
411
  on (ev, fn) {
345
- try {
346
- return super.on(ev, fn)
347
- } finally {
348
- if (ev === 'data' && !this.pipes.length && !this.flowing)
349
- this[RESUME]()
350
- else if (isEndish(ev) && this[EMITTED_END]) {
351
- super.emit(ev)
352
- this.removeAllListeners(ev)
353
- } else if (ev === 'error' && this[EMITTED_ERROR]) {
412
+ const ret = super.on(ev, fn)
413
+ if (ev === 'data' && !this.pipes.length && !this.flowing)
414
+ this[RESUME]()
415
+ else if (ev === 'readable' && this[BUFFERLENGTH] !== 0)
416
+ super.emit('readable')
417
+ else if (isEndish(ev) && this[EMITTED_END]) {
418
+ super.emit(ev)
419
+ this.removeAllListeners(ev)
420
+ } else if (ev === 'error' && this[EMITTED_ERROR]) {
421
+ if (this[ASYNC])
422
+ defer(() => fn.call(this, this[EMITTED_ERROR]))
423
+ else
354
424
  fn.call(this, this[EMITTED_ERROR])
355
- }
356
425
  }
426
+ return ret
357
427
  }
358
428
 
359
429
  get emittedEnd () {
@@ -376,65 +446,84 @@ module.exports = class Minipass extends Stream {
376
446
  }
377
447
  }
378
448
 
379
- emit (ev, data) {
449
+ emit (ev, data, ...extra) {
380
450
  // error and close are only events allowed after calling destroy()
381
451
  if (ev !== 'error' && ev !== 'close' && ev !== DESTROYED && this[DESTROYED])
382
452
  return
383
453
  else if (ev === 'data') {
384
- if (!data)
385
- return
386
-
387
- if (this.pipes.length)
388
- this.pipes.forEach(p =>
389
- p.dest.write(data) === false && this.pause())
454
+ return !data ? false
455
+ : this[ASYNC] ? defer(() => this[EMITDATA](data))
456
+ : this[EMITDATA](data)
390
457
  } else if (ev === 'end') {
391
- // only actual end gets this treatment
392
- if (this[EMITTED_END] === true)
393
- return
394
-
395
- this[EMITTED_END] = true
396
- this.readable = false
397
-
398
- if (this[DECODER]) {
399
- data = this[DECODER].end()
400
- if (data) {
401
- this.pipes.forEach(p => p.dest.write(data))
402
- super.emit('data', data)
403
- }
404
- }
405
-
406
- this.pipes.forEach(p => {
407
- p.dest.removeListener('drain', p.ondrain)
408
- if (p.opts.end)
409
- p.dest.end()
410
- })
458
+ return this[EMITEND]()
411
459
  } else if (ev === 'close') {
412
460
  this[CLOSED] = true
413
461
  // don't emit close before 'end' and 'finish'
414
462
  if (!this[EMITTED_END] && !this[DESTROYED])
415
463
  return
464
+ const ret = super.emit('close')
465
+ this.removeAllListeners('close')
466
+ return ret
416
467
  } else if (ev === 'error') {
417
468
  this[EMITTED_ERROR] = data
469
+ const ret = super.emit('error', data)
470
+ this[MAYBE_EMIT_END]()
471
+ return ret
472
+ } else if (ev === 'resume') {
473
+ const ret = super.emit('resume')
474
+ this[MAYBE_EMIT_END]()
475
+ return ret
476
+ } else if (ev === 'finish' || ev === 'prefinish') {
477
+ const ret = super.emit(ev)
478
+ this.removeAllListeners(ev)
479
+ return ret
418
480
  }
419
481
 
420
- // TODO: replace with a spread operator when Node v4 support drops
421
- const args = new Array(arguments.length)
422
- args[0] = ev
423
- args[1] = data
424
- if (arguments.length > 2) {
425
- for (let i = 2; i < arguments.length; i++) {
426
- args[i] = arguments[i]
482
+ // Some other unknown event
483
+ const ret = super.emit(ev, data, ...extra)
484
+ this[MAYBE_EMIT_END]()
485
+ return ret
486
+ }
487
+
488
+ [EMITDATA] (data) {
489
+ for (const p of this.pipes) {
490
+ if (p.dest.write(data) === false)
491
+ this.pause()
492
+ }
493
+ const ret = super.emit('data', data)
494
+ this[MAYBE_EMIT_END]()
495
+ return ret
496
+ }
497
+
498
+ [EMITEND] () {
499
+ if (this[EMITTED_END])
500
+ return
501
+
502
+ this[EMITTED_END] = true
503
+ this.readable = false
504
+ if (this[ASYNC])
505
+ defer(() => this[EMITEND2]())
506
+ else
507
+ this[EMITEND2]()
508
+ }
509
+
510
+ [EMITEND2] () {
511
+ if (this[DECODER]) {
512
+ const data = this[DECODER].end()
513
+ if (data) {
514
+ for (const p of this.pipes) {
515
+ p.dest.write(data)
516
+ }
517
+ super.emit('data', data)
427
518
  }
428
519
  }
429
520
 
430
- try {
431
- return super.emit.apply(this, args)
432
- } finally {
433
- if (!isEndish(ev))
434
- this[MAYBE_EMIT_END]()
435
- else
436
- this.removeAllListeners(ev)
521
+ for (const p of this.pipes) {
522
+ p.end()
437
523
  }
524
+ const ret = super.emit('end')
525
+ this.removeAllListeners('end')
526
+ return ret
438
527
  }
439
528
 
440
529
  // const all = await stream.collect()
@@ -536,7 +625,7 @@ module.exports = class Minipass extends Stream {
536
625
  this[DESTROYED] = true
537
626
 
538
627
  // throw away all buffered data, it's never coming out
539
- this.buffer = new Yallist()
628
+ this.buffer.length = 0
540
629
  this[BUFFERLENGTH] = 0
541
630
 
542
631
  if (typeof this.close === 'function' && !this[CLOSED])
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "minipass",
3
- "version": "3.1.6",
3
+ "version": "3.3.3",
4
4
  "description": "minimal implementation of a PassThrough stream",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "yallist": "^4.0.0"
8
8
  },
9
9
  "devDependencies": {
10
+ "@types/node": "^17.0.41",
10
11
  "end-of-stream": "^1.4.0",
11
- "tap": "^15.0.9",
12
- "through2": "^2.0.3"
12
+ "prettier": "^2.6.2",
13
+ "tap": "^16.2.0",
14
+ "through2": "^2.0.3",
15
+ "ts-node": "^10.8.1",
16
+ "typescript": "^4.7.3"
13
17
  },
14
18
  "scripts": {
15
19
  "test": "tap",
@@ -28,6 +32,7 @@
28
32
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
29
33
  "license": "ISC",
30
34
  "files": [
35
+ "index.d.ts",
31
36
  "index.js"
32
37
  ],
33
38
  "tap": {
@@ -35,5 +40,16 @@
35
40
  },
36
41
  "engines": {
37
42
  "node": ">=8"
43
+ },
44
+ "prettier": {
45
+ "semi": false,
46
+ "printWidth": 80,
47
+ "tabWidth": 2,
48
+ "useTabs": false,
49
+ "singleQuote": true,
50
+ "jsxSingleQuote": false,
51
+ "bracketSameLine": true,
52
+ "arrowParens": "avoid",
53
+ "endOfLine": "lf"
38
54
  }
39
55
  }