You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reduce is the operator that is responsible for serialising new collections, and there's a shorthand generalisation that makes it more ergonomic i.e. reduce([]) to collect into an array, reduce({}) to collect into an object, etc. Currently it knows about a limited set of types, but was also planning to make it a Symbol-based protocol. The prototype just needs one Symbol that dictates how to concat new values it receives into itself.
With Emitter we can tease apart the three concerns of "iteration, transformation, and accumulation". Here's a snippet from one of the tests that explores the entire matrix of going from/to Array, Object, String, Number, Function, Generator, Async Generator, Emitter with a series of transformations in between.
@gsathya, here's what I was thinking re: collection helpers proposal. We can spec it in a generic way to work with all collections rather than duplicating functionality:
reduce
is the operator that is responsible for serialising new collections, and there's a shorthand generalisation that makes it more ergonomic i.e.reduce([])
to collect into an array,reduce({})
to collect into an object, etc. Currently it knows about a limited set of types, but was also planning to make it a Symbol-based protocol. The prototype just needs one Symbol that dictates how to concat new values it receives into itself.With Emitter we can tease apart the three concerns of "iteration, transformation, and accumulation". Here's a snippet from one of the tests that explores the entire matrix of going from/to Array, Object, String, Number, Function, Generator, Async Generator, Emitter with a series of transformations in between.
@gsathya, here's what I was thinking re: collection helpers proposal. We can spec it in a generic way to work with all collections rather than duplicating functionality:
That is, each of the collection helper methods apply the corresponding transform and serialise the values into a new collection of the same type.
(Note:
new this.constructor
can also benew this.constructor[Symbol.species]
, but @syg has more thoughts on that).The text was updated successfully, but these errors were encountered: