1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
4 | * This code may only be used under the BSD style license found at
|
5 | * http://polymer.github.io/LICENSE.txt
|
6 | * The complete set of authors may be found at
|
7 | * http://polymer.github.io/AUTHORS.txt
|
8 | * The complete set of contributors may be found at
|
9 | * http://polymer.github.io/CONTRIBUTORS.txt
|
10 | * Code distributed by Google as part of the polymer project is also
|
11 | * subject to an additional IP rights grant found at
|
12 | * http://polymer.github.io/PATENTS.txt
|
13 | */
|
14 | /// <reference types="node" />
|
15 | /// <reference types="vinyl-fs" />
|
16 | import { Transform, TransformCallback } from 'stream';
|
17 | import File = require('vinyl');
|
18 | /**
|
19 | * Waits for the given ReadableStream
|
20 | */
|
21 | export declare function waitFor(stream: NodeJS.ReadableStream): Promise<NodeJS.ReadableStream>;
|
22 | /**
|
23 | * Waits for all the given ReadableStreams
|
24 | */
|
25 | export declare function waitForAll(streams: NodeJS.ReadableStream[]): Promise<NodeJS.ReadableStream[]>;
|
26 | /**
|
27 | * Returns the string contents of a Vinyl File object, waiting for
|
28 | * all chunks if the File is a stream.
|
29 | */
|
30 | export declare function getFileContents(file: File): Promise<string>;
|
31 | /**
|
32 | * Composes multiple streams (or Transforms) into one.
|
33 | */
|
34 | export declare function compose(streams: NodeJS.ReadWriteStream[]): any;
|
35 | /**
|
36 | * Implements `stream.Transform` via standard async iteration.
|
37 | *
|
38 | * The main advantage over implementing stream.Transform itself is that correct
|
39 | * error handling is built in and easy to get right, simply by using
|
40 | * async/await.
|
41 | *
|
42 | * `In` and `Out` extend `{}` because they may not be `null`.
|
43 | */
|
44 | export declare abstract class AsyncTransformStream<In extends {}, Out extends {}> extends Transform {
|
45 | private readonly _inputs;
|
46 | /**
|
47 | * Implement this method!
|
48 | *
|
49 | * Read from the given iterator to consume input, yield values to write
|
50 | * chunks of your own. You may yield any number of values for each input.
|
51 | *
|
52 | * Note: currently you *must* completely consume `inputs` and return for this
|
53 | * stream to close.
|
54 | */
|
55 | protected abstract _transformIter(inputs: AsyncIterable<In>): AsyncIterable<Out>;
|
56 | private _initialized;
|
57 | private _writingFinished;
|
58 | private _initializeOnce;
|
59 | /**
|
60 | * Don't override.
|
61 | *
|
62 | * Passes input into this._inputs.
|
63 | */
|
64 | _transform(input: In, _encoding: string, callback: (error?: Error, value?: Out) => void): void;
|
65 | /**
|
66 | * Don't override.
|
67 | *
|
68 | * Finish writing out the outputs.
|
69 | */
|
70 | _flush(callback: TransformCallback): Promise<void>;
|
71 | }
|
72 | /**
|
73 | * A stream that takes file path strings, and outputs full Vinyl file objects
|
74 | * for the file at each location.
|
75 | */
|
76 | export declare class VinylReaderTransform extends AsyncTransformStream<string, File> {
|
77 | constructor();
|
78 | protected _transformIter(paths: AsyncIterable<string>): AsyncIterable<File>;
|
79 | }
|
80 | export declare type PipeStream = (NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadableStream[] | NodeJS.WritableStream[]);
|
81 | /**
|
82 | * pipeStreams() takes in a collection streams and pipes them together,
|
83 | * returning the last stream in the pipeline. Each element in the `streams`
|
84 | * array must be either a stream, or an array of streams (see PipeStream).
|
85 | * pipeStreams() will then flatten this array before piping them all together.
|
86 | */
|
87 | export declare function pipeStreams(streams: PipeStream[]): NodeJS.ReadableStream;
|