Skip to content

Commit

Permalink
debugging remove infinate loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellie Frymire authored and Ellie Frymire committed Aug 31, 2018
1 parent df85563 commit 0c1b006
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions read_and_reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,41 @@ auth.twitter_oauth = {
const parse = (text) => {
console.log('parsing...')
const data = text.split('\n').filter(e => e.slice(0,4).search(/\d{4}/) === 0)
if (data.length) {
const delimeter = data[0][4]
const parsed = [...data].map(d => d.split(delimeter).map(e => +e.trim().replace(/[^\.\d]+/g,'')))
console.log('parsed data = ', parsed)
return parsed
} else {
return
}

const delimeter = data[0][4]
const parsed = [...data].map(d => d.split(delimeter).map(e => +e.trim().replace(/[^\.\d]+/g,'')))
console.log('parsed data = ', parsed)
return parsed
}

const makeViz = (data) => {
console.log('vizing... ')

if (data) {
const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')
}
const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')
}
}

const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]
const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]

const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)
const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)

return viz
} else {
return false;
}
return viz
}

module.exports.read_and_reply = read_and_reply = (tweetEvent) => {
Expand Down

0 comments on commit 0c1b006

Please sign in to comment.