Platform
Resources
Pricing
Sign in
Contact us
Stephan Schmid
Workspace
Fork
Published
By
Stephan Schmid
Edited
Jun 7, 2019
3 stars
Insert cell
Insert cell
{
for
await
(
const
{
id
,
src
}
of
delay
(
2
,
filter
(
map
(
getData
(
)
)
)
)
)
{
yield
html
`Fetched Image "${
id
}" by generator from Test API:<br /><img src="${
src
}" style="height: 100px" />`
}
}
Insert cell
{
for
await
(
const
{
id
,
src
}
of
filter
(
delay
(
2
,
map
(
asyncIterable
)
)
)
)
{
yield
html
`Fetched Image "${
id
}" by iterable object from Test API:<br /><img src="${
src
}" style="height: 100px" />`
}
}
Insert cell
async
function
*
filter
(
iterable
)
{
for
await
(
const
entry
of
iterable
)
{
const
num
=
entry
.
id
.
split
(
' '
)
.
pop
(
)
if
(
num
%
2
===
0
)
{
yield
entry
}
}
}
Insert cell
async
function
*
delay
(
seconds
,
iterable
)
{
for
await
(
const
value
of
iterable
)
{
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
seconds
*
1000
)
)
yield
value
}
}
Insert cell
async
function
*
map
(
iterable
)
{
for
await
(
const
{
name
:
id
,
url
:
src
}
of
iterable
)
{
yield
{
id
,
src
}
}
}
Insert cell
function
getData
(
)
{
const
generator
=
async
function
*
(
)
{
const
entries
=
await
fetch
(
uri
)
.
then
(
(
response
)
=>
response
.
json
(
)
)
.
then
(
(
{
entries
}
)
=>
entries
)
for
(
const
entry
of
entries
)
{
yield
entry
}
}
return
generator
(
)
}
Insert cell
asyncIterable
=
{
return
{
entries
:
await
fetch
(
uri
)
.
then
(
(
response
)
=>
response
.
json
(
)
)
.
then
(
(
{
entries
}
)
=>
entries
)
,
[
Symbol
.
asyncIterator
]
:
async
function
*
(
)
{
for
(
const
entry
of
this
.
entries
)
{
yield
entry
}
}
}
}
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
filter
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
delay
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
map
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
asyncIterable
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
uri
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML