osmosis: add more types (#29501)

This commit is contained in:
rdoo
2018-10-11 23:26:57 +02:00
committed by Andy
parent 86fd332d85
commit b06ea9d0f0
2 changed files with 37 additions and 5 deletions

View File

@@ -56,8 +56,33 @@ interface Osmosis {
* result data, osmosis finished
*/
data(callback: (param: any) => any): Osmosis;
}
declare const osmosis: Osmosis;
/**
* Set configuration options for the **preceeding** command on down the chain.
*/
config(option: string | { [key: string]: any }, value?: any): Osmosis;
export = osmosis;
/**
* Set a cookie. Short for `.config({ cookies: ... })`. Note: Setting a cookie to `null` will delete the cookie.
*/
cookie(name: string, value: string | null): Osmosis;
/**
* Set an HTTP header. Short for `.config({ headers: ... })`
*/
header(name: string, value: string): Osmosis;
/**
* Set multiple HTTP headers. Short for `.config({ headers: ... })`.
*/
headers(headers: { [key: string]: string }): Osmosis;
/**
* Call a callback when the Osmosis instance has completely finished.
*/
done(callback: () => any): Osmosis;
}
declare const osmosis: Osmosis;
export = osmosis;

View File

@@ -12,9 +12,15 @@ const errorFunction = (error: string) => {
const myError = error;
};
// example is from https://github.com/rchipka/node-osmosis#example
const doneFunction = () => {};
// modified example from https://github.com/rchipka/node-osmosis#example
osmosis
.config({ headers: { 'test-header-name': 'test-header-value' } })
.headers({ 'test-header-name': 'test-header-value' })
.header('test-header-name', 'test-header-value')
.cookie('test-cookie-name', 'test-cookie-value')
.get('www.craigslist.org/about/sites')
.find('h1 + div a')
.set('location')
@@ -39,4 +45,5 @@ osmosis
})
.log(logFunction)
.error(errorFunction)
.debug(debugFunction);
.debug(debugFunction)
.done(doneFunction);