Giter Club home page Giter Club logo

Comments (2)

tsani avatar tsani commented on May 28, 2024

Quick update: I did find a workaround with .flat() but it's kinda gnarly.

seq.flat(async function* (x) { yield await f(x) })

Surely seq.map(f) would be way nicer.

And this workaround is especially unpleasant if f needs to access this, as one can't use an arrow function to create a generator.

EDIT: and unfortunately, the overload for .flat() that takes a transformation returns a plain AsyncIterable and not an AsyncIterableQuery, so I can't continue to chain itiriri methods together after using the workaround without wrapping up with itiririAsync again.

from itiriri-async.

dimadeveatii avatar dimadeveatii commented on May 28, 2024

Hi @tsani,
I don't remember the exact implementation, but from the source code here it looks like map accepts async functions as well.

So in the case of:

(selector: (x: T) => S): AsyncIterableQuery<S>

the selector can be a function that returns a Promise. I agree typings have to be fixed.
It should look like:

(selector: (x: T) => S | Promise<S>): AsyncIterableQuery<S>

You're welcome to open a PR.

from itiriri-async.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.