From 85d9d6fe312f5ed68db22a28b84b6c8f257f9ec9 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Fri, 30 Aug 2024 14:39:09 -0700 Subject: [PATCH] perf(GoogleAuth): Improve Client Creation From Files/Streams Perf (#1856) --- src/auth/googleauth.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auth/googleauth.ts b/src/auth/googleauth.ts index ae7a99a1..3d08ec7f 100644 --- a/src/auth/googleauth.ts +++ b/src/auth/googleauth.ts @@ -787,15 +787,15 @@ export class GoogleAuth { 'Must pass in a stream containing the Google auth settings.' ); } - let s = ''; + const chunks: string[] = []; inputStream .setEncoding('utf8') .on('error', reject) - .on('data', chunk => (s += chunk)) + .on('data', chunk => chunks.push(chunk)) .on('end', () => { try { try { - const data = JSON.parse(s); + const data = JSON.parse(chunks.join('')); const r = this._cacheClientFromJSON(data, options); return resolve(r); } catch (err) {