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/custom-validators/pods.ts | 2 +- server/helpers/custom-validators/remote/videos.ts | 6 +++--- server/helpers/custom-validators/videos.ts | 2 +- server/helpers/database-utils.ts | 14 +++++--------- server/helpers/utils.ts | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index ec9f26cc8..0519def52 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts @@ -9,7 +9,7 @@ function isHostValid (host: string) { function isEachUniqueHostValid (hosts: string[]) { return isArray(hosts) && hosts.length !== 0 && - hosts.every(function (host) { + hosts.every(host => { return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host) }) } diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts index e14673cb3..b33d8c9be 100644 --- a/server/helpers/custom-validators/remote/videos.ts +++ b/server/helpers/custom-validators/remote/videos.ts @@ -33,7 +33,7 @@ const ENDPOINT_ACTIONS = REQUEST_ENDPOINT_ACTIONS[REQUEST_ENDPOINTS.VIDEOS] function isEachRemoteRequestVideosValid (requests: any[]) { return isArray(requests) && - requests.every(function (request) { + requests.every(request => { const video = request.data if (!video) return false @@ -63,7 +63,7 @@ function isEachRemoteRequestVideosValid (requests: any[]) { function isEachRemoteRequestVideosQaduValid (requests: any[]) { return isArray(requests) && - requests.every(function (request) { + requests.every(request => { const video = request.data if (!video) return false @@ -79,7 +79,7 @@ function isEachRemoteRequestVideosQaduValid (requests: any[]) { function isEachRemoteRequestVideosEventsValid (requests: any[]) { return isArray(requests) && - requests.every(function (request) { + requests.every(request => { const eventData = request.data if (!eventData) return false diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index e335b09d1..62132acb1 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -68,7 +68,7 @@ function isVideoNameValid (value: string) { function isVideoTagsValid (tags: string[]) { return isArray(tags) && validator.isInt(tags.length.toString(), VIDEOS_CONSTRAINTS_FIELDS.TAGS) && - tags.every(function (tag) { + tags.every(tag => { return exists(tag) && validator.isLength(tag, VIDEOS_CONSTRAINTS_FIELDS.TAG) }) } 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()) }) } diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index e99a48393..9c08afb71 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -18,7 +18,7 @@ interface FormatableToJSON { function getFormatedObjects (objects: T[], objectsTotal: number) { const formatedObjects: U[] = [] - objects.forEach(function (object) { + objects.forEach(object => { formatedObjects.push(object.toFormatedJSON()) }) -- cgit v1.2.3