Skip to content

Commit 85d9d6f

Browse files
authored
perf(GoogleAuth): Improve Client Creation From Files/Streams Perf (#1856)
1 parent a56b198 commit 85d9d6f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/auth/googleauth.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -787,15 +787,15 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {
787787
'Must pass in a stream containing the Google auth settings.'
788788
);
789789
}
790-
let s = '';
790+
const chunks: string[] = [];
791791
inputStream
792792
.setEncoding('utf8')
793793
.on('error', reject)
794-
.on('data', chunk => (s += chunk))
794+
.on('data', chunk => chunks.push(chunk))
795795
.on('end', () => {
796796
try {
797797
try {
798-
const data = JSON.parse(s);
798+
const data = JSON.parse(chunks.join(''));
799799
const r = this._cacheClientFromJSON(data, options);
800800
return resolve(r);
801801
} catch (err) {

0 commit comments

Comments
 (0)