npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

callq

v1.0.7

Published

call queue

Downloads

8

Readme

callq

call queue

Install

npm install callq

Usage

var cq= require( "callq" );

var myObj = {
	f1: function (error, data, que) {
		console.log(data = "1-label");
		setTimeout(function() { que.jump(null, data, "f3"); }, 50);
	},
	f2: function (error, data, que) {
		console.log(data = data + ",2-end");
		setTimeout(function() { que.jump(null, data, "f4"); }, 50);
	},
	f3: function (error, data, que) {
		console.log(data = data + ",3-label");
		setTimeout(function() { que.jump(null, data, "f2"); }, 50);
	},
	f4: function (error, data, que) {
		var expect = "1-label,3-label,2-end";
		if(data != expect) throw Error("expect (" + expect + ") but (" + data + ")");
		que.next(null, data);
	},
};

cq(myObj, ["f1", "f2", "f3", "f4"] );

Convention

* an 'error-data-que' callback function, named `operator`, is defined as:
	function( error, data, que ){ ... }

		* `que`: a call-queue object.

		* sync process:
			* return an `Error` object, for `error`;
			* or throw an exception, for `error`;
			* or return anything neither `undefined` nor `Error`, for `data`;
			* or directly call `que.next()` and return nothing/`undefined`;

		* async callback:
			* return nothing/`undefined`.
				* directly call `que.next()` in callback;
				* or get an 'error-first' function from `que.wait()`, as a parameter for outside callback;

* an `operator-set`, is a user-defined object with some operator functions.

* operator-array:
	* an array of
		{ label:"labelN", timeout:timeoutN, op:operatorN }

		* label: default-label string for the operator;
			* a label prefixed ":" char is a sub procedure label.
				* the procedure will be skipped by normal process;
				* it can be called by .pick() later;
		* timeout: default-timeout number for the operator, in milliseconds;
		* op:
			* an operator function.
			* or an existing label string of an operator in the operator-set;
	
	* or an array like:
		[ ["label1",] [timeout1,] operator1, ["label2",] [timeout2,] operator2, ... ]

		* a new `labelN` here shouldn't be an existing label in the operator-set, otherwise it will be parsed as the existing operator;
	
		* the `label` here can be a label-range, defined as string "label1:label2",
				that is a new array extracted from an existig operator-array, that from `label1` to `label2`(included).
			* a label-range will clear preceding `label` and `timeout`

	* or a mixed array of the 2 above formats;

* levels
	1. root: static call-queue object with a user-defined `operator-set`
	2. process: run user-defined `operator-array` by tools of call-queue class
	3. thread: run user-defined operator.

* call stack
	queue
		.next()	/ .wait() / .waitVoid()	/ thread
			.jump()	/ thread
				.pick() / .run() / process
					.if()
					.loop()
					.fork()
					.final()
					.joinAt()

* all *-timeout arguments are optional.