mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
[bufferstream] upd, upstream fix
This commit is contained in:
158
bufferstream/index.d.ts
vendored
158
bufferstream/index.d.ts
vendored
@@ -1,115 +1,89 @@
|
||||
// Type definitions for bufferstream v0.6.2
|
||||
// Type definitions for bufferstream 0.6
|
||||
// Project: https://github.com/dodo/node-bufferstream
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare module 'bufferstream' {
|
||||
import stream = require('stream');
|
||||
import stream = require('stream');
|
||||
|
||||
export = BufferStream;
|
||||
export = BufferStream;
|
||||
|
||||
class BufferStream extends stream.Duplex {
|
||||
constructor(options?: BufferStream.Opts);
|
||||
declare class BufferStream extends stream.Duplex {
|
||||
constructor(options?: BufferStream.Opts);
|
||||
|
||||
/*
|
||||
different buffer behaviors can be triggered by size:
|
||||
/*
|
||||
different buffer behaviors can be triggered by size:
|
||||
|
||||
none when output drains, bufferstream drains too
|
||||
flexible buffers everthing that it gets and not piping out
|
||||
<number> TODO buffer has given size. buffers everthing until buffer is full. when buffer is full then the stream will drain
|
||||
*/
|
||||
setSize(size: string): void; // can be one of ['none', 'flexible', <number>]
|
||||
setSize(size: number): void; // can be one of ['none', 'flexible', <number>]
|
||||
/*
|
||||
enables stream buffering default
|
||||
*/
|
||||
enable(): void;
|
||||
/*
|
||||
flushes buffer and disables stream buffering. BufferStream now pipes all data as long as the output accepting data. when the output is draining BufferStream will buffer all input temporary.
|
||||
none when output drains, bufferstream drains too
|
||||
flexible buffers everthing that it gets and not piping out
|
||||
<number> TODO buffer has given size. buffers everthing until buffer is full. when buffer is full then the stream will drain
|
||||
*/
|
||||
setSize(size: string | number): void; // can be one of ['none', 'flexible', <number>]
|
||||
/*
|
||||
enables stream buffering default
|
||||
*/
|
||||
enable(): void;
|
||||
/*
|
||||
flushes buffer and disables stream buffering. BufferStream now pipes all data as long as the output accepting data. when the output is draining BufferStream will buffer all input temporary.
|
||||
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
|
||||
disables given tokens. wont flush until no splitter tokens are left.
|
||||
*/
|
||||
disable(): void;
|
||||
disable(token: string, ...tokens: string[]): void;
|
||||
disable(tokens: string[]): void; // Array
|
||||
disable(token: Buffer, ...tokens: Buffer[]): void;
|
||||
disable(tokens: Buffer[]): void; // Array
|
||||
/*
|
||||
each time BufferStream finds a splitter token in the input data it will emit a split event. this also works for binary data.
|
||||
disables given tokens. wont flush until no splitter tokens are left.
|
||||
*/
|
||||
disable(tokens?: string[] | Buffer[]): void;
|
||||
disable(token: string, ...tokens: string[]): void;
|
||||
disable(token: Buffer, ...tokens: Buffer[]): void;
|
||||
/*
|
||||
each time BufferStream finds a splitter token in the input data it will emit a split event. this also works for binary data.
|
||||
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
*/
|
||||
split(token: string, ...tokens: string[]): void;
|
||||
split(tokens: string[]): void; // Array
|
||||
split(token: Buffer, ...tokens: Buffer[]): void;
|
||||
split(tokens: Buffer[]): void; // Array
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
*/
|
||||
split(tokens: string[] | Buffer[]): void;
|
||||
split(token: string, ...tokens: string[]): void;
|
||||
split(token: Buffer, ...tokens: Buffer[]): void;
|
||||
/*
|
||||
returns Buffer.
|
||||
*/
|
||||
getBuffer(): Buffer;
|
||||
/*
|
||||
returns Buffer.
|
||||
*/
|
||||
buffer: Buffer;
|
||||
/*
|
||||
shortcut for buffer.toString()
|
||||
*/
|
||||
toString(): string;
|
||||
/*
|
||||
shortcut for buffer.length
|
||||
*/
|
||||
length: number;
|
||||
} // https://github.com/dodo/node-bufferstream/blob/master/src/buffer-stream.coffee#L28
|
||||
declare namespace BufferStream {
|
||||
|
||||
export interface Opts {
|
||||
/*
|
||||
returns Buffer.
|
||||
default encoding for writing strings
|
||||
*/
|
||||
getBuffer(): Buffer;
|
||||
encoding?: string;
|
||||
/*
|
||||
returns Buffer.
|
||||
if true and the source is a child_process the stream will block the entire process (timeouts wont work anymore, but splitting and listening on data still works, because they work sync)
|
||||
*/
|
||||
buffer: Buffer;
|
||||
blocking?: boolean;
|
||||
/*
|
||||
shortcut for buffer.toString()
|
||||
defines buffer level or sets buffer to given size (see ↓setSize for more)
|
||||
*/
|
||||
toString(): string;
|
||||
size?: any;
|
||||
/*
|
||||
shortcut for buffer.length
|
||||
immediately call disable
|
||||
*/
|
||||
length: number;
|
||||
}
|
||||
namespace BufferStream {
|
||||
|
||||
export interface Opts {
|
||||
/*
|
||||
default encoding for writing strings
|
||||
*/
|
||||
encoding?: string;
|
||||
/*
|
||||
if true and the source is a child_process the stream will block the entire process (timeouts wont work anymore, but splitting and listening on data still works, because they work sync)
|
||||
*/
|
||||
blocking?: boolean;
|
||||
/*
|
||||
defines buffer level or sets buffer to given size (see ↓setSize for more)
|
||||
*/
|
||||
size?: any;
|
||||
/*
|
||||
immediately call disable
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/*
|
||||
short form for:
|
||||
split(token, function (chunk) {emit('data', chunk)})
|
||||
*/
|
||||
// String or Buffer
|
||||
split?: any;
|
||||
}
|
||||
export var fn: {warn: boolean};
|
||||
disabled?: boolean;
|
||||
/*
|
||||
short form for:
|
||||
split(token, function (chunk) {emit('data', chunk)})
|
||||
*/
|
||||
// String or Buffer
|
||||
split?: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bufferstream/postbuffer' {
|
||||
import http = require('http');
|
||||
import BufferStream = require('bufferstream');
|
||||
|
||||
class PostBuffer extends BufferStream {
|
||||
/*
|
||||
for if you want to get all the post data from a http server request and do some db reqeust before.
|
||||
|
||||
http client buffer
|
||||
*/
|
||||
constructor(req: http.IncomingMessage);
|
||||
/*
|
||||
set a callback to get all post data from a http server request
|
||||
*/
|
||||
onEnd(callback: (data: any) => void): void;
|
||||
}
|
||||
|
||||
export = PostBuffer;
|
||||
export var fn: {warn: boolean};
|
||||
}
|
||||
|
||||
12
bufferstream/postbuffer.d.ts
vendored
Normal file
12
bufferstream/postbuffer.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import http = require('http');
|
||||
import BufferStream = require('./index');
|
||||
|
||||
export = PostBuffer;
|
||||
declare class PostBuffer extends BufferStream {
|
||||
/** for if you want to get all the post data from a http server request and do some db request before. */
|
||||
constructor(req: http.IncomingMessage);
|
||||
/** set a callback to get all post data from a http server request */
|
||||
onEnd(callback: (data: any) => void): void;
|
||||
/** pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe */
|
||||
pipe(stream: NodeJS.WritableStream, options?: BufferStream.Opts): NodeJS.ReadableStream;
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
@@ -15,6 +17,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"postbuffer.d.ts",
|
||||
"bufferstream-tests.ts"
|
||||
]
|
||||
}
|
||||
1
bufferstream/tslint.json
Normal file
1
bufferstream/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user