New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cqueue

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cqueue

Channel queue with Promises

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-47.06%
Maintainers
1
Weekly downloads
 
Created
Source

cqueue

cqueue is a Channel queue for holding a msg/value until it's taken. Promises are used for concurrent operations against the queue.

build status

How do I use it?

Put something in the queue, and then take it at some point in the future. The queue can only hold one value, and the response will indicate what your machine should do, i.e. "continue" or "pause".

const cqueue = require("cqueue");
let chan = cqueue();

function handle (arg) {
    console.log(arg[1] || "empty");
}

chan.take().then(handle); // "empty"
chan.put("hello world");
chan.take().then(handle); // "hello world"

API

queue

Property

Array which can hold 1 value

put

Method

Puts an item into the Channel, and the Promise receives an Array

method put
param  {Mixed} arg Item
return {Object}    Promise
chan.put(arg).then(function(state) {
	if (state[0] === "continue") {
		// arg was added to the channel
	} else {
		// arg is not in the channel
	}
});

take

Method

Takes an item from the Channel, and the Promise receives an Array

method take
return {Object} Promise
chan.take().then(function(state) {
	if (state[0] === "continue") {
		// state[1] was taken from the channel
	} else {
		// state[1] is null
	}
});

License

Copyright (c) 2015 Jason Mulligan Licensed under the BSD-3 license.

Keywords

FAQs

Package last updated on 27 Dec 2015

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