forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR DefinitelyTyped#66731 Add @types/map-stream by @KonradPerl…
…icki * Add @types/map-stream * Update comment in types/map-stream/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]> * Fixed return type --------- Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]>
- Loading branch information
1 parent
127cdd3
commit f472296
Showing
4 changed files
with
77 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Type definitions for map-stream 0.0 | ||
// Project: http://github.com/dominictarr/map-stream | ||
// Definitions by: Konrad Perlicki <https://github.com/KonradPerlicki> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
/// <reference types="node"/> | ||
|
||
import { Stream } from 'stream'; | ||
|
||
export = mapStream; | ||
|
||
declare namespace mapStream { | ||
interface Options { | ||
/** | ||
* Continue mapping even if error occured. | ||
* | ||
* On error `map-stream` will emit `failure` event. | ||
* | ||
* @default false | ||
*/ | ||
failures?: boolean; | ||
} | ||
|
||
interface mapStream extends Stream { | ||
resume(): void; | ||
pause(): void; | ||
destroy(): void; | ||
end(): void; | ||
write(): boolean | never; | ||
} | ||
|
||
type Callback = (err: null | Error, data: unknown) => void; | ||
} | ||
|
||
declare function mapStream( | ||
mapper: (data: unknown, callback: mapStream.Callback) => void, | ||
opts?: mapStream.Options, | ||
): mapStream.mapStream; |
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,15 @@ | ||
import map = require('map-stream'); | ||
|
||
const callback: map.Callback = function (err, data) {}; | ||
|
||
const fn = map((data, callback) => {}, { | ||
failures: true, | ||
}); | ||
|
||
fn.pause(); | ||
fn.write(); | ||
fn.resume(); | ||
fn.destroy(); | ||
fn.end(); | ||
|
||
map((data, callback) => {}); |
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,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"map-stream-tests.ts" | ||
] | ||
} |
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 @@ | ||
{ "extends": "@definitelytyped/dtslint/dt.json" } |