Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2016-01-28 03:43:56 +0300
committerRebecca Turner <me@re-becca.org>2016-01-29 01:58:48 +0300
commita7b24074cb59a1ab17c0d8eff1498047e6a123e5 (patch)
treec398a4df2affcf1b766c54e63865f56081f5b252 /node_modules/retry
parent220fc7702ae3e5d601dfefd3e95c14e9b32327de (diff)
retry@0.9.0
Add ability to unref timers. Internal refactoring of retryForever. Credit: @tim-kos
Diffstat (limited to 'node_modules/retry')
-rw-r--r--node_modules/retry/Readme.md30
-rw-r--r--node_modules/retry/lib/retry.js7
-rw-r--r--node_modules/retry/lib/retry_operation.js20
-rw-r--r--node_modules/retry/package.json90
4 files changed, 100 insertions, 47 deletions
diff --git a/node_modules/retry/Readme.md b/node_modules/retry/Readme.md
index 09d9c8a81..26e50a3a7 100644
--- a/node_modules/retry/Readme.md
+++ b/node_modules/retry/Readme.md
@@ -57,8 +57,10 @@ var operation = retry.operation({
### retry.operation([options])
-Creates a new `RetryOperation` object. See the `retry.timeouts()` function
-below for available `options`.
+Creates a new `RetryOperation` object. `options` is the same as `retry.timeouts()`'s `options`, with two additions:
+
+* `forever`: Whether to retry forever, defaults to `false`.
+* `unref`: Wether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
### retry.timeouts([options])
@@ -126,11 +128,19 @@ retry.wrap(obj, {retries: 3}, ['method1', 'method2']);
```
The `options` object can take any options that the usual call to `retry.operation` can take.
-### new RetryOperation(timeouts)
+### new RetryOperation(timeouts, [options])
Creates a new `RetryOperation` where `timeouts` is an array where each value is
a timeout given in milliseconds.
+Available options:
+* `forever`: Whether to retry forever, defaults to `false`.
+* `unref`: Wether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
+
+If `forever` is true, the following changes happen:
+* `RetryOperation.errors()` will only output an array of one item: the last error.
+* `RetryOperation` will repeatedly use the last item in the `timeouts` array.
+
#### retryOperation.errors()
Returns an array of all errors that have been passed to
@@ -157,11 +167,11 @@ Whenever your retry operation takes longer than `timeout` to execute, the timeou
#### retryOperation.try(fn)
-This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
+This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
#### retryOperation.start(fn)
-This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
+This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
#### retryOperation.retry(error)
@@ -180,13 +190,15 @@ Returns an int representing the number of attempts it took to call `fn` before i
retry is licensed under the MIT license.
-#Changelog
+# Changelog
+
+0.8.0 Implementing retry.wrap.
-0.7.0 Some bugfixes and made retry.createTimeout() public. Fixed issues [#10](https://github.com/tim-kos/node-retry/issues/10), [#12](https://github.com/tim-kos/node-retry/issues/12), and [#13](https://github.com/tim-kos/node-retry/issues/13).
+0.7.0 Some bug fixes and made retry.createTimeout() public. Fixed issues [#10](https://github.com/tim-kos/node-retry/issues/10), [#12](https://github.com/tim-kos/node-retry/issues/12), and [#13](https://github.com/tim-kos/node-retry/issues/13).
-0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in miliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
+0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in milliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
-0.5.0 Some minor refactorings.
+0.5.0 Some minor refactoring.
0.4.0 Changed retryOperation.try() to retryOperation.attempt(). Deprecated the aliases start() and try() for it.
diff --git a/node_modules/retry/lib/retry.js b/node_modules/retry/lib/retry.js
index 94685652c..02ab14729 100644
--- a/node_modules/retry/lib/retry.js
+++ b/node_modules/retry/lib/retry.js
@@ -1,10 +1,11 @@
var RetryOperation = require('./retry_operation');
exports.operation = function(options) {
- var retryForever = false;
- if (options && options.forever === true) retryForever = true;
var timeouts = exports.timeouts(options);
- return new RetryOperation(timeouts, retryForever);
+ return new RetryOperation(timeouts, {
+ forever: options && options.forever,
+ unref: options && options.unref
+ });
};
exports.timeouts = function(options) {
diff --git a/node_modules/retry/lib/retry_operation.js b/node_modules/retry/lib/retry_operation.js
index 52b895544..ad96efbdf 100644
--- a/node_modules/retry/lib/retry_operation.js
+++ b/node_modules/retry/lib/retry_operation.js
@@ -1,5 +1,11 @@
-function RetryOperation(timeouts, retryForever) {
+function RetryOperation(timeouts, options) {
+ // Compatibility for the old (timeouts, retryForever) signature
+ if (typeof options === 'boolean') {
+ options = { forever: options };
+ }
+
this._timeouts = timeouts;
+ this._options = options || {};
this._fn = null;
this._errors = [];
this._attempts = 1;
@@ -7,7 +13,7 @@ function RetryOperation(timeouts, retryForever) {
this._operationTimeoutCb = null;
this._timeout = null;
- if (!!retryForever) {
+ if (this._options.forever) {
this._cachedTimeouts = this._timeouts.slice(0);
}
}
@@ -37,18 +43,26 @@ RetryOperation.prototype.retry = function(err) {
}
var self = this;
- setTimeout(function() {
+ var timer = setTimeout(function() {
self._attempts++;
if (self._operationTimeoutCb) {
self._timeout = setTimeout(function() {
self._operationTimeoutCb(self._attempts);
}, self._operationTimeout);
+
+ if (this._options.unref) {
+ self._timeout.unref();
+ }
}
self._fn(self._attempts);
}, timeout);
+ if (this._options.unref) {
+ timer.unref();
+ }
+
return true;
};
diff --git a/node_modules/retry/package.json b/node_modules/retry/package.json
index 68d19a908..9d2283a39 100644
--- a/node_modules/retry/package.json
+++ b/node_modules/retry/package.json
@@ -1,53 +1,79 @@
{
- "author": {
- "name": "Tim Koschützki",
+ "_args": [
+ [
+ "retry@latest",
+ "/Users/rebecca/code/npm"
+ ]
+ ],
+ "_from": "retry@latest",
+ "_id": "retry@0.9.0",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/retry",
+ "_nodeVersion": "4.2.1",
+ "_npmUser": {
"email": "tim@debuggable.com",
- "url": "http://debuggable.com/"
+ "name": "tim-kos"
},
- "name": "retry",
- "description": "Abstraction for exponential and custom retry strategies for failed operations.",
- "license": "MIT",
- "version": "0.8.0",
- "homepage": "https://github.com/tim-kos/node-retry",
- "repository": {
- "type": "git",
- "url": "git://github.com/tim-kos/node-retry.git"
+ "_npmVersion": "2.1.7",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "retry",
+ "raw": "retry@latest",
+ "rawSpec": "latest",
+ "scope": null,
+ "spec": "latest",
+ "type": "tag"
},
- "directories": {
- "lib": "./lib"
+ "_requiredBy": [
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/retry/-/retry-0.9.0.tgz",
+ "_shasum": "6f697e50a0e4ddc8c8f7fb547a9b60dead43678d",
+ "_shrinkwrap": null,
+ "_spec": "retry@latest",
+ "_where": "/Users/rebecca/code/npm",
+ "author": {
+ "email": "tim@debuggable.com",
+ "name": "Tim Koschützki",
+ "url": "http://debuggable.com/"
},
- "main": "index",
- "engines": {
- "node": "*"
+ "bugs": {
+ "url": "https://github.com/tim-kos/node-retry/issues"
},
"dependencies": {},
+ "description": "Abstraction for exponential and custom retry strategies for failed operations.",
"devDependencies": {
"fake": "0.2.0",
"far": "0.0.1"
},
- "gitHead": "9446e803d6a41ae08732a4a215ae5bf1ff1ccfdd",
- "bugs": {
- "url": "https://github.com/tim-kos/node-retry/issues"
+ "directories": {
+ "lib": "./lib"
},
- "_id": "retry@0.8.0",
- "scripts": {},
- "_shasum": "2367628dc0edb247b1eab649dc53ac8628ac2d5f",
- "_from": "retry@>=0.8.0 <0.9.0",
- "_npmVersion": "2.1.7",
- "_nodeVersion": "0.10.33",
- "_npmUser": {
- "name": "tim-kos",
- "email": "tim@debuggable.com"
+ "dist": {
+ "shasum": "6f697e50a0e4ddc8c8f7fb547a9b60dead43678d",
+ "tarball": "http://registry.npmjs.org/retry/-/retry-0.9.0.tgz"
},
+ "engines": {
+ "node": "*"
+ },
+ "gitHead": "1b621cf499ef7647d005e3650006b93a8dbeb986",
+ "homepage": "https://github.com/tim-kos/node-retry",
+ "license": "MIT",
+ "main": "index",
"maintainers": [
{
"name": "tim-kos",
"email": "tim@debuggable.com"
}
],
- "dist": {
- "shasum": "2367628dc0edb247b1eab649dc53ac8628ac2d5f",
- "tarball": "http://registry.npmjs.org/retry/-/retry-0.8.0.tgz"
+ "name": "retry",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/tim-kos/node-retry.git"
},
- "_resolved": "https://registry.npmjs.org/retry/-/retry-0.8.0.tgz"
+ "scripts": {},
+ "version": "0.9.0"
}