diff --git a/JSONStream/JSONStream-tests.ts b/JSONStream/JSONStream-tests.ts new file mode 100644 index 000000000..ea7eb64ff --- /dev/null +++ b/JSONStream/JSONStream-tests.ts @@ -0,0 +1,15 @@ +/// + +import json = require('JSONStream'); + +var read: NodeJS.ReadableStream; +var write: NodeJS.WritableStream; + +read = read.pipe(json.parse('*')); +read = read.pipe(json.parse(['foo/*', 'bar/*'])); + +read = json.stringify(); +read = json.stringify('{', ',', '}'); + +read = json.stringifyObject(); +read = json.stringifyObject('{', ',', '}'); diff --git a/JSONStream/JSONStream.d.ts b/JSONStream/JSONStream.d.ts new file mode 100644 index 000000000..869f965f4 --- /dev/null +++ b/JSONStream/JSONStream.d.ts @@ -0,0 +1,22 @@ +// Type definitions for JSONStream v0.8.0 +// Project: http://github.com/dominictarr/JSONStream +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'JSONStream' { + + export interface Options { + recurse: boolean; + } + + export function parse(pattern: any): NodeJS.ReadWriteStream; + export function parse(patterns: any[]): NodeJS.ReadWriteStream; + + export function stringify(): NodeJS.ReadWriteStream; + export function stringify(open: string, sep: string, close: string): NodeJS.ReadWriteStream; + + export function stringifyObject(): NodeJS.ReadWriteStream; + export function stringifyObject(open: string, sep: string, close: string): NodeJS.ReadWriteStream; +} diff --git a/buffer-equal/buffer-equal.d.ts b/buffer-equal/buffer-equal.d.ts index 5f671662d..a3597c684 100644 --- a/buffer-equal/buffer-equal.d.ts +++ b/buffer-equal/buffer-equal.d.ts @@ -1,5 +1,5 @@ // Type definitions for buffer-equal 1.0 0 -// Project: https://github.com/chaijs/assertion-error +// Project: https://github.com/substack/node-buffer-equal // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/bufferstream/bufferstream-tests.ts b/bufferstream/bufferstream-tests.ts new file mode 100644 index 000000000..fe1ea70aa --- /dev/null +++ b/bufferstream/bufferstream-tests.ts @@ -0,0 +1,14 @@ +/// + +import BufferStream = require('bufferstream') + +var stream = new BufferStream({encoding:'utf8', size:'flexible'}); +stream.enable(); +stream.disable(); +stream.split('//', ':'); +stream.on('split', (chunk: any, token: any) => { + console.log("got '%s' by '%s'", chunk.toString(), token.toString()) +}); +stream.write("buffer:stream//23"); +console.log(stream.toString()); + diff --git a/bufferstream/bufferstream.d.ts b/bufferstream/bufferstream.d.ts new file mode 100644 index 000000000..5323103e2 --- /dev/null +++ b/bufferstream/bufferstream.d.ts @@ -0,0 +1,119 @@ +// Type definitions for bufferstream v0.6.2 +// Project: https://github.com/dodo/node-bufferstream +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'bufferstream' { + import stream = require('stream'); + + export = BufferStream; + + class BufferStream extends stream.Duplex { + constructor(options?: BufferStream.Opts); + + /* + 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 + 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', ] + setSize(size: number): void; // can be one of ['none', 'flexible', ] + /* + 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) + + 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. + + 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 + /* + returns Buffer. + */ + getBuffer(): Buffer; + /* + returns Buffer. + */ + buffer: Buffer; + /* + shortcut for buffer.toString() + */ + toString(): string; + /* + shortcut for buffer.length + */ + length: number; + } + module 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}; + } +} + +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.ServerRequest); + /* + 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; + } + + export = PostBuffer; +} diff --git a/deep-freeze/deep-freeze-tests.ts b/deep-freeze/deep-freeze-tests.ts new file mode 100644 index 000000000..8369d3087 --- /dev/null +++ b/deep-freeze/deep-freeze-tests.ts @@ -0,0 +1,8 @@ +/// + +import df = require('deep-freeze'); + +class Foo { + foo: string; +} +var foo:Foo = df(new Foo()); diff --git a/deep-freeze/deep-freeze.d.ts b/deep-freeze/deep-freeze.d.ts new file mode 100644 index 000000000..3d7ede8ad --- /dev/null +++ b/deep-freeze/deep-freeze.d.ts @@ -0,0 +1,9 @@ +// Type definitions for deep-freeze +// Project: https://github.com/substack/deep-freeze +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'deep-freeze' { + function df(obj: T): T; + export = df; +} diff --git a/glob-stream/glob-stream-tests.ts b/glob-stream/glob-stream-tests.ts new file mode 100644 index 000000000..f6a0e4bf3 --- /dev/null +++ b/glob-stream/glob-stream-tests.ts @@ -0,0 +1,12 @@ +/// + +import gs = require('glob-stream'); + +var read: NodeJS.ReadableStream; + +read = gs.create('xx'); +read = gs.create('xx', {}); +read = gs.create(['xx'], {}); +read = gs.create(['xx'], {cwd: 'xx'}); +read = gs.create(['xx'], {base: 'xx'}); +read = gs.create(['xx'], {cwdbase: true}); diff --git a/glob-stream/glob-stream.d.ts b/glob-stream/glob-stream.d.ts new file mode 100644 index 000000000..52db4f437 --- /dev/null +++ b/glob-stream/glob-stream.d.ts @@ -0,0 +1,26 @@ +// Type definitions for glob-stream v3.1.12 +// Project: http://github.com/wearefractal/glob-stream +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module 'glob-stream' { + import glob = require('glob'); + + export interface Options extends glob.IOptions { + cwd?: string; + base?: string; + cwdbase?: boolean; + } + + export interface Element { + cwd: string; + base: string; + path: string; + } + + export function create(glob:string, opts?: Options): NodeJS.ReadableStream; + export function create(globs:string[], opts?: Options): NodeJS.ReadableStream; +}