(text: string, textTransform: CoreTypes.TextTransformType)
| 484 | } |
| 485 | |
| 486 | export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string { |
| 487 | if (!text || !isString(text)) { |
| 488 | return ''; |
| 489 | } |
| 490 | |
| 491 | switch (textTransform) { |
| 492 | case 'uppercase': |
| 493 | return NSStringFromNSAttributedString(text).uppercaseString; |
| 494 | case 'lowercase': |
| 495 | return NSStringFromNSAttributedString(text).lowercaseString; |
| 496 | case 'capitalize': |
| 497 | return NSStringFromNSAttributedString(text).capitalizedString; |
| 498 | default: |
| 499 | return text; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | function NSStringFromNSAttributedString(source: NSAttributedString | string): NSString { |
| 504 | return NSString.stringWithString((source instanceof NSAttributedString && source.string) || <string>source); |
no test coverage detected