|
1 | 1 | /// <reference types="node"/> |
2 | 2 | import {Readable as ReadableStream} from 'stream'; |
3 | 3 |
|
4 | | -export interface Options { |
5 | | - /** |
6 | | - * The total size to be produced by the stream in bytes. |
7 | | - * |
8 | | - * @default Infinity |
9 | | - */ |
10 | | - readonly size?: number; |
| 4 | +declare namespace randomBytesReadableStream { |
| 5 | + interface Options { |
| 6 | + /** |
| 7 | + The total size to be produced by the stream in bytes. |
| 8 | +
|
| 9 | + @default Infinity |
| 10 | + */ |
| 11 | + readonly size?: number; |
| 12 | + } |
11 | 13 | } |
12 | 14 |
|
13 | | -/** |
14 | | - * Creates a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) producing cryptographically strong pseudo-random data using [`crypto.randomBytes()`](https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback). |
15 | | - * |
16 | | - * @returns By default, infinite data. |
17 | | - */ |
18 | | -export default function randomBytesReadableStream(options?: Options): ReadableStream; |
| 15 | +declare const randomBytesReadableStream: { |
| 16 | + /** |
| 17 | + Creates a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) producing cryptographically strong pseudo-random data using [`crypto.randomBytes()`](https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback). |
| 18 | +
|
| 19 | + @returns By default, infinite data. |
| 20 | +
|
| 21 | + @example |
| 22 | + ``` |
| 23 | + import randomBytesReadableStream = require('random-bytes-readable-stream'); |
| 24 | +
|
| 25 | + randomBytesReadableStream({size: 10}).pipe(process.stdout); |
| 26 | + ``` |
| 27 | + */ |
| 28 | + (options?: randomBytesReadableStream.Options): ReadableStream; |
| 29 | + |
| 30 | + // TODO: Remove this for the next major release, refactor the whole definition to: |
| 31 | + // declare function randomBytesReadableStream( |
| 32 | + // options?: randomBytesReadableStream.Options |
| 33 | + // ): ReadableStream; |
| 34 | + // export = randomBytesReadableStream; |
| 35 | + default: typeof randomBytesReadableStream; |
| 36 | +}; |
| 37 | + |
| 38 | +export = randomBytesReadableStream; |
0 commit comments