GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - microfleet/callback-queue: Put your callbacks into queue to make sure that concurrent requests that you might want to perform will only be executed once

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.husky
.husky
 
 
.semaphore
.semaphore
 
 
src
src
 
 
test
test
 
 
.commitlintrc.cjs
.commitlintrc.cjs
 
 
.editorconfig
.editorconfig
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.mocharc.json
.mocharc.json
 
 
.releaserc.json
.releaserc.json
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
tsconfig.base.json
tsconfig.base.json
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Callback queue

Codacy Badge

Node.js callback queue. Can be used with browserify as well.

Idea is to queue callbacks, when same function wants to be called at the same time by different callers.

One example would be conserving resources spent on outgoing http requests.

npm install callback-queue -S

Example usage

  1. callbackQueue.add(String, Function): queues callbacks based on key attribute
  2. callbackQueue.remove(String, Error): calls queued callbacks with Error argument
const callbackQueue = require('callback-queue');
const request = require('request');

function performOutgoingRequest(url, next) {
  const callback = callbackQueue.add(url, next);
  if (!callback) {
    return;
  }

  request(url, callback);
}

for (let i = 0; i < 100; i++) {
  // request itself will be performed just once
  performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
    // will be called 100 times
  });
}

for (let x = 0; x < 100; x++) {
  // request itself will be performed just once
  performOutgoingRequest('https://google.com', function niceCallback(err, resp, body) {
      // will be called 100 times with Error object
  });
}

callbackQueue.remove('https://google.com', new Error('cancel it!'));

About

Put your callbacks into queue to make sure that concurrent requests that you might want to perform will only be executed once

Resources

Readme
MIT license
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.