-
-
Notifications
You must be signed in to change notification settings - Fork 14
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 8, add TypeScript definition (#4)
- Loading branch information
1 parent
da6a608
commit 2eff2e8
Showing
6 changed files
with
32 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
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,4 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// <reference types="node"/> | ||
import {Readable as ReadableStream} from 'stream'; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
export default function toReadableStream( | ||
input: string | Buffer | Uint8Array | ||
): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
'use strict'; | ||
const {Readable: ReadableStream} = require('stream'); | ||
|
||
module.exports = input => ( | ||
const toReadableStream = input => ( | ||
new ReadableStream({ | ||
read() { | ||
this.push(input); | ||
this.push(null); | ||
} | ||
}) | ||
); | ||
|
||
module.exports = toReadableStream; | ||
module.exports.default = toReadableStream; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import toReadableStream from '.'; | ||
|
||
toReadableStream('🦄🌈').pipe(process.stdout); | ||
toReadableStream(Buffer.from('🦄🌈')).pipe(process.stdout); | ||
toReadableStream(new Uint8Array(Buffer.from('🦄🌈').buffer)).pipe( | ||
process.stdout | ||
); |
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