add stream-to-promise pkg

Signed-off-by: Arturas Molcanovas <a.molcanovas@gmail.com>
This commit is contained in:
Arturas Molcanovas
2018-03-01 22:29:57 +00:00
parent 3f14b7a252
commit e5472a24cf
4 changed files with 55 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for stream-to-promise 2.2
// Project: https://github.com/bendrucker/stream-to-promise
// Definitions by: Alorel <https://github.com/Alorel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
/**
* Return a promise which resolves when the input stream ends
* @param stream The input stream
* @returns A promise containing the stream output as a buffer
*/
declare function streamToPromise(stream: NodeJS.ReadableStream): Promise<Buffer>;
/**
* Return s promise which resolves when the input stream ends
* @param stream The input stream
*/
declare function streamToPromise(stream: NodeJS.WritableStream): Promise<void>;
declare namespace streamToPromise {} // Add a namespace so we can do import * instead of import x = require()
export = streamToPromise;
@@ -0,0 +1,8 @@
import * as stp from 'stream-to-promise';
import * as fs from 'fs';
const read = fs.createReadStream(__filename);
const write = fs.createWriteStream(__filename);
const read$: Promise<Buffer> = stp(read);
const write$: Promise<void> = stp(write);
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"stream-to-promise-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }