mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add typings for oboe.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/// <reference path="oboe.d.ts" />
|
||||
import oboe = require('oboe');
|
||||
|
||||
oboe('friends.json')
|
||||
.node('name', function (name) {
|
||||
console.log('You have a friend called', name);
|
||||
}).on('node', '{name dob address}', function (personJson) {
|
||||
console.log('Name is: %s', personJson.name);
|
||||
}).on('node', 'person.address', function (address) {
|
||||
return oboe.drop;
|
||||
})
|
||||
|
||||
var friendCount = 0;
|
||||
oboe('friends.json')
|
||||
.path('friend', function (name) {
|
||||
friendCount++;
|
||||
});
|
||||
|
||||
oboe('resource.json')
|
||||
.on('done', function (parsedJson) {
|
||||
console.log('Request complete', parsedJson);
|
||||
});
|
||||
|
||||
oboe('resource.json')
|
||||
.on('start', function (status, headers) {
|
||||
console.log('Resource cached for', headers.Age, 'secs');
|
||||
});
|
||||
|
||||
oboe('/content')
|
||||
.fail(function (errorReport) {
|
||||
if (404 == errorReport.statusCode) {
|
||||
console.error('no such content');
|
||||
}
|
||||
});
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// Type definitions for [LIBRARY NAME]
|
||||
// Project: [LIBRARY URL]
|
||||
// Definitions by: [AUTHOR NAME] <[AUTHOR URL]>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
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;
|
||||
|
||||
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?: string;
|
||||
statusCode?: number;
|
||||
body?: string;
|
||||
jsonBody?: Object;
|
||||
}
|
||||
}
|
||||
|
||||
export = oboe;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user