From a715c6c79f4e8c2348badc5ed221c0c127b2db9c Mon Sep 17 00:00:00 2001 From: Anush Date: Sat, 3 Feb 2024 15:12:37 +0530 Subject: [PATCH] refactor: Faster getEmbeddings() (#14) * refactor: Faster get embeddings() * Update fastembed.ts --- src/fastembed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastembed.ts b/src/fastembed.ts index 0197f86..24d19f7 100644 --- a/src/fastembed.ts +++ b/src/fastembed.ts @@ -53,7 +53,7 @@ function getEmbeddings( ): number[][] { const [x, y, z] = dimensions; - return Array.from({ length: x }, (_, index) => { + return new Array(x).fill(undefined).map((_, index) => { const startIndex = index * y * z; const endIndex = startIndex + z; return data.slice(startIndex, endIndex);