lib/transform.js
function transform (raw, protocol, board) {
  const reducer = (acc, file) => acc.concat([{
    filename: file.filename,
    url: webmUrl(protocol, board, file.tim),
    thumbnail: thumbUrl(protocol, board, file.tim)
  }])

  const payload = {
    webms: raw.posts.filter(isWebm).reduce(reducer, [])
  }

  if (raw.posts[0].sub) {
    payload.subject = raw.posts[0].sub
  }

  return payload
}
function transform (raw, protocol, board) {
  const reducer = (acc, file) => acc.concat([{
    filename: file.filename,
    url: webmUrl(protocol, board, file.tim),
    thumbnail: thumbUrl(protocol, board, file.tim)
  }])

  const payload = {
    webms: raw.posts.filter(isWebm).reduce(reducer, [])
  }

  if (raw.posts[0].sub) {
    payload.subject = raw.posts[0].sub
  }

  return payload
}
function transform ( raw , protocol , board ) { const reducer = ( acc , file ) => acc . concat ( [ { filename : file . filename , url : webmUrl ( protocol , board , file . tim ) , thumbnail : thumbUrl ( protocol , board , file . tim ) } ] ) const payload = { webms : raw . posts . filter ( isWebm ) . reduce ( reducer , [ ] ) } if ( raw . posts [ 0 ] . sub ) { payload . subject = raw . posts [ 0 ] . sub } return payload }
Transforms a 4chan thread payload into a JSON with webm data
@func    transform
@param   {Object} raw      Raw thread JSON payload
@param   {String} protocol Protocol to use for generating links
@param   {String} board    Board shortname, eg. 'b'
@returns {Object}          JSON containing thread subject and webm data
Transforms a 4chan thread payload into a JSON with webm data