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.

npm install ng-queue
INSTALL
IMPORT
SIG · NG-QUEUE
N
ng-queue
testingjavascriptv0.3.1
harness data pending
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.

ngQueue
import 'ng-queue'; // then angular.module('myApp', ['ngQueue']);
const ngQueue = require('ng-queue');
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.
$queueFactory
// In an AngularJS controller or service: var queue = $queueFactory(2);
import { $queueFactory } from 'ng-queue';
$queueFactory is an AngularJS service, not a named ES module export. It must be injected via AngularJS DI (function($queueFactory) {...}).
Queue
// Queue instances are created by $queueFactory, not imported
import { Queue } from 'ng-queue';
There is no 'Queue' symbol to import. The Queue type is internal; you interact with instances returned by $queueFactory.

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 issues
deprecatedngQueue only supports AngularJS 1.x (specifically version 1.1.5 recommended in docs). It is not compatible with Angular 2+.
fix
Use a modern queue library like p-queue or bull for Angular 2+ applications.
affects: >=0
breakingThe 'deferred' option relies on setImmediate(), which is not widely supported. Falls back to $timeout, which may affect timing and cause digest cycle issues.
fix
Ensure a setImmediate polyfill is included, or avoid the deferred option.
affects: >=0
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.
fix
Do not use the deferred option if strict sequencing without delay is required.
affects: >=0
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.
fix
Use the returned object only for queue.remove(taskHandle). To chain after task completion, return a promise from the task function itself.
affects: >=0
Errors
Common errors & fixes
ReferenceError: $queueFactory is not defined
The ngQueue module is not loaded or not added as a dependency.
fix
Ensure the ngQueue script is included in your HTML and that your AngularJS app declares 'ngQueue' as a dependency: angular.module('myApp', ['ngQueue']).
Error: [$injector:modulerr] Failed to instantiate module ngQueue due to: Error: [$injector:nomod] Module 'ngQueue' is not available!
The ngQueue script was not loaded before AngularJS initialization or the script path is incorrect.
fix
Include the ngQueue script after AngularJS but before your app code. Check the script URL or use a CDN.
TypeError: queue.enqueue(...).then is not a function
enqueue() returns a task handle object, not a promise. Developers mistakenly try to call .then() on it.
fix
Do not call .then() on the result of enqueue(). To react to task completion, return a promise from the task function and handle it via $q promises.
Error: [$rootScope:inprog] $digest already in progress
Using the deferred queue with setImmediate->$timeout may cause nested digest cycles if tasks trigger AngularJS bindings synchronously.
fix
Avoid the deferred option when tasks cause immediate $scope updates. Use non-deferred queue or wrap updates in $scope.$applyAsync().
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
angularrequiredRequires AngularJS 1.x as a peer dependency
Agent activity
6 hits · last 30 days
node
6
Resources
ng-queue — npm install ng-queue · libregistry