Code Monkey home page Code Monkey logo

asyncro's People

Contributors

danielruf avatar developit avatar fimars avatar wkovacs64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

asyncro's Issues

Shouldn't map() run the callback in parallel?

Hi @developit. I had a quick look on your lib, but something seemed rather strange to me.

Why does map() run the callback serially? The nice thing about map is that it provides great opportunities for concurrent processing.

Let's say I do map(['/a', '/b', '/c'], async (item) => await fetch(item)) and every fetch takes 100ms. I would expect the map() to resolve after 100ms, not 300 ms.

Doing filter() and reduce() concurrently might get tricky, but map() should be rather carefree :)

Cheers

Next version plan?

Awesome, asyncro is both simple and practical.

Some suggestions:

  • support more Array operators. In fact, most operators are the same pattern like filter.
  • support Object, maybe like lodash.js.

If you have any plan, very happy to make a PR. 🐵

Series is executing in parallel

From what I can tell, the series method is actually executing all of the methods when it's called, and then waiting for each one to resolve in series before adding it to the array. I think the expected behavior would be that each method is not called until the previous one has resolved.

series([1,2,3,4].map((n) => {
  return async () => new Promise((resolve) => {
    console.log(n)
    setTimeout(() => resolve(n), 1000)
  })
}))

Expected: Each number is logged out 1 second after the previous, total runtime is ~4 seconds
Actual: All numbers are printed immediately, total runtime is ~1 second

I think one way of solving this would be to remove https://github.com/developit/asyncro/blob/master/src/util.js#L6
And change https://github.com/developit/asyncro/blob/master/src/util.js#L6 to be
acc.push(await v());, but I'm not sure if that's the best way.
** This would break the parallel method, so no go there

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.