Merge pull request #23436 from dex4er/readline-transform

New typings for readline-transform
This commit is contained in:
Daniel Rosenwasser
2018-02-13 11:12:31 -08:00
committed by GitHub
4 changed files with 58 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for readline-transform 0.9
// Project: https://github.com/tilfin/readline-transform
// Definitions by: Piotr Roszatycki <https://github.com/dex4er>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Transform, TransformOptions } from 'stream';
export interface ReadlineTransformOptions extends TransformOptions {
/** line break matcher for str.split() (default: /\r?\n/) */
breakMatcher?: RegExp;
/** if content ends with line break, ignore last empty line (default: true) */
ignoreEndOfBreak?: boolean;
/** if line is empty string, skip it (default: false) */
skipEmpty?: boolean;
}
export default class ReadlineTransform extends Transform {
constructor(options?: ReadlineTransformOptions);
}
@@ -0,0 +1,12 @@
import { PassThrough } from 'stream';
import ReadlineTransform from 'readline-transform';
const readStream = new PassThrough();
const transform = new ReadlineTransform({
breakMatcher: /\n/,
ignoreEndOfBreak: false,
skipEmpty: true
});
const writeStream = new PassThrough({ objectMode: true });
readStream.pipe(transform).pipe(writeStream);
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"readline-transform-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }