| 86 | | Date |
| 87 | |
| 88 | function mergeLiteral<T>( |
| 89 | parts: MessageFormatPart<T>[] |
| 90 | ): MessageFormatPart<T>[] { |
| 91 | if (parts.length < 2) { |
| 92 | return parts |
| 93 | } |
| 94 | return parts.reduce((all, part) => { |
| 95 | const lastPart = all[all.length - 1] |
| 96 | if ( |
| 97 | !lastPart || |
| 98 | lastPart.type !== PART_TYPE.literal || |
| 99 | part.type !== PART_TYPE.literal |
| 100 | ) { |
| 101 | all.push(part) |
| 102 | } else { |
| 103 | lastPart.value += part.value |
| 104 | } |
| 105 | return all |
| 106 | }, [] as MessageFormatPart<T>[]) |
| 107 | } |
| 108 | |
| 109 | export function isFormatXMLElementFn<T>( |
| 110 | el: PrimitiveType | T | FormatXMLElementFn<T> |