mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-26 10:14:26 +08:00
osmosis: add more types (#29501)
This commit is contained in:
31
types/osmosis/index.d.ts
vendored
31
types/osmosis/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user