MeTuple.sub constructor

MeTuple.sub(
  1. String key,
  2. Iterable<String> val
)

Create a tuple with a comma-separated values

Implementation

factory MeTuple.sub(String key, Iterable<String> val) {
  final result = StringBuffer();
  for (final v in val) {
    result.write(v.replaceAll(',', r'\,'));
    result.write(',');
  }

  final data = result.toString();
  var p = data.length - 1;
  while (data.codeUnitAt(p) == 0x2c) {
    p--;
  }

  return MeTuple(key, data.substring(0, p + 1));
}