New typings for readline-transform

This commit is contained in:
Piotr Roszatycki
2018-02-05 21:25:49 +01:00
parent 8058968995
commit 4f7ef19cc7
4 changed files with 66 additions and 0 deletions

25
types/readline-transform/index.d.ts vendored Normal file
View File

@@ -0,0 +1,25 @@
// 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';
declare namespace ReadlineTransform {
interface Options 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;
}
}
declare class ReadlineTransform extends Transform {
constructor(options?: ReadlineTransform.Options);
}
export = ReadlineTransform;

View File

@@ -0,0 +1,12 @@
import { PassThrough } from 'stream';
import ReadlineTransform = require('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);

View File

@@ -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",
"readline-transform-tests.ts"
]
}

View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"strict-export-declare-modifiers": false
}
}