Dan Cojocaru
3 years ago
3 changed files with 16 additions and 14 deletions
@ -0,0 +1,12 @@
|
||||
extension TakeWhile on String { |
||||
String takeWhile(Function charValidator) { |
||||
StringBuffer output = StringBuffer(); |
||||
|
||||
for (final char in this.codeUnits) { |
||||
if (charValidator(char)) output.writeCharCode(char); |
||||
else break; |
||||
} |
||||
|
||||
return output.toString(); |
||||
} |
||||
} |
Loading…
Reference in new issue