Line data Source code
1 1 : export const stringRepeat = (() => { 2 2 : try { 3 2 : if (("x" as any).repeat(3) === "xxx") { 4 0 : return (pattern: string, count: number): string => 5 0 : (pattern as any).repeat(count); 6 2 : } 7 2 : } catch (_) { 8 : // nothing to do here 9 0 : } 10 0 : return (pattern: string, count: number): string => { 11 0 : let result = ""; 12 0 : while (count > 0) { 13 0 : if (count & 1) { 14 0 : result += pattern; 15 0 : } 16 0 : count >>= 1; 17 0 : pattern += pattern; 18 0 : } 19 0 : return result; 20 0 : }; 21 1 : })();