Skip to content

Commit

Permalink
Replace 'while' loop with 'padStart' function (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
nir11 authored Nov 14, 2023
1 parent 6cb1d9d commit d2eb73b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/js/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d2eb73b

Please sign in to comment.