Published
Edited
Jan 11, 2022
Importers
3 stars
Insert cell
Insert cell
observeHighland(randomIconsStream)
Insert cell
observeHighland(randomIconsStream.observe())
Insert cell
observeHighland(
randomIconsStream
.observe()
.through(lastN(10))
.invoke('join', [''])
)
Insert cell
Insert cell
observeHighland(
randomIconsStream
.observe()
.through(lastN(n))
.invoke('join', [''])
)
Insert cell
observeHighland(
randomIconsStream
.observe()
.uniq()
.through(lastN(n))
.invoke('join', [''])
)
Insert cell
observeHighland(
randomIconsStream
.observe()
.through(lastN(n))
.invoke('join', [''])
.zip(
randomIconsStream
.observe()
.uniq()
.through(lastN(n))
.invoke('join', [''])
)
.map(([first, last]) => `\n${first}\n${last}\n`)
)
Insert cell
observeHighland(
randomIconsStream
.observe()
.zip(timer.fork().latest())
.map(([icon, elapsedTime]) => ({ icon, elapsedTime }))
)
Insert cell
observeHighland(
randomIconsStream
.observe()
.uniq()
.zip(timer.fork().latest())
.map(([icon, elapsedTime]) => ({ icon, elapsedTime }))
)
Insert cell
Insert cell
observeHighland(timer.observe().throttle(100))
Insert cell
observeHighland(
highland([{id:1}, {status: 2}, {id:2}, 10, null, {id:3}, [], {id:4}, {id:6}])
.flatMap(delay(1000))
.pluck('id')
.collect()
)
Insert cell
Insert cell
Insert cell
randomIconsStream = highland(randomIcons())
.flatMap(delay(delayTime))
// .take(50)
Insert cell
observeHighland(
highland(randomNumber(0, 100))
.through(average)
.through(takeEveryNth(10000))
.take(10)
.collect()
)
Insert cell
observeHighland(
integerStream
.flatMap(delay(100))
)
Insert cell
observeHighland(
integerStream
.observe()
.through(sample)
)
Insert cell
observeHighland(
integerStream
.observe()
.through(takeEveryNth(10))
)
Insert cell
takeEveryNth = nth => stream => stream.scan(
{ },
({ count = 0, last }, next) => ((count + 1) % nth) === 0 ? { count: count + 1, last: next } : { count: count + 1, last }
)
.map(highland.get('last'))
.uniq()
.drop(1) //the first value emitted is the default case
Insert cell
sample = stream => stream.scan(
[],
(last, next) => _.random(0,1) === 1 ? next : last
)
.uniq()
.drop(1) //the first value emitted is the default case
Insert cell
average = (stream) => stream
.scan(
{ count: 0, sum: 0, average: 0 },
({ count, sum, average }, number) => ({
number,
count: count + 1,
sum: sum + number,
average: (average * count + number)/ (count + 1)
})
)
.drop(1) //the first value emitted is the default case
Insert cell
randomNumberStream = (min, max) => highland(randomNumber(min, max))
.flatMap(delay(delayTime))
Insert cell
observeHighland = stream => Generators.queue(
(change) => {
stream.errors(error => change(`error: ${error}`)).each(change)
return () => change('invalidated!') && stream.destroy()
}
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
_ = require('lodash')
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more