source: node_modules/es-toolkit/dist/compat/string/repeat.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 525 bytes
Line 
1import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
2import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER.mjs';
3import { toInteger } from '../util/toInteger.mjs';
4import { toString } from '../util/toString.mjs';
5
6function repeat(str, n, guard) {
7 if (guard ? isIterateeCall(str, n, guard) : n === undefined) {
8 n = 1;
9 }
10 else {
11 n = toInteger(n);
12 }
13 if (n < 1 || n > MAX_SAFE_INTEGER) {
14 return '';
15 }
16 return toString(str).repeat(n);
17}
18
19export { repeat };
Note: See TracBrowser for help on using the repository browser.