@@ -19,11 +19,11 @@ import constant from 'lodash/constant';
1919 * * `interval` - The time to wait between retries, in milliseconds. The
2020 * default is `0`. The interval may also be specified as a function of the
2121 * retry count (see example).
22- * * `continueOperation ` - An optional synchronous function that is invoked on
23- * erroneous result with the the error . If it returns `true` the retry attempts
24- * will continue, if the function returns `false` the retry flow is aborted
25- * with the current attempt's error and result being returned to the final
26- * callback. Invoked with (err).
22+ * * `errorFilter ` - An optional synchronous function that is invoked on
23+ * erroneous result. If it returns `true` the retry attempts will continue;
24+ * if the function returns `false` the retry flow is aborted with the current
25+ * attempt's error and result being returned to the final callback.
26+ * Invoked with (err, result ).
2727 * * If `opts` is a number, the number specifies the number of times to retry,
2828 * with the default interval of `0`.
2929 * @param {Function } task - A function which receives two arguments: (1) a
@@ -70,7 +70,7 @@ import constant from 'lodash/constant';
7070 * // try calling apiMethod only when error condition satisfies, all other
7171 * // errors will abort the retry control flow and return to final callback
7272 * async.retry({
73- * continueOperation : function(err) {
73+ * errorFilter : function(err) {
7474 * return err.message === 'Temporary error'; // only retry on a specific error
7575 * }
7676 * }, apiMethod, function(err, result) {
@@ -104,7 +104,7 @@ export default function retry(opts, task, callback) {
104104 t . interval :
105105 constant ( + t . interval || DEFAULT_INTERVAL ) ;
106106
107- acc . continueOperation = t . continueOperation ;
107+ acc . errorFilter = t . errorFilter ;
108108 } else if ( typeof t === 'number' || typeof t === 'string' ) {
109109 acc . times = + t || DEFAULT_TIMES ;
110110 } else {
@@ -127,14 +127,10 @@ export default function retry(opts, task, callback) {
127127 var attempt = 1 ;
128128 function retryAttempt ( ) {
129129 task ( function ( err ) {
130- if ( err && attempt ++ < options . times ) {
131- var proceed = typeof options . continueOperation != 'function' ||
132- options . continueOperation ( err ) ;
133- if ( proceed ) {
134- setTimeout ( retryAttempt , options . intervalFunc ( attempt ) ) ;
135- } else {
136- callback . apply ( null , arguments ) ;
137- }
130+ if ( err && attempt ++ < options . times &&
131+ ( typeof options . errorFilter != 'function' ||
132+ options . errorFilter ( err ) ) ) {
133+ setTimeout ( retryAttempt , options . intervalFunc ( attempt ) ) ;
138134 } else {
139135 callback . apply ( null , arguments ) ;
140136 }
0 commit comments