MCPcopy Index your code
hub / github.com/formatjs/formatjs / repeat

Function repeat

packages/ecma402-abstract/utils.ts:4–13  ·  view source on GitHub ↗
(s: string, times: number)

Source from the content-addressed store, hash-verified

2import {memoize, strategies} from '@formatjs/fast-memoize'
3
4export function repeat(s: string, times: number): string {
5 if (typeof s.repeat === 'function') {
6 return s.repeat(times)
7 }
8 const arr = Array.from({length: times})
9 for (let i = 0; i < arr.length; i++) {
10 arr[i] = s
11 }
12 return arr.join('')
13}
14
15export function setInternalSlot<
16 Instance extends object,

Callers 3

FormatNumericToStringFunction · 0.85
ToRawPrecisionFunction · 0.85
ToRawFixedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected