8889841cREADME.md000066600000001021150476771170006040 0ustar00# Installation > `npm install --save @types/retry` # Summary This package contains type definitions for retry (https://github.com/tim-kos/node-retry). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/retry Additional Details * Last updated: Thu, 03 Jan 2019 17:45:51 GMT * Dependencies: none * Global values: none # Credits These definitions were written by Stan Goldmann , BendingBender . index.d.ts000066600000012026150476771170006471 0ustar00// Type definitions for retry 0.12 // Project: https://github.com/tim-kos/node-retry // Definitions by: Stan Goldmann // BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 export interface RetryOperation { /** * Returns an array of all errors that have been passed to `retryOperation.retry()` so far. * The returning array has the errors ordered chronologically based on when they were passed to * `retryOperation.retry()`, which means the first passed error is at index zero and the last is at the last index. */ errors(): Error[]; /** * A reference to the error object that occured most frequently. * Errors are compared using the `error.message` property. * If multiple error messages occured the same amount of time, the last error object with that message is returned. * * @return If no errors occured so far the value will be `null`. */ mainError(): Error | null; /** * Defines the function that is to be retried and executes it for the first time right away. * * @param fn The function that is to be retried. `currentAttempt` represents the number of attempts * callback has been executed so far. * @param [timeoutOps.timeout] A timeout in milliseconds. * @param [timeoutOps.callback] Callback to execute when the operation takes longer than the timeout. */ attempt(fn: (currentAttempt: number) => void, timeoutOps?: AttemptTimeoutOptions): void; /** * Returns `false` when no `error` value is given, or the maximum amount of retries has been reached. * Otherwise it returns `true`, and retries the operation after the timeout for the current attempt number. */ retry(err?: Error): boolean; /** * Stops the operation being retried. Useful for aborting the operation on a fatal error etc. */ stop(): void; /** * Resets the internal state of the operation object, so that you can call `attempt()` again as if * this was a new operation object. */ reset(): void; /** * Returns an int representing the number of attempts it took to call `fn` before it was successful. */ attempts(): number; } export interface AttemptTimeoutOptions { /** * A timeout in milliseconds. */ timeout?: number; /** * Callback to execute when the operation takes longer than the timeout. */ callback?(): void; } /** * Create a new RetryOperation object. * * @param [options.retries=10] The maximum amount of times to retry the operation. * @param [options.factor=2] The exponential factor to use. * @param [options.minTimeout=1000] The number of milliseconds before starting the first retry. * @param [options.maxTimeout=Infinity] The maximum number of milliseconds between two retries. * @param [options.randomize=false] Randomizes the timeouts by multiplying a factor between 1-2. * @param [options.forever=false] Wether to retry forever. * @param [options.unref=false] Wether to unref the setTimeout's. * */ export function operation(options?: OperationOptions): RetryOperation; export interface OperationOptions extends TimeoutsOptions { /** * Whether to retry forever. * @default false */ forever?: boolean; /** * Whether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's. * @default false */ unref?: boolean; /** * The maximum time (in milliseconds) that the retried operation is allowed to run. * @default Infinity */ maxRetryTime?: number; } /** Get an array with timeouts and their return values in milliseconds. */ export function timeouts(options?: TimeoutsOptions): number[]; export interface TimeoutsOptions extends CreateTimeoutOptions { /** * The maximum amount of times to retry the operation. * @default 10 */ retries?: number; } /** * Create a new timeout (in milliseconds) based on the given parameters. * * @param attempt Representing for which retry the timeout should be calculated. * @return timeout */ export function createTimeout(attempt: number, options?: CreateTimeoutOptions): number; export interface CreateTimeoutOptions { /** * The exponential factor to use. * @default 2 */ factor?: number; /** * The number of milliseconds before starting the first retry. * @default 1000 */ minTimeout?: number; /** * The maximum number of milliseconds between two retries. * @default Infinity */ maxTimeout?: number; /** * Randomizes the timeouts by multiplying a factor between 1-2. * @default false */ randomize?: boolean; } /** * Wrap all functions of the object with retry. * * @param object The object to be wrapped * @param methods Methods which need to be wrapped * */ export function wrap(object: object, methods?: string[]): void; export function wrap(object: object, options?: OperationOptions, methods?: string[]): void; LICENSE000066600000002237150476771170005600 0ustar00 MIT License Copyright (c) Microsoft Corporation. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE package.json000066600000001440150476771170007054 0ustar00{ "name": "@types/retry", "version": "0.12.0", "description": "TypeScript definitions for retry", "license": "MIT", "contributors": [ { "name": "Stan Goldmann", "url": "https://github.com/krenor", "githubUsername": "krenor" }, { "name": "BendingBender", "url": "https://github.com/BendingBender", "githubUsername": "BendingBender" } ], "main": "", "types": "index", "repository": { "type": "git", "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git" }, "scripts": {}, "dependencies": {}, "typesPublisherContentHash": "dc8156aa3c27632d2585c45d8951c4a0f7ae9122bd17190d8973018556d174f3", "typeScriptVersion": "2.3" }