From 0c6d99a86a7ef4adffe469141be593cdade5962c Mon Sep 17 00:00:00 2001 From: nir11 Date: Tue, 22 Aug 2023 21:18:20 +0300 Subject: [PATCH] Replace 'while' loop with 'padStart' function --- src/js/asset.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/js/asset.ts b/src/js/asset.ts index 4a99c28..513515d 100644 --- a/src/js/asset.ts +++ b/src/js/asset.ts @@ -181,12 +181,8 @@ function getAssetSelector(assetDictType: string) { Adds leading zeroes to the input hex-string to complement the expected length. */ function addLeadingZeroes(hexStr: string, expectedLen: number) { - let res = hexStr; - assert(res.length <= expectedLen); - while (res.length < expectedLen) { - res = '0' + res; - } - return res; + assert(hexStr.length <= expectedLen); + return hexStr.padStart(expectedLen, '0'); } function blobToBlobHash(blob: string) {