Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

collapse-tasks-queue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collapse-tasks-queue

Collapse tasks queue

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Collapse Tasks Queue

CTQueue executes latest task defined by unique key ms milliseconds after latest consume call.

This library was created for firebase push notifications management (but you can use it for anything else, of course). In out case, client pushes button frequently; we need to bound notifications, collapse them and send only latest one. For some reasons we can not do that on client side and we can not use collapse_key across all devices.

let { CTQueue } = require('collapse-tasks-queue');

let q = new CTQueue(100);
let x = 200,
    y = 0,
    z = 300,
    w = 0;
q.consume('a', () => {
    x = 500;
    y = 100;
});
q.consume('b', () => {
    z = 500;
    w = 100;
});
q.consume('a', () => {
    x = 550;
});
q.consume('b', () => {
    z = 550;
});
/*
delay 100 ms
x === 550;
y === 0;
z === 550;
w === 0;
*/

Keywords

FAQs

Package last updated on 08 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc