|
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 | |
|---|
| 1 | import { isIterateeCall } from '../_internal/isIterateeCall.mjs';
|
|---|
| 2 | import { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER.mjs';
|
|---|
| 3 | import { toInteger } from '../util/toInteger.mjs';
|
|---|
| 4 | import { toString } from '../util/toString.mjs';
|
|---|
| 5 |
|
|---|
| 6 | function 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 |
|
|---|
| 19 | export { repeat };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.