Coder Social home page Coder Social logo

Add a '.throttle' method about promise-utils HOT 4 CLOSED

blend avatar blend commented on May 21, 2024
Add a '.throttle' method

from promise-utils.

Comments (4)

ftrimble avatar ftrimble commented on May 21, 2024

I think this is already implemented in promiseUtils.mapLimit - what would you want from that function that isn't already built in?

from promise-utils.

ftrimble avatar ftrimble commented on May 21, 2024

Also, fwiw - I'm not sure that as written your code actually implements the throttling correctly. Since you've already created the promises, they are going to get executed whether you are awaiting them or not. You need to only invoke the function that generates the promise when there is sufficient remaining concurrency to deal with it.

from promise-utils.

rjnienaber avatar rjnienaber commented on May 21, 2024

Sorry, you're absolutely right not sure how I missed it when looking through the docs. promiseUtils.mapLimit is what I'm looking for!

The promiseThrottle function will work because of promiseFuncs.shift()() which will invoke the function that returns the promise which will then start executing.

from promise-utils.

ftrimble avatar ftrimble commented on May 21, 2024

ah ya i didn't notice that the original map returned a lambda, not just invoked one.

from promise-utils.

Related Issues (10)

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.