diff --git a/src/index.ts b/src/index.ts index 9da1c1b..9116271 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,6 +71,7 @@ export { b2a, a2b, parse, + repeat, //number randomInt, round, diff --git a/src/utils/index.ts b/src/utils/index.ts index 374893f..661dbbb 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -220,6 +220,20 @@ export function parse(token: string){ return JSON.parse(jsonPayload); } +/** + * Repeat a string n times + * @param str The string to repeat + * @param count Number of times to repeat + * @returns Repeated string + */ +export function repeat(str: string, count: number): string { + let result = ""; + for (let i = 0; i < count; i++) { + result += str; + } + return result; +} + /** * All string utils */ @@ -236,7 +250,8 @@ const string = { rgbToHex, b2a, a2b, - parse + parse, + repeat, } /**