mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
// Type definitions for wait-on 3.2
|
||||
// Project: https://github.com/jeffbski/wait-on#readme
|
||||
// Definitions by: Ifiok Jr. <https://github.com/ifiokjr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = waitOn;
|
||||
|
||||
declare function waitOn(options: waitOn.WaitOnOptions): Promise<void>;
|
||||
declare function waitOn(
|
||||
options: waitOn.WaitOnOptions,
|
||||
cb: (err: any) => void,
|
||||
): void;
|
||||
|
||||
declare namespace waitOn {
|
||||
interface WaitOnOptions {
|
||||
/**
|
||||
* Array of string resources to wait for. prefix determines the type of resource with the default type of file:
|
||||
*/
|
||||
resources: string[];
|
||||
/**
|
||||
* Initial delay in ms.
|
||||
* @default 0
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
* Poll resource interval in ms,
|
||||
* @default 250ms
|
||||
*/
|
||||
interval?: number;
|
||||
/**
|
||||
* Flag which outputs to stdout, remaining resources waited on and when complete or any error occurs.
|
||||
*/
|
||||
log?: boolean;
|
||||
/**
|
||||
* Flag to reverse operation so checks are for resources being NOT available.
|
||||
* @default false
|
||||
*/
|
||||
reverse?: boolean;
|
||||
/**
|
||||
* Timeout in ms until it aborts with error.
|
||||
* @default Infinity
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Tcp timeout in ms.
|
||||
* @default 300
|
||||
*/
|
||||
tcpTimeout?: number;
|
||||
/**
|
||||
* Flag which outputs debug output.
|
||||
* @default false
|
||||
*/
|
||||
verbose?: boolean;
|
||||
/**
|
||||
* Stabilization time in ms
|
||||
* Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged.
|
||||
* @default 750ms.
|
||||
*/
|
||||
window?: number;
|
||||
|
||||
/**
|
||||
* Https specific option.
|
||||
* see https:// github.com/request/request#readme for specific details
|
||||
*/
|
||||
auth?: WaitOnAuth;
|
||||
httpSignature?: HttpSignature;
|
||||
strictSSL?: boolean;
|
||||
followAllRedirects?: boolean;
|
||||
followRedirect?: boolean;
|
||||
headers?: Record<string, any>;
|
||||
}
|
||||
|
||||
interface HttpSignature {
|
||||
keyId: string;
|
||||
key: string;
|
||||
}
|
||||
|
||||
type WaitOnAuth =
|
||||
| {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* Alias of username
|
||||
*/
|
||||
user: string;
|
||||
/**
|
||||
* Alias of password
|
||||
*/
|
||||
pass: string;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "wait-on-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,75 @@
|
||||
import waitOn = require('wait-on');
|
||||
|
||||
const opts = {
|
||||
resources: [
|
||||
'file1',
|
||||
'http://foo.com:8000/bar',
|
||||
'https://my.com/cat',
|
||||
'http-get://foo.com:8000/bar',
|
||||
'https-get://my.com/cat',
|
||||
'tcp:foo.com:8000',
|
||||
'socket:/my/sock',
|
||||
'http://unix:/my/sock:/my/url',
|
||||
'http-get://unix:/my/sock:/my/url',
|
||||
],
|
||||
delay: 1000, // initial delay in ms, default 0
|
||||
interval: 100, // poll interval in ms, default 250ms
|
||||
timeout: 30000, // timeout in ms, default Infinity
|
||||
tcpTimeout: 1000, // tcp timeout in ms, default 300ms
|
||||
window: 1000, // stabilization time in ms, default 750ms
|
||||
|
||||
// http options
|
||||
ca: [
|
||||
/* strings or binaries */
|
||||
],
|
||||
cert: [
|
||||
/* strings or binaries */
|
||||
],
|
||||
key: [
|
||||
/* strings or binaries */
|
||||
],
|
||||
passphrase: 'yourpassphrase',
|
||||
auth: {
|
||||
user: 'theuser', // or username
|
||||
pass: 'thepassword', // or password
|
||||
},
|
||||
httpSignature: {
|
||||
keyId: 'yourKeyId',
|
||||
key: 'yourKey',
|
||||
},
|
||||
strictSSL: false,
|
||||
followAllRedirects: true,
|
||||
followRedirect: true,
|
||||
headers: {
|
||||
'x-custom': 'headers',
|
||||
},
|
||||
};
|
||||
|
||||
const handleError = (err: any) => undefined;
|
||||
|
||||
// Usage with callback function
|
||||
waitOn(opts, err => {
|
||||
if (err) {
|
||||
return handleError(err);
|
||||
}
|
||||
// once here, all resources are available
|
||||
});
|
||||
|
||||
// Usage with promises
|
||||
waitOn(opts)
|
||||
.then(() => {
|
||||
// once here, all resources are available
|
||||
})
|
||||
.catch(err => {
|
||||
handleError(err);
|
||||
});
|
||||
|
||||
// Usage with async await
|
||||
(async () => {
|
||||
try {
|
||||
await waitOn(opts);
|
||||
// once here, all resources are available
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user