| OLD | NEW |
| (Empty) |
| 1 part of petitparser.reflection; | |
| 2 | |
| 3 /// Returns a copy of [parser] with all settable parsers removed. | |
| 4 Parser removeSettables(Parser parser) { | |
| 5 return transformParser(parser, (each) { | |
| 6 while (each is SettableParser) { | |
| 7 each = each.children.first; | |
| 8 } | |
| 9 return each; | |
| 10 }); | |
| 11 } | |
| 12 | |
| 13 /// Returns a copy of [parser] with all duplicates parsers collapsed. | |
| 14 Parser removeDuplicates(Parser parser) { | |
| 15 var uniques = new Set(); | |
| 16 return transformParser(parser, (source) { | |
| 17 var target = uniques.firstWhere((each) { | |
| 18 return source != each && source.isEqualTo(each); | |
| 19 }, orElse: () => null); | |
| 20 if (target == null) { | |
| 21 uniques.add(source); | |
| 22 return source; | |
| 23 } else { | |
| 24 return target; | |
| 25 } | |
| 26 }); | |
| 27 } | |
| OLD | NEW |