to-readable-stream
Advanced tools
+11
-23
@@ -1,27 +0,15 @@ | ||
| /// <reference types="node"/> | ||
| import {Readable as ReadableStream} from 'stream'; | ||
| import {Readable as ReadableStream} from 'node:stream'; | ||
| declare const toReadableStream: { | ||
| /** | ||
| Convert a `string`/`Buffer`/`Uint8Array` to a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams). | ||
| /** | ||
| Convert a `string`/`Buffer`/`Uint8Array` to a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams). | ||
| @param input - Value to convert to a stream. | ||
| @param value - Value to convert to a stream. | ||
| @example | ||
| ``` | ||
| import toReadableStream = require('to-readable-stream'); | ||
| @example | ||
| ``` | ||
| import toReadableStream from 'to-readable-stream'; | ||
| toReadableStream('🦄🌈').pipe(process.stdout); | ||
| ``` | ||
| */ | ||
| (input: string | Buffer | Uint8Array): ReadableStream; | ||
| // TODO: Remove this for the next major release, refactor the whole definition to: | ||
| // declare function toReadableStream( | ||
| // input: string | Buffer | Uint8Array | ||
| // ): ReadableStream; | ||
| // export = toReadableStream; | ||
| default: typeof toReadableStream; | ||
| }; | ||
| export = toReadableStream; | ||
| toReadableStream('🦄🌈').pipe(process.stdout); | ||
| ``` | ||
| */ | ||
| export default function toReadableStream(value: string | Buffer | Uint8Array): ReadableStream; |
+6
-11
@@ -1,15 +0,10 @@ | ||
| 'use strict'; | ||
| const {Readable: ReadableStream} = require('stream'); | ||
| import {Readable as ReadableStream} from 'node:stream'; | ||
| const toReadableStream = input => ( | ||
| new ReadableStream({ | ||
| export default function toReadableStream(value) { | ||
| return new ReadableStream({ | ||
| read() { | ||
| this.push(input); | ||
| this.push(value); | ||
| this.push(null); | ||
| } | ||
| }) | ||
| ); | ||
| module.exports = toReadableStream; | ||
| // TODO: Remove this for the next major release | ||
| module.exports.default = toReadableStream; | ||
| }); | ||
| } |
+10
-7
| { | ||
| "name": "to-readable-stream", | ||
| "version": "2.1.0", | ||
| "version": "3.0.0", | ||
| "description": "Convert a string/Buffer/Uint8Array to a readable stream", | ||
| "license": "MIT", | ||
| "repository": "sindresorhus/to-readable-stream", | ||
| "funding": "https://github.com/sponsors/sindresorhus", | ||
| "author": { | ||
| "name": "Sindre Sorhus", | ||
| "email": "sindresorhus@gmail.com", | ||
| "url": "sindresorhus.com" | ||
| "url": "https://sindresorhus.com" | ||
| }, | ||
| "type": "module", | ||
| "exports": "./index.js", | ||
| "engines": { | ||
| "node": ">=8" | ||
| "node": ">=12" | ||
| }, | ||
@@ -37,7 +40,7 @@ "scripts": { | ||
| "devDependencies": { | ||
| "ava": "^1.4.1", | ||
| "get-stream": "^5.0.0", | ||
| "tsd": "^0.7.2", | ||
| "xo": "^0.24.0" | ||
| "ava": "^3.15.0", | ||
| "get-stream": "^6.0.1", | ||
| "tsd": "^0.14.0", | ||
| "xo": "^0.39.1" | ||
| } | ||
| } |
+16
-11
@@ -1,5 +0,6 @@ | ||
| # to-readable-stream [](https://travis-ci.org/sindresorhus/to-readable-stream) | ||
| # to-readable-stream | ||
| > Convert a string/Buffer/Uint8Array to a [readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) | ||
| If you target Node.js 12 or later, you can use [`stream.Readable#from()`](https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options) instead. | ||
@@ -12,7 +13,6 @@ ## Install | ||
| ## Usage | ||
| ```js | ||
| const toReadableStream = require('to-readable-stream'); | ||
| import toReadableStream from 'to-readable-stream'; | ||
@@ -22,16 +22,14 @@ toReadableStream('🦄🌈').pipe(process.stdout); | ||
| ## API | ||
| ### toReadableStream(input) | ||
| ### toReadableStream(value) | ||
| Returns a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams). | ||
| #### input | ||
| #### value | ||
| Type: `string` `Buffer` `Uint8Array` | ||
| Type: `string | Buffer | Uint8Array` | ||
| Value to convert to a stream. | ||
| ## Related | ||
@@ -41,5 +39,12 @@ | ||
| --- | ||
| ## License | ||
| MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
| <div align="center"> | ||
| <b> | ||
| <a href="https://tidelift.com/subscription/pkg/npm-to-readable-stream?utm_source=npm-to-readable-stream&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
| </b> | ||
| <br> | ||
| <sub> | ||
| Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
| </sub> | ||
| </div> |
Sorry, the diff of this file is not supported yet
3853
2.2%48
11.63%Yes
NaN20
-41.18%