parseArray method
Implementation
Future<List> parseArray(LazyStream s) {
//closure
Future<List> consumeList(LazyStream s, int len, List lst) {
assert(len >= 0);
if (len == 0) {
return Future.value(lst);
}
return parseredisresponse(s).then((resp) {
lst.add(resp);
return consumeList(s, len - 1, lst);
});
}
//end of closure
return parseInt(s).then((i) {
//get len
if (i == -1) //null
return [null];
if (i >= 0) {
//i of array data
List a = [];
return consumeList(s, i, a);
} else {
return Future.error(
RedisRuntimeError("cant process array data less than -1"));
}
});
}