From b2ae59d821344ff5d1ca3b7e8ff8623c0dca5ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateus=20Felipe=20Gon=C3=A7alves?= Date: Tue, 13 Feb 2024 12:19:02 -0300 Subject: [PATCH] feat(shuffle-array): check array type on parameter level --- src/lib/shuffleArray.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/shuffleArray.ts b/src/lib/shuffleArray.ts index 86cb6daf..3925ec7a 100644 --- a/src/lib/shuffleArray.ts +++ b/src/lib/shuffleArray.ts @@ -1,6 +1,4 @@ -export function shuffleArray(array: T) { - if (!Array.isArray(array)) throw new Error('"array" is not an array') - +export function shuffleArray(array: 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]]