Skip to content

Commit

Permalink
add repeat util
Browse files Browse the repository at this point in the history
  • Loading branch information
tyzoo committed Jan 3, 2023
1 parent a4174d6 commit b290f0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export {
b2a,
a2b,
parse,
repeat,
//number
randomInt,
round,
Expand Down
17 changes: 16 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -236,7 +250,8 @@ const string = {
rgbToHex,
b2a,
a2b,
parse
parse,
repeat,
}

/**
Expand Down

0 comments on commit b290f0c

Please sign in to comment.