From a9c669dc442c12a94b3db19d3cc6a5ab2fa4e408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyauheni-kryzhyk-deriv=E2=80=9D?= <“yauheni@deriv.me”> Date: Mon, 20 Feb 2023 18:29:52 +0300 Subject: [PATCH 1/4] refactor: packages shared utils array ts migration --- packages/shared/src/utils/array/{array.js => array.ts} | 4 ++-- packages/shared/src/utils/array/{index.js => index.ts} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/shared/src/utils/array/{array.js => array.ts} (81%) rename packages/shared/src/utils/array/{index.js => index.ts} (100%) diff --git a/packages/shared/src/utils/array/array.js b/packages/shared/src/utils/array/array.ts similarity index 81% rename from packages/shared/src/utils/array/array.js rename to packages/shared/src/utils/array/array.ts index 738e7ee40ee5..ad2830af1c16 100644 --- a/packages/shared/src/utils/array/array.js +++ b/packages/shared/src/utils/array/array.ts @@ -1,4 +1,4 @@ -export const shuffleArray = array => { +export function shuffleArray(array: T[]): T[] { if (Array.isArray(array)) { for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); @@ -6,4 +6,4 @@ export const shuffleArray = array => { } } return array; -}; +} diff --git a/packages/shared/src/utils/array/index.js b/packages/shared/src/utils/array/index.ts similarity index 100% rename from packages/shared/src/utils/array/index.js rename to packages/shared/src/utils/array/index.ts From aae71fd68cebcc94230feb5e0967696f247efb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyauheni-kryzhyk-deriv=E2=80=9D?= <“yauheni@deriv.me”> Date: Tue, 21 Feb 2023 09:02:40 +0300 Subject: [PATCH 2/4] refactor: array check remove --- packages/shared/src/utils/array/array.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/shared/src/utils/array/array.ts b/packages/shared/src/utils/array/array.ts index ad2830af1c16..28f4b0c9cd4a 100644 --- a/packages/shared/src/utils/array/array.ts +++ b/packages/shared/src/utils/array/array.ts @@ -1,9 +1,7 @@ export function shuffleArray(array: T[]): T[] { - if (Array.isArray(array)) { - for (let i = array.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [array[i], array[j]] = [array[j], array[i]]; - } + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; } return array; } From 28168ca869aa9b1efefb72a90f284c9ad26a36b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyauheni-kryzhyk-deriv=E2=80=9D?= <“yauheni@deriv.me”> Date: Tue, 21 Feb 2023 09:19:42 +0300 Subject: [PATCH 3/4] refactor: function returned to arrow --- packages/shared/src/utils/array/array.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/utils/array/array.ts b/packages/shared/src/utils/array/array.ts index 28f4b0c9cd4a..24f449cf0168 100644 --- a/packages/shared/src/utils/array/array.ts +++ b/packages/shared/src/utils/array/array.ts @@ -1,7 +1,8 @@ -export function shuffleArray(array: T[]): T[] { +export const shuffleArray = (array: T[]): T[] => { for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } + return array; -} +}; From def91ad1097e3a4c722f074d7981bad042712bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyauheni-kryzhyk-deriv=E2=80=9D?= <“yauheni@deriv.me”> Date: Tue, 21 Feb 2023 09:19:56 +0300 Subject: [PATCH 4/4] refactor: function returned to arrow --- packages/shared/src/utils/array/array.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/shared/src/utils/array/array.ts b/packages/shared/src/utils/array/array.ts index 24f449cf0168..a7695bd058ef 100644 --- a/packages/shared/src/utils/array/array.ts +++ b/packages/shared/src/utils/array/array.ts @@ -3,6 +3,5 @@ export const shuffleArray = (array: T[]): T[] => { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } - return array; };