Skip to content

Commit

Permalink
readline-transform: update to 1.0 (#37478)
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er authored and sandersn committed Aug 8, 2019
1 parent 074bd37 commit d4f4525
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 16 deletions.
24 changes: 10 additions & 14 deletions types/readline-transform/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for readline-transform 0.9
// Type definitions for readline-transform 1.0
// Project: https://github.com/tilfin/readline-transform
// Definitions by: Piotr Roszatycki <https://github.com/dex4er>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -7,19 +7,15 @@

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;
}
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;
}

declare class ReadlineTransform extends Transform {
constructor(options?: ReadlineTransform.Options);
export default class ReadlineTransform extends Transform {
constructor(options?: ReadlineTransformOptions);
}

export = ReadlineTransform;
4 changes: 2 additions & 2 deletions types/readline-transform/readline-transform-tests.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PassThrough } from 'stream';
import ReadlineTransform = require('readline-transform');
import ReadlineTransform from 'readline-transform';

const readStream = new PassThrough();
const transform = new ReadlineTransform({
breakMatcher: /\n/,
ignoreEndOfBreak: false,
skipEmpty: true
skipEmpty: true,
});
const writeStream = new PassThrough({ objectMode: true });

Expand Down
25 changes: 25 additions & 0 deletions types/readline-transform/v0/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions types/readline-transform/v0/readline-transform-tests.ts
Original file line number Diff line number Diff line change
@@ -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);
28 changes: 28 additions & 0 deletions types/readline-transform/v0/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../../",
"paths": {
"readline-transform": [
"readline-transform/v0"
]
},
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"readline-transform-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/readline-transform/v0/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit d4f4525

Please sign in to comment.