From 075f16caac5236cb04c98ae7b3a989766d764bb3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Jul 2017 17:04:57 +0200 Subject: Remove "function" in favor of () => {} --- server/helpers/database-utils.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'server/helpers/database-utils.ts') diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index e174dc3e9..987e42eb0 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts @@ -8,13 +8,11 @@ type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] function retryTransactionWrapper (functionToRetry: (... args) => Promise, options: RetryTransactionWrapperOptions) { const args = options.arguments ? options.arguments : [] - return transactionRetryer( - function (callback) { - functionToRetry.apply(this, args) + return transactionRetryer(callback => { + functionToRetry.apply(this, args) .then(result => callback(null, result)) .catch(err => callback(err)) - } - ) + }) .catch(err => { // Do not throw the error, continue the process logger.error(options.errorMessage, err) @@ -26,14 +24,12 @@ function transactionRetryer (func: Function) { retry({ times: 5, - errorFilter: function (err) { + errorFilter: err => { const willRetry = (err.name === 'SequelizeDatabaseError') logger.debug('Maybe retrying the transaction function.', { willRetry }) return willRetry } - }, func, function (err) { - err ? rej(err) : res() - }) + }, func, err => err ? rej(err) : res()) }) } -- cgit v1.2.3