-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
0a04c26
commit ae9b4c5
Showing
8 changed files
with
44 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,24 @@ | ||
/// <reference types="node"/> | ||
import {Readable as ReadableStream} from 'stream'; | ||
import {Readable as ReadableStream} from 'node:stream'; | ||
|
||
declare namespace randomBytesReadableStream { | ||
interface Options { | ||
/** | ||
The total size to be produced by the stream in bytes. | ||
@default Infinity | ||
*/ | ||
readonly size?: number; | ||
} | ||
} | ||
|
||
declare const randomBytesReadableStream: { | ||
export interface Options { | ||
/** | ||
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). | ||
The total size to be produced by the stream in bytes. | ||
@returns By default, infinite data. | ||
@default Infinity | ||
*/ | ||
readonly size?: number; | ||
} | ||
|
||
@example | ||
``` | ||
import randomBytesReadableStream = require('random-bytes-readable-stream'); | ||
/** | ||
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). | ||
randomBytesReadableStream({size: 10}).pipe(process.stdout); | ||
``` | ||
*/ | ||
(options?: randomBytesReadableStream.Options): ReadableStream; | ||
@returns By default, infinite data. | ||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function randomBytesReadableStream( | ||
// options?: randomBytesReadableStream.Options | ||
// ): ReadableStream; | ||
// export = randomBytesReadableStream; | ||
default: typeof randomBytesReadableStream; | ||
}; | ||
@example | ||
``` | ||
import randomBytesReadableStream from 'random-bytes-readable-stream'; | ||
export = randomBytesReadableStream; | ||
randomBytesReadableStream({size: 10}).pipe(process.stdout); | ||
``` | ||
*/ | ||
export default function randomBytesReadableStream(options?: Options): ReadableStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import randomBytesReadableStream = require('.'); | ||
import process from 'node:process'; | ||
import randomBytesReadableStream from './index.js'; | ||
|
||
randomBytesReadableStream().pipe(process.stdout); | ||
randomBytesReadableStream({size: 50}).pipe(process.stdout); | ||
randomBytesReadableStream().pipe(process.stdout); // eslint-disable-line @typescript-eslint/no-unsafe-member-access | ||
randomBytesReadableStream({size: 50}).pipe(process.stdout); // eslint-disable-line @typescript-eslint/no-unsafe-member-access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters