client/src/ast.js
function makePresentable(observable, query) {
  // Whether the entire data structure is in each change
  const pointQuery = Boolean(query.find)

  if (pointQuery) {
    let hasEmitted = false
    const seedVal = null
    // Simplest case: just pass through new_val
    return observable
      .filter(change => !hasEmitted || change.type !== 'state')
      .scan((previous, change) => {
        hasEmitted = true
        if (change.new_val != null) {
          delete change.new_val.$hz_v$
        }
        if (change.old_val != null) {
          delete change.old_val.$hz_v$
        }
        if (change.state === 'synced') {
          return previous
        } else {
          return change.new_val
        }
      }, seedVal)
  } else {
    const seedVal = { emitted: false, val: [] }
    return observable
      .scan((state, change) => {
        if (change.new_val != null) {
          delete change.new_val.$hz_v$
        }
        if (change.old_val != null) {
          delete change.old_val.$hz_v$
        }
        if (change.state === 'synced') {
          state.emitted = true
        }
        state.val = applyChange(state.val.slice(), change)
        return state
      }, seedVal)
      .filter(state => state.emitted)
      .map(x => x.val)
  }
}
function makePresentable(observable, query) {
  // Whether the entire data structure is in each change
  const pointQuery = Boolean(query.find)

  if (pointQuery) {
    let hasEmitted = false
    const seedVal = null
    // Simplest case: just pass through new_val
    return observable
      .filter(change => !hasEmitted || change.type !== 'state')
      .scan((previous, change) => {
        hasEmitted = true
        if (change.new_val != null) {
          delete change.new_val.$hz_v$
        }
        if (change.old_val != null) {
          delete change.old_val.$hz_v$
        }
        if (change.state === 'synced') {
          return previous
        } else {
          return change.new_val
        }
      }, seedVal)
  } else {
    const seedVal = { emitted: false, val: [] }
    return observable
      .scan((state, change) => {
        if (change.new_val != null) {
          delete change.new_val.$hz_v$
        }
        if (change.old_val != null) {
          delete change.old_val.$hz_v$
        }
        if (change.state === 'synced') {
          state.emitted = true
        }
        state.val = applyChange(state.val.slice(), change)
        return state
      }, seedVal)
      .filter(state => state.emitted)
      .map(x => x.val)
  }
}
function makePresentable ( observable , query ) { // Whether the entire data structure is in each change const pointQuery = Boolean ( query . find ) if ( pointQuery ) { let hasEmitted = false const seedVal = null // Simplest case: just pass through new_val return observable . filter ( change => ! hasEmitted || change . type !== 'state' ) . scan ( ( previous , change ) => { hasEmitted = true if ( change . new_val != null ) { delete change . new_val . $hz_v$ } if ( change . old_val != null ) { delete change . old_val . $hz_v$ } if ( change . state === 'synced' ) { return previous } else { return change . new_val } } , seedVal ) } else { const seedVal = { emitted : false , val : [ ] } return observable . scan ( ( state , change ) => { if ( change . new_val != null ) { delete change . new_val . $hz_v$ } if ( change . old_val != null ) { delete change . old_val . $hz_v$ } if ( change . state === 'synced' ) { state . emitted = true } state . val = applyChange ( state . val . slice ( ) , change ) return state } , seedVal ) . filter ( state => state . emitted ) . map ( x => x . val ) } }
Turn a raw observable of server responses into user-presentable events  `observable` is the base observable with full responses coming from the HorizonSocket `query` is the value of `options` in the request
Turn a raw observable of server responses into user - presentable events observable is the base observable with full responses coming from the HorizonSocket query is the value of options in the request