muhammara 2.3.0 → 2.6.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/muhammara.d.ts +261 -242
  3. package/muhammara.js +1 -1
  4. package/node_modules/concat-map/package.json +1 -1
  5. package/node_modules/console-control-strings/package.json +1 -1
  6. package/node_modules/delegates/package.json +1 -1
  7. package/node_modules/fs.realpath/package.json +1 -1
  8. package/node_modules/glob/common.js +2 -0
  9. package/node_modules/glob/glob.js +4 -1
  10. package/node_modules/glob/package.json +9 -6
  11. package/node_modules/glob/sync.js +6 -3
  12. package/node_modules/has-unicode/package.json +1 -1
  13. package/node_modules/inflight/package.json +1 -1
  14. package/node_modules/minimatch/package.json +5 -5
  15. package/node_modules/minipass/LICENSE +1 -1
  16. package/node_modules/minipass/README.md +122 -7
  17. package/node_modules/minipass/index.d.ts +149 -0
  18. package/node_modules/minipass/index.js +191 -102
  19. package/node_modules/minipass/package.json +23 -7
  20. package/node_modules/object-assign/package.json +1 -1
  21. package/node_modules/once/package.json +1 -1
  22. package/node_modules/path-is-absolute/package.json +1 -1
  23. package/node_modules/set-blocking/package.json +1 -1
  24. package/node_modules/tr46/package.json +1 -1
  25. package/node_modules/util-deprecate/package.json +1 -1
  26. package/node_modules/webidl-conversions/package.json +1 -1
  27. package/node_modules/whatwg-url/package.json +1 -1
  28. package/node_modules/wrappy/package.json +1 -1
  29. package/package.json +2 -1
  30. package/src/DocumentCopyingContextDriver.cpp +9 -9
  31. package/src/ObjectByteWriterWithPosition.cpp +15 -7
  32. package/src/ObjectsContextDriver.cpp +1 -1
  33. package/src/deps/PDFWriter/PDFDocumentHandler.cpp +4 -0
package/muhammara.js CHANGED
@@ -15,7 +15,7 @@ muhammara.PDFWriter.prototype.getEvents = function() {
15
15
  return this.events;
16
16
  }
17
17
 
18
- muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function(eventName,eventParams) {
18
+ muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function(eventName, eventParams) {
19
19
  eventParams.writer = this;
20
20
  this.getEvents().emit(eventName,eventParams);
21
21
  }
@@ -2,7 +2,7 @@
2
2
  "_from": "concat-map@0.0.1",
3
3
  "_id": "concat-map@0.0.1",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
5
+ "_integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
6
6
  "_location": "/concat-map",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -2,7 +2,7 @@
2
2
  "_from": "console-control-strings@^1.1.0",
3
3
  "_id": "console-control-strings@1.1.0",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
5
+ "_integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==",
6
6
  "_location": "/console-control-strings",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -2,7 +2,7 @@
2
2
  "_from": "delegates@^1.0.0",
3
3
  "_id": "delegates@1.0.0",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
5
+ "_integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==",
6
6
  "_location": "/delegates",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -2,7 +2,7 @@
2
2
  "_from": "fs.realpath@^1.0.0",
3
3
  "_id": "fs.realpath@1.0.0",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
5
+ "_integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
6
6
  "_location": "/fs.realpath",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -110,6 +110,8 @@ function setopts (self, pattern, options) {
110
110
  // Note that they are not supported in Glob itself anyway.
111
111
  options.nonegate = true
112
112
  options.nocomment = true
113
+ // always treat \ in patterns as escapes, not path separators
114
+ options.allowWindowsEscape = false
113
115
 
114
116
  self.minimatch = new Minimatch(pattern, options)
115
117
  self.options = self.minimatch.options
@@ -342,7 +342,10 @@ Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
342
342
  var read
343
343
  if (prefix === null)
344
344
  read = '.'
345
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
345
+ else if (isAbsolute(prefix) ||
346
+ isAbsolute(pattern.map(function (p) {
347
+ return typeof p === 'string' ? p : '[*]'
348
+ }).join('/'))) {
346
349
  if (!prefix || !isAbsolute(prefix))
347
350
  prefix = '/' + prefix
348
351
  read = prefix
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "glob@^7.1.3",
3
- "_id": "glob@7.2.0",
3
+ "_id": "glob@7.2.3",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
5
+ "_integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
6
6
  "_location": "/glob",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -18,8 +18,8 @@
18
18
  "_requiredBy": [
19
19
  "/rimraf"
20
20
  ],
21
- "_resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
22
- "_shasum": "d15535af7732e02e948f4c41628bd910293f6023",
21
+ "_resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
22
+ "_shasum": "b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b",
23
23
  "_spec": "glob@^7.1.3",
24
24
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/rimraf",
25
25
  "author": {
@@ -35,7 +35,7 @@
35
35
  "fs.realpath": "^1.0.0",
36
36
  "inflight": "^1.0.4",
37
37
  "inherits": "2",
38
- "minimatch": "^3.0.4",
38
+ "minimatch": "^3.1.1",
39
39
  "once": "^1.3.0",
40
40
  "path-is-absolute": "^1.0.0"
41
41
  },
@@ -63,6 +63,9 @@
63
63
  "license": "ISC",
64
64
  "main": "glob.js",
65
65
  "name": "glob",
66
+ "publishConfig": {
67
+ "tag": "v7-legacy"
68
+ },
66
69
  "repository": {
67
70
  "type": "git",
68
71
  "url": "git://github.com/isaacs/node-glob.git"
@@ -81,5 +84,5 @@
81
84
  "after": "test/zz-cleanup.js",
82
85
  "jobs": 1
83
86
  },
84
- "version": "7.2.0"
87
+ "version": "7.2.3"
85
88
  }
@@ -48,7 +48,7 @@ function GlobSync (pattern, options) {
48
48
  }
49
49
 
50
50
  GlobSync.prototype._finish = function () {
51
- assert(this instanceof GlobSync)
51
+ assert.ok(this instanceof GlobSync)
52
52
  if (this.realpath) {
53
53
  var self = this
54
54
  this.matches.forEach(function (matchset, index) {
@@ -72,7 +72,7 @@ GlobSync.prototype._finish = function () {
72
72
 
73
73
 
74
74
  GlobSync.prototype._process = function (pattern, index, inGlobStar) {
75
- assert(this instanceof GlobSync)
75
+ assert.ok(this instanceof GlobSync)
76
76
 
77
77
  // Get the first [n] parts of pattern that are all strings.
78
78
  var n = 0
@@ -109,7 +109,10 @@ GlobSync.prototype._process = function (pattern, index, inGlobStar) {
109
109
  var read
110
110
  if (prefix === null)
111
111
  read = '.'
112
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
112
+ else if (isAbsolute(prefix) ||
113
+ isAbsolute(pattern.map(function (p) {
114
+ return typeof p === 'string' ? p : '[*]'
115
+ }).join('/'))) {
113
116
  if (!prefix || !isAbsolute(prefix))
114
117
  prefix = '/' + prefix
115
118
  read = prefix
@@ -2,7 +2,7 @@
2
2
  "_from": "has-unicode@^2.0.1",
3
3
  "_id": "has-unicode@2.0.1",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=",
5
+ "_integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==",
6
6
  "_location": "/has-unicode",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -2,7 +2,7 @@
2
2
  "_from": "inflight@^1.0.4",
3
3
  "_id": "inflight@1.0.6",
4
4
  "_inBundle": false,
5
- "_integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
5
+ "_integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
6
6
  "_location": "/inflight",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "_from": "minimatch@^3.0.4",
2
+ "_from": "minimatch@^3.1.1",
3
3
  "_id": "minimatch@3.1.2",
4
4
  "_inBundle": false,
5
5
  "_integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
@@ -8,19 +8,19 @@
8
8
  "_requested": {
9
9
  "type": "range",
10
10
  "registry": true,
11
- "raw": "minimatch@^3.0.4",
11
+ "raw": "minimatch@^3.1.1",
12
12
  "name": "minimatch",
13
13
  "escapedName": "minimatch",
14
- "rawSpec": "^3.0.4",
14
+ "rawSpec": "^3.1.1",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^3.0.4"
16
+ "fetchSpec": "^3.1.1"
17
17
  },
18
18
  "_requiredBy": [
19
19
  "/glob"
20
20
  ],
21
21
  "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
22
22
  "_shasum": "19cd194bfd3e428f049a70817c038d89ab4be35b",
23
- "_spec": "minimatch@^3.0.4",
23
+ "_spec": "minimatch@^3.1.1",
24
24
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/glob",
25
25
  "author": {
26
26
  "name": "Isaac Z. Schlueter",
@@ -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
@@ -17,9 +17,6 @@ from this stream via `'data'` events or by calling `pipe()` into some other
17
17
  stream. Calling `read()` requires the buffer to be flattened in some
18
18
  cases, which requires copying memory.
19
19
 
20
- There is also no `unpipe()` method. Once you start piping, there is no
21
- stopping it!
22
-
23
20
  If you set `objectMode: true` in the options, then whatever is written will
24
21
  be emitted. Otherwise, it'll do a minimal amount of Buffer copying to
25
22
  ensure proper Streams semantics when `read(n)` is called.
@@ -63,6 +60,10 @@ some ways superior to) Node.js core streams.
63
60
  Please read these caveats if you are familiar with node-core streams and
64
61
  intend to use Minipass streams in your programs.
65
62
 
63
+ You can avoid most of these differences entirely (for a very
64
+ small performance penalty) by setting `{async: true}` in the
65
+ constructor options.
66
+
66
67
  ### Timing
67
68
 
68
69
  Minipass streams are designed to support synchronous use-cases. Thus, data
@@ -82,6 +83,82 @@ This non-deferring approach makes Minipass streams much easier to reason
82
83
  about, especially in the context of Promises and other flow-control
83
84
  mechanisms.
84
85
 
86
+ Example:
87
+
88
+ ```js
89
+ const Minipass = require('minipass')
90
+ const stream = new Minipass({ async: true })
91
+ stream.on('data', () => console.log('data event'))
92
+ console.log('before write')
93
+ stream.write('hello')
94
+ console.log('after write')
95
+ // output:
96
+ // before write
97
+ // data event
98
+ // after write
99
+ ```
100
+
101
+ ### Exception: Async Opt-In
102
+
103
+ If you wish to have a Minipass stream with behavior that more
104
+ closely mimics Node.js core streams, you can set the stream in
105
+ async mode either by setting `async: true` in the constructor
106
+ options, or by setting `stream.async = true` later on.
107
+
108
+ ```js
109
+ const Minipass = require('minipass')
110
+ const asyncStream = new Minipass({ async: true })
111
+ asyncStream.on('data', () => console.log('data event'))
112
+ console.log('before write')
113
+ asyncStream.write('hello')
114
+ console.log('after write')
115
+ // output:
116
+ // before write
117
+ // after write
118
+ // data event <-- this is deferred until the next tick
119
+ ```
120
+
121
+ Switching _out_ of async mode is unsafe, as it could cause data
122
+ corruption, and so is not enabled. Example:
123
+
124
+ ```js
125
+ const Minipass = require('minipass')
126
+ const stream = new Minipass({ encoding: 'utf8' })
127
+ stream.on('data', chunk => console.log(chunk))
128
+ stream.async = true
129
+ console.log('before writes')
130
+ stream.write('hello')
131
+ setStreamSyncAgainSomehow(stream) // <-- this doesn't actually exist!
132
+ stream.write('world')
133
+ console.log('after writes')
134
+ // hypothetical output would be:
135
+ // before writes
136
+ // world
137
+ // after writes
138
+ // hello
139
+ // NOT GOOD!
140
+ ```
141
+
142
+ To avoid this problem, once set into async mode, any attempt to
143
+ make the stream sync again will be ignored.
144
+
145
+ ```js
146
+ const Minipass = require('minipass')
147
+ const stream = new Minipass({ encoding: 'utf8' })
148
+ stream.on('data', chunk => console.log(chunk))
149
+ stream.async = true
150
+ console.log('before writes')
151
+ stream.write('hello')
152
+ stream.async = false // <-- no-op, stream already async
153
+ stream.write('world')
154
+ console.log('after writes')
155
+ // actual output:
156
+ // before writes
157
+ // after writes
158
+ // hello
159
+ // world
160
+ ```
161
+
85
162
  ### No High/Low Water Marks
86
163
 
87
164
  Node.js core streams will optimistically fill up a buffer, returning `true`
@@ -97,6 +174,9 @@ If the data has nowhere to go, then `write()` returns false, and the data
97
174
  sits in a buffer, to be drained out immediately as soon as anyone consumes
98
175
  it.
99
176
 
177
+ Since nothing is ever buffered unnecessarily, there is much less
178
+ copying data, and less bookkeeping about buffer capacity levels.
179
+
100
180
  ### Hazards of Buffering (or: Why Minipass Is So Fast)
101
181
 
102
182
  Since data written to a Minipass stream is immediately written all the way
@@ -181,6 +261,8 @@ moving on to the next entry in an archive parse stream, etc.) then be sure
181
261
  to call `stream.pause()` on creation, and then `stream.resume()` once you
182
262
  are ready to respond to the `end` event.
183
263
 
264
+ However, this is _usually_ not a problem because:
265
+
184
266
  ### Emit `end` When Asked
185
267
 
186
268
  One hazard of immediately emitting `'end'` is that you may not yet have had
@@ -197,6 +279,18 @@ To prevent calling handlers multiple times who would not expect multiple
197
279
  ends to occur, all listeners are removed from the `'end'` event whenever it
198
280
  is emitted.
199
281
 
282
+ ### Emit `error` When Asked
283
+
284
+ The most recent error object passed to the `'error'` event is
285
+ stored on the stream. If a new `'error'` event handler is added,
286
+ and an error was previously emitted, then the event handler will
287
+ be called immediately (or on `process.nextTick` in the case of
288
+ async streams).
289
+
290
+ This makes it much more difficult to end up trying to interact
291
+ with a broken stream, if the error handler is added after an
292
+ error was previously emitted.
293
+
200
294
  ### Impact of "immediate flow" on Tee-streams
201
295
 
202
296
  A "tee stream" is a stream piping to multiple destinations:
@@ -221,7 +315,7 @@ src.pipe(dest1) // 'foo' chunk flows to dest1 immediately, and is gone
221
315
  src.pipe(dest2) // gets nothing!
222
316
  ```
223
317
 
224
- The solution is to create a dedicated tee-stream junction that pipes to
318
+ One solution is to create a dedicated tee-stream junction that pipes to
225
319
  both locations, and then pipe to _that_ instead.
226
320
 
227
321
  ```js
@@ -258,6 +352,13 @@ tee.on('data', handler2)
258
352
  src.pipe(tee)
259
353
  ```
260
354
 
355
+ All of the hazards in this section are avoided by setting `{
356
+ async: true }` in the Minipass constructor, or by setting
357
+ `stream.async = true` afterwards. Note that this does add some
358
+ overhead, so should only be done in cases where you are willing
359
+ to lose a bit of performance in order to avoid having to refactor
360
+ program logic.
361
+
261
362
  ## USAGE
262
363
 
263
364
  It's a stream! Use it like a stream and it'll most likely do what you
@@ -279,6 +380,10 @@ mp.end('bar')
279
380
  by default if you write() something other than a string or Buffer at any
280
381
  point. Setting `objectMode: true` will prevent setting any encoding
281
382
  value.
383
+ * `async` Defaults to `false`. Set to `true` to defer data
384
+ emission until next tick. This reduces performance slightly,
385
+ but makes Minipass streams use timing behavior closer to Node
386
+ core streams. See [Timing](#timing) for more details.
282
387
 
283
388
  ### API
284
389
 
@@ -300,9 +405,19 @@ streams.
300
405
  from being emitted for empty streams until the stream is resumed.
301
406
  * `resume()` - Resume the stream. If there's data in the buffer, it is all
302
407
  discarded. Any buffered events are immediately emitted.
303
- * `pipe(dest)` - Send all output to the stream provided. There is no way
304
- to unpipe. When data is emitted, it is immediately written to any and
305
- all pipe destinations.
408
+ * `pipe(dest)` - Send all output to the stream provided. When
409
+ data is emitted, it is immediately written to any and all pipe
410
+ destinations. (Or written on next tick in `async` mode.)
411
+ * `unpipe(dest)` - Stop piping to the destination stream. This
412
+ is immediate, meaning that any asynchronously queued data will
413
+ _not_ make it to the destination when running in `async` mode.
414
+ * `options.end` - Boolean, end the destination stream when
415
+ the source stream ends. Default `true`.
416
+ * `options.proxyErrors` - Boolean, proxy `error` events from
417
+ the source stream to the destination stream. Note that
418
+ errors are _not_ proxied after the pipeline terminates,
419
+ either due to the source emitting `'end'` or manually
420
+ unpiping with `src.unpipe(dest)`. Default `false`.
306
421
  * `on(ev, fn)`, `emit(ev, fn)` - Minipass streams are EventEmitters. Some
307
422
  events are given special treatment, however. (See below under "events".)
308
423
  * `promise()` - Returns a Promise that resolves when the stream emits
@@ -0,0 +1,149 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events'
3
+ import { Stream } from 'stream'
4
+
5
+ export type Encoding = BufferEncoding | 'buffer' | null
6
+
7
+ interface Writable extends EventEmitter {
8
+ end(): any
9
+ write(chunk: any, ...args: any[]): any
10
+ }
11
+
12
+ interface Readable extends EventEmitter {
13
+ pause(): any
14
+ resume(): any
15
+ pipe(): any
16
+ }
17
+
18
+ interface Pipe<R, W> {
19
+ src: Minipass<R, W>
20
+ dest: Writable
21
+ opts: PipeOptions
22
+ }
23
+
24
+ type DualIterable<T> = Iterable<T> & AsyncIterable<T>
25
+
26
+ type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string
27
+
28
+ type BufferOrString = Buffer | string
29
+
30
+ export default class Minipass<
31
+ RType extends any = Buffer,
32
+ WType extends any = RType extends BufferOrString ? ContiguousData : RType
33
+ >
34
+ extends Stream
35
+ implements DualIterable<RType>
36
+ {
37
+ static isStream(stream: any): stream is Readable | Writable
38
+
39
+ readonly bufferLength: number
40
+ readonly flowing: boolean
41
+ readonly writable: boolean
42
+ readonly readable: boolean
43
+ readonly paused: boolean
44
+ readonly emittedEnd: boolean
45
+ readonly destroyed: boolean
46
+
47
+ /**
48
+ * Not technically private or readonly, but not safe to mutate.
49
+ */
50
+ private readonly buffer: RType[]
51
+ private readonly pipes: Pipe<RType, WType>[]
52
+
53
+ /**
54
+ * Technically writable, but mutating it can change the type,
55
+ * so is not safe to do in TypeScript.
56
+ */
57
+ readonly objectMode: boolean
58
+ async: boolean
59
+
60
+ /**
61
+ * Note: encoding is not actually read-only, and setEncoding(enc)
62
+ * exists. However, this type definition will insist that TypeScript
63
+ * programs declare the type of a Minipass stream up front, and if
64
+ * that type is string, then an encoding MUST be set in the ctor. If
65
+ * the type is Buffer, then the encoding must be missing, or set to
66
+ * 'buffer' or null. If the type is anything else, then objectMode
67
+ * must be set in the constructor options. So there is effectively
68
+ * no allowed way that a TS program can set the encoding after
69
+ * construction, as doing so will destroy any hope of type safety.
70
+ * TypeScript does not provide many options for changing the type of
71
+ * an object at run-time, which is what changing the encoding does.
72
+ */
73
+ readonly encoding: Encoding
74
+ // setEncoding(encoding: Encoding): void
75
+
76
+ // Options required if not reading buffers
77
+ constructor(
78
+ ...args: RType extends Buffer
79
+ ? [] | [Options<RType>]
80
+ : [Options<RType>]
81
+ )
82
+
83
+ write(chunk: WType, cb?: () => void): boolean
84
+ write(chunk: WType, encoding?: Encoding, cb?: () => void): boolean
85
+ read(size?: number): RType
86
+ end(cb?: () => void): this
87
+ end(chunk: any, cb?: () => void): this
88
+ end(chunk: any, encoding?: Encoding, cb?: () => void): this
89
+ pause(): void
90
+ resume(): void
91
+ promise(): Promise<void>
92
+ collect(): Promise<RType[]>
93
+
94
+ concat(): RType extends BufferOrString ? Promise<RType> : never
95
+ destroy(er?: any): void
96
+ pipe<W extends Writable>(dest: W, opts?: PipeOptions): W
97
+ unpipe<W extends Writable>(dest: W): void
98
+
99
+ /**
100
+ * alias for on()
101
+ */
102
+ addEventHandler(event: string, listener: (...args: any[]) => any): this
103
+
104
+ on(event: string, listener: (...args: any[]) => any): this
105
+ on(event: 'data', listener: (chunk: RType) => any): this
106
+ on(event: 'error', listener: (error: any) => any): this
107
+ on(
108
+ event:
109
+ | 'readable'
110
+ | 'drain'
111
+ | 'resume'
112
+ | 'end'
113
+ | 'prefinish'
114
+ | 'finish'
115
+ | 'close',
116
+ listener: () => any
117
+ ): this
118
+
119
+ [Symbol.iterator](): Iterator<RType>
120
+ [Symbol.asyncIterator](): AsyncIterator<RType>
121
+ }
122
+
123
+ interface StringOptions {
124
+ encoding: BufferEncoding
125
+ objectMode?: boolean
126
+ async?: boolean
127
+ }
128
+
129
+ interface BufferOptions {
130
+ encoding?: null | 'buffer'
131
+ objectMode?: boolean
132
+ async?: boolean
133
+ }
134
+
135
+ interface ObjectModeOptions {
136
+ objectMode: true
137
+ async?: boolean
138
+ }
139
+
140
+ export declare interface PipeOptions {
141
+ end?: boolean
142
+ proxyErrors?: boolean
143
+ }
144
+
145
+ export declare type Options<T> = T extends string
146
+ ? StringOptions
147
+ : T extends Buffer
148
+ ? BufferOptions
149
+ : ObjectModeOptions