Skip to content

Commit

Permalink
once('pipe' | 'unpipe') resolves to Readable
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Oct 10, 2017
1 parent d8760e6 commit 5459cda
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.0.2 2017-10-10

* Typescript: `once('pipe' | 'unpipe')` resolves to `Readable`.

## v2.0.1 2017-10-06

* Do not use UMD import internally.
Expand Down
7 changes: 4 additions & 3 deletions examples/bsmtp-client-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ import * as net from 'net'

import byline = require('byline')

const [host = 'localhost', port = '25'] = process.argv.slice(2, 4)
const host = process.argv[2] || 'localhost'
const port = Number(process.argv[3]) || 25

const socket = new PromiseDuplex(new net.Socket())
const stdin = new PromiseReadable(byline(process.stdin, { keepEmptyLines: true }))
const stdout = new PromiseWritable(process.stdout)

socket.stream.connect(Number(port), host, client)
socket.stream.connect(port, host, client)

async function client (arg: any): Promise<void> {
async function client (): Promise<void> {
try {
// which line for DATA command?
let dataLine = 0
Expand Down
5 changes: 3 additions & 2 deletions examples/bsmtp-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ const { PromiseDuplex } = require('../lib/promise-duplex')
const net = require('net')
const byline = require('byline')

const [host = 'localhost', port = '25'] = process.argv.slice(2, 4)
const host = process.argv[2] || 'localhost'
const port = Number(process.argv[3]) || 25

const psocket = new PromiseDuplex(new net.Socket())
const pstdin = new PromiseReadable(byline(process.stdin, {keepEmptyLines: true}))
const pstdout = new PromiseWritable(process.stdout)

psocket.stream.connect(port, host, client)

async function client (arg) {
async function client () {
try {
// which line for DATA command?
let dataLine = 0
Expand Down
12 changes: 4 additions & 8 deletions lib/promise-duplex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { PromiseReadable } from 'promise-readable'
import { PromiseWritable } from 'promise-writable'
import * as stream from 'stream'
import { Readable, Duplex } from 'stream'

export declare class PromiseDuplex<TDuplex extends stream.Duplex> extends PromiseReadable<TDuplex> implements PromiseWritable<TDuplex> {
export declare class PromiseDuplex<TDuplex extends Duplex> extends PromiseReadable<TDuplex> implements PromiseWritable<TDuplex> {
readonly stream: TDuplex
readonly readable: PromiseReadable<TDuplex>
readonly writable: PromiseWritable<TDuplex>
Expand All @@ -17,13 +17,9 @@ export declare class PromiseDuplex<TDuplex extends stream.Duplex> extends Promis
write (chunk: string | Buffer, encoding?: string): Promise<number>
writeAll (content: string | Buffer, chunkSize?: number): Promise<number>

once (event: 'close'): Promise<void>
once (event: 'end'): Promise<void>
once (event: 'error'): Promise<void>
once (event: 'finish'): Promise<void>
once (event: 'close' | 'end' | 'error' | 'finish'): Promise<void>
once (event: 'open'): Promise<number>
once (event: 'pipe'): Promise<NodeJS.ReadableStream>
once (event: 'unpipe'): Promise<NodeJS.ReadableStream>
once (event: 'pipe' | 'unpipe'): Promise<Readable>

end (): Promise<void>
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "promise-duplex",
"version": "2.0.1",
"version": "2.0.2",
"description": "Return promise for duplex stream",
"main": "lib/promise-duplex.js",
"typings": "lib/promise-duplex.d.ts",
Expand All @@ -23,12 +23,12 @@
"node": ">=4.0.0"
},
"dependencies": {
"promise-readable": "^2.0.0",
"promise-writable": "^2.0.1"
"promise-readable": "^2.1.0",
"promise-writable": "^2.1.1"
},
"devDependencies": {
"@types/byline": "^4.2.31",
"@types/node": "^8.0.33",
"@types/node": "^8.0.34",
"byline": "^5.0.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
Expand Down
10 changes: 4 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"removeComments": false,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"target": "ES2017",
"typeRoots" : [
"./lib",
"./node_modules/@types"
]
"target": "ES2017"
}
}
3 changes: 1 addition & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"tslint:recommended",
"tslint-config-standard"
],
"jsRules": {},
"rules": {
"no-conditional-assignment": false,
"no-console": [true, "log"],
"triple-equals": [true, "allow-null-check"]
"no-unused-variable": false
}
}

0 comments on commit 5459cda

Please sign in to comment.