(str: string, targetLength: number, addString: string)
| 1 | export function unshiftString(str: string, targetLength: number, addString: string): string { |
| 2 | targetLength = targetLength > 0 ? targetLength : 0; |
| 3 | addString = String((typeof addString !== 'undefined' && typeof addString !== 'object') ? addString : ' '); |
| 4 | str = (str === undefined || str === null) ? '' : String(str); |
| 5 | if (str.length >= targetLength) { |
| 6 | return String(str); |
| 7 | } else { |
| 8 | targetLength = targetLength - str.length; |
| 9 | if (targetLength > addString.length) { |
| 10 | addString += addString.repeat(targetLength / addString.length); |
| 11 | } |
| 12 | return addString.slice(0, targetLength) + String(str); |
| 13 | } |
| 14 | } |
no test coverage detected