run0 static method

Object run0(
  1. int index,
  2. List<Function> fns,
  3. Socket socket,
  4. Function fn,
)

Implementation

static Object run0(
    int index, List<Function> fns, Socket socket, Function fn) {
  return fns[index](socket, (err) {
    // upon error, short-circuit
    if (err) return fn(err);

    // if no middleware left, summon callback
    if (fns.length <= index + 1) return fn(null);

    // go on to next
    return run0(index + 1, fns, socket, fn);
  });
}