Registry / testing / ng-queue

ng-queue

JSON →
library0.3.1jsnpmunverified

ngQueue is an AngularJS module for managing synchronous and asynchronous task queues in AngularJS 1.x applications. Current version 0.3.1 is stable but has seen no releases since 2014. It provides a $queueFactory service to create queues with configurable concurrency limits and an optional 'deferred' mode that uses setImmediate() to prevent browser freezing during heavy tasks. Unlike generic queue libraries, it integrates directly with AngularJS's $q promises and $timeout, making it natural for AngularJS projects. Tasks can be enqueued, removed, and queues cleared programmatically.

testing
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The module is side-effect only; it registers 'ngQueue' on the angular global. Import or require the package for side effects, then add 'ngQueue' to your app's dependency list.

import 'ng-queue'; // then angular.module('myApp', ['ngQueue']);

$queueFactory is an AngularJS service, not a named ES module export. It must be injected via AngularJS DI (function($queueFactory) {...}).

// In an AngularJS controller or service: var queue = $queueFactory(2);

There is no 'Queue' symbol to import. The Queue type is internal; you interact with instances returned by $queueFactory.

// Queue instances are created by $queueFactory, not imported

Demonstrates how to create a queue with $queueFactory, enqueue synchronous and asynchronous tasks, and handle promise resolution.

// 1. Include angular and ngQueue scripts in HTML // 2. Define AngularJS app module angular.module('myApp', ['ngQueue']); // 3. In a controller, inject $queueFactory angular.module('myApp').controller('MainCtrl', function($scope, $queueFactory, $timeout, $q) { // Create a queue with concurrency 2 var queue = $queueFactory(2); // Enqueue synchronous tasks queue.enqueue(function() { console.log('Task A'); }); // Enqueue an asynchronous task (returns a promise) queue.enqueue(function() { var deferred = $q.defer(); $timeout(function() { deferred.resolve(); }, 100); return deferred.promise; }).then(function() { console.log('Async task completed'); }); // Tasks are executed in order, respecting concurrency limit });
Debug
Known footguns
deprecatedngQueue only supports AngularJS 1.x (specifically version 1.1.5 recommended in docs). It is not compatible with Angular 2+.
breakingThe 'deferred' option relies on setImmediate(), which is not widely supported. Falls back to $timeout, which may affect timing and cause digest cycle issues.
gotchaWhen using the deferred queue, task execution is not truly immediate; small delays are introduced. This may break code that depends on synchronous execution order.
gotchaThe enqueue() method returns a task handle (not a promise) for removal. Developers often expect a promise and try to chain .then() on it, which fails.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
bingbot
1
Resources