diff --git a/oboe/oboe-tests.ts b/oboe/oboe-tests.ts index f98def75e..48939d418 100644 --- a/oboe/oboe-tests.ts +++ b/oboe/oboe-tests.ts @@ -32,3 +32,18 @@ oboe('/content') console.error('no such content'); } }); + +oboe('friends.json') + .node('friend', function (parsedJson) { + console.log('friend parsed', parsedJson); + }); + +oboe('friends.json') + .node({ + 'friend': function (parsedJson) { + console.log('friend parsed', parsedJson); + }, + '!': function (parsedJson) { + console.log('root parsed', parsedJson); + } + }); diff --git a/oboe/oboe.d.ts b/oboe/oboe.d.ts index 6e6ed650b..1f036ce8b 100644 --- a/oboe/oboe.d.ts +++ b/oboe/oboe.d.ts @@ -5,61 +5,65 @@ /// -declare module "oboe" { - import stream = require('stream'); - - function oboe(url: string): oboe.Oboe; - function oboe(options: oboe.Options): oboe.Oboe; - function oboe(stream: stream.Readable) : oboe.Oboe; - - module oboe { - - var drop: {}; - - interface Oboe { - done(callback: (result: any) => void): Oboe; - - fail(callback: (result: FailReason) => void): Oboe; - - node(pattern: string, callback: CallbackSignature): Oboe; - - on(event: string, pattern: string, callback: CallbackSignature): Oboe; - on(eventPattern: string, callback: CallbackSignature): Oboe; - - path(pattern: string, callback: CallbackSignature): Oboe; - path(listeners: any): Oboe; - - removeListener(eventPattern: string, callback: CallbackSignature): Oboe; - removeListener(event: string, pattern: string, callback: CallbackSignature): Oboe; - - start(callback: (status: number, headers: Object) => void): Oboe; - - abort():void; - - source: string; - } - - interface CallbackSignature { - (node: any, pathOrHeaders: any, ancestors: Object[]): any; - } - - interface Options { - url: string; - method?: string; - headers?: Object; - body?: any; - cached?: boolean; - withCredentials?: boolean; - } - - interface FailReason { - thrown?: Error; - statusCode?: number; - body?: string; - jsonBody?: Object; - } +declare module oboe { + interface OboeFunction extends Function { + drop: Object; + (url: string): Oboe; + (options: Options): Oboe; + (stream: NodeJS.ReadableStream): Oboe; } - export = oboe; + interface Oboe { + done(callback: (result: any) => void): Oboe; + + fail(callback: (result: FailReason) => void): Oboe; + + node(pattern: string, callback: CallbackSignature): Oboe; + node(patterns: PatternMap): Oboe; + + on(event: string, pattern: string, callback: CallbackSignature): Oboe; + on(eventPattern: string, callback: CallbackSignature): Oboe; + + path(pattern: string, callback: CallbackSignature): Oboe; + path(listeners: any): Oboe; + + removeListener(eventPattern: string, callback: CallbackSignature): Oboe; + removeListener(event: string, pattern: string, callback: CallbackSignature): Oboe; + + start(callback: (status: number, headers: Object) => void): Oboe; + + abort():void; + + source: string; + } + + interface CallbackSignature { + (node: any, pathOrHeaders: any, ancestors: Object[]): any; + } + + interface Options { + url: string; + method?: string; + headers?: Object; + body?: any; + cached?: boolean; + withCredentials?: boolean; + } + + interface FailReason { + thrown?: Error; + statusCode?: number; + body?: string; + jsonBody?: Object; + } + + interface PatternMap { + [pattern: string]: CallbackSignature + } } +declare var oboe: oboe.OboeFunction; + +declare module "oboe" { + export = oboe; +}