code: function applyChanges(state, changes, queryInfo) {
    if (state === undefined) return state;
    return changes.reduce(function (stateValue, change) {
      return applyChange(stateValue, change, queryInfo);
    }, state);
  }
docs: https://github.com/rethinkdb/horizon/blob/next/client/src/ast.js