Repository URL to install this package:
|
Version:
0.9.2 ▾
|
// (c) Copyright 2023 Supertenant Ltd. - all rights reserved.
// See LICENSE file in project root for license terms.
"use strict";module.exports=leftPad;const cache=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000","00000000000000000000000000","000000000000000000000000000","0000000000000000000000000000","00000000000000000000000000000","000000000000000000000000000000","0000000000000000000000000000000","00000000000000000000000000000000"];function leftPad(str,len){if((len-=str.length)<=0)return str;if(len<33)return cache[len]+str;let ch="0",pad="";for(;;){if(1&len&&(pad+=ch),!(len>>=1))break;ch+=ch}return pad+str}