1 | import { invariant, PartitionPattern } from '@formatjs/ecma402-abstract';
|
2 | export function MakePartsList(pattern, unit, parts) {
|
3 | var patternParts = PartitionPattern(pattern);
|
4 | var result = [];
|
5 | for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
|
6 | var patternPart = patternParts_1[_i];
|
7 | if (patternPart.type === 'literal') {
|
8 | result.push({
|
9 | type: 'literal',
|
10 | value: patternPart.value,
|
11 | });
|
12 | }
|
13 | else {
|
14 | invariant(patternPart.type === '0', "Malformed pattern ".concat(pattern));
|
15 | for (var _a = 0, parts_1 = parts; _a < parts_1.length; _a++) {
|
16 | var part = parts_1[_a];
|
17 | result.push({
|
18 | type: part.type,
|
19 | value: part.value,
|
20 | unit: unit,
|
21 | });
|
22 | }
|
23 | }
|
24 | }
|
25 | return result;
|
26 | }
|