Skip to content
Permalink
Browse files

Require Node.js 8, add TypeScript definition (#4)

  • Loading branch information...
BendingBender authored and sindresorhus committed Mar 11, 2019
1 parent da6a608 commit 2eff2e8308216efeccd7dfa6f786be56160da54d
Showing with 32 additions and 10 deletions.
  1. +1 −2 .gitattributes
  2. +1 −1 .travis.yml
  3. +11 −0 index.d.ts
  4. +4 −1 index.js
  5. +7 −0 index.test-d.ts
  6. +8 −6 package.json
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
@@ -1,4 +1,4 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
@@ -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;
@@ -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;
@@ -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
);
@@ -10,13 +10,14 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd-check"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"stream",
@@ -33,8 +34,9 @@
"pull"
],
"devDependencies": {
"ava": "*",
"get-stream": "^3.0.0",
"xo": "*"
"ava": "^1.3.1",
"get-stream": "^4.1.0",
"tsd-check": "^0.3.0",
"xo": "^0.24.0"
}
}

0 comments on commit 2eff2e8

Please sign in to comment.
You can’t perform that action at this time.