►
From YouTube: An Introduction to Streaming Iterables - Alan Shaw
Description
Source, transform, sink and duplex - these words explained
For more information on IPFS
- visit the project website: https://ipfs.io
- or follow IPFS on Twitter: https://twitter.com/IPFS
Sign up to get IPFS news, including releases, ecosystem updates, and community announcements in your inbox, each Tuesday: http://eepurl.com/gL2Pi5
A
I'm
going
to
talk
to
you
about
streaming,
it
of
intervals
in
in
je
s
and
J
si
via
this
I'm,
going
to
explain
a
little
bit
about
the
types
of
these
sources,
transform
sinks
and
duplex
is,
and
that's
all
for
now,
and
so
it
all
started
with
iterators
and
lots
of
things
in
JavaScript
are
iterable
at
the
moment.
Like
sets
maps
and
arrays.
So
typically,
you'd
have
like
some
things,
like
some
data.
A
It
will
unpack
that
object
that
it
gets
back
and
give
me
the
value.
So
I,
don't
I,
don't
get
that
value
done
thing.
I
just
get
the
value
and
it
automatically
finishes
the
loop
when
everything
is
done
and
I
get
I
get
the
values
which
is
great,
so
that's
iterators
or
iterables.
And
then
what
happened
is
that
async
Ettore
iterators
came
along
and
and
instead
of
next
returning
an
object,
that's
just
done
and
the
value
it
returns.
A
promise
of
that
object.
A
So
now
our
thing
that
we're
getting
data
relative
can
asynchronously,
give
us
things,
and
so
what
else
do
we
know
that
yield
things
asynchronously
and
streams?
So
what
we
can
do
now
is
we
can
use
a
language
native
thing
to
stream
data
without
any
libraries
in
the
browser.
So
that's
super
fun
and
it's
really
easy
I.
So
this
is
a
an
iterable
that
I
made
called,
which
I
called
infinite
Rand,
because
it
it
it
yields
a
random
numbers
forever.
A
So
that's
kind
of
cool
and
what
you
all
you
can
do
with
with
async
iterables
is
you
can
use
a
for
a
wait,
loops
and
then
I
can
just
get
every
value.
So
this
is
the
iterator
we're
saying
every
give
me
every
value
out
of
this
infinite
random
and
it
will
just
keep
chugging
and
chugging
and
chugging
and
giving
me
random
values.
So
let's
have
a
look.
I
can
just
place
this
into
here
and
it
will
just
kind
of
occasionally
spurt
out
some
random
random
values,
which
is
cool.
A
It's
just
easy
because
streaming
is
now
like
it's
a
for
loop.
It
like
you,
don't
you
no
longer
have
to
think
about.
Like
nodejs
streams
and
like
attaching
data
events
and
touching
end
events
and
piping
them
to
places
and
stuff
like
that,
it's
it's
it's
just
a
for
loop.
This
is
one
of
the
first
things
you
learn
when
you're
a
programmer,
and
so
alright,
that's
great,
but
wait
a
minute.
We
it's
not
just.
A
We
didn't
just
read
from
streams,
we
also
write
to
them
and
we
also
have
streams
that
can
take
some
data
and
transform
it
and
spit
out
some
data
and
then
in
network
stuff.
We
have
duplex
streams,
so
we
can
have
kind
of
not
really
connected
data
to
servers
and
back
and
vice-versa.
So
we
need
the
whole
family
of
streams,
and
so
sources
is
what
I've
been
talking
about.
So
far,
it's
just
a
it's
just
an
async
iterable.
So
that's
what
we've
called
a
source.
A
sync
is
just
a
function.
A
So
here
we've
got
like
a
logger
sync
and
it
the
function
is
just
a
function
and
it
takes
a
source
and
then
it
does
something
with
it.
It
usually
consumes
it
because
otherwise
it's
a
bit
useless
and
then
optionally.
It
can
return
something.
So
this
is
this:
logger
sync
takes
the
source
iterates
over
it
and
logs
out
each
value
is
kind
of
like
what
we
did
just
a
second
ago
with
the
random
random
thing.
But
we've
kind
of
formalized
it
as
a
thing.
A
A
transform
is,
is
a
kind
of
sync
and
a
source
because
it
takes
it.
So
this
is
our
transform
the
doubler
thing
here
and
it
it
takes
a
source
and
it
returns
so
I'm
not
gonna,
get
into
generators,
but
generators.
When
you
call
they
will
return
you
a
and
in
this
because
an
async
generates
it
or
return
you
an
async
iterable
and
what
we,
what
it
does,
is
it
just
suspends
a
execution
of
function
until
it
anyways
matter.
The
point
is
it:
it
takes
a
source
and
it
returns
an
async
iterable.
A
So
it's
just
a
function
that
returns
an
async
iterable,
so
that's
kind
of
cool,
that's
a
transform,
and
then
we
have
duplex
which
is
kind
of
the
weird
one,
because
it's
actually
an
object
which
has
a
source
and
a
sink,
and
it's
kind
of
like
a
transform,
like
you
can
model
a
transform
as
a
duplex
that
where
these
two
things
are
connected
in
some
way
so
kind
of
fun
and
then
so
what
you
will
typically
do,
because
I'm
I
didn't
show
you
the
things
I
mean.
So
what
we
can
do
here.
A
I
can
just
take
these.
So
this
is
the
transform
which
doubles
my
randomness.
So
if
I
paste
that
in
instead
of
getting
like
zero
dot
values,
I'll
get
doubled,
doubled,
randoms
and
so
that's
kind
of
fun.
There
we
go
and
then
so
often
you
kind
of
want
and
some
utilities
and
things
for
working
with
async
iterators,
because
one
of
the
most
useful
things
that
you
might
want
is
pipe
because
you,
you
kind
of
sometimes
have
these
pipelines
of
streams
that
you
kind
of
want
to
keep
separate
as
different
different
kind
of
discrete
pieces
of
functionality.
A
But
you
don't
want
to
have
to
like
like
stuff
like
this.
Where
we've
got,
we've
got
this,
the
the
the
source
is
being
passed
into
the
doubler
they're
being
passed
into
the
logger
like
you.
Just
have
this
big
long
like
function
cool
chain,
and
it's
actually
a
little
bit
easier
to
see
it
as
as
something
like
this.
So
we
can,
we
can
use
a
thing
called
pipe
and
then
other
utilities,
like
the
the
just
modules
that
we
create
it,
stands
for
iterable,
like
last
really
useful.
When
so
I
bet
has
a
Dinge.
A
cyberfest.
A
Now
is
a
it's.
It
returns
an
async
iterable
and
actually,
when
you
add
stuff
to
ipfs,
you
can't,
if
you're,
adding
lots
of
files,
you
want
the
last
item
from
the
iturra
iterator,
so
you
might
want
to
use
that
it
target
has
get
returns.
Tar
and
updater.
You
have
to
antar
it
or
pack.
It
either
way
it
Claude
is
useful.
A
When
you're,
you
want
to
add
like
files
from
your
file
system
and
it
might
want
to
global
rule
files-
and
it
just
gives
you
back
stuff
and
often
what
we
do
in
ipfs
is
prefix
things
with
variants,
and
so
you
might
want
some
utilities
like
that,
so
we
made
loads
of
these
in
the
process
of
async/await,
and
then
I
made
a
list
of
them
at
awesome
because
they
are
all
awesome.
What's
really
awesome
is
that
there's
a
lot
of
these?