Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What nodejs library is most like jQuery's deferreds?

I've become a skilled user of jQuery's new and amazing Deferred module, and as I'm easing into using more of Node.js, I find myself wanting something exactly like it in much of my Node.js programming: callbacks that block until a collection of promises devolves to resolved, with the freedom to add to the array on-the-fly as the task grows in complexity-- such as when one processes a tree of data, the size of which is not known at the start of the task.

But node-fibers requires a whole new executable, Q()'s interface is just damned confusing, and node-step only seems to handle single-task synchronizations.

Has someone just ported jQuery's Deferreds to a node-ready form? It doesn't seem that unlikely, nor does it seem that Deferreds is dependent upon DOM-available features, but I haven't found a server-side equivalent.

like image 842
Elf Sternberg Avatar asked Sep 28 '11 19:09

Elf Sternberg


People also ask

What is node js jQuery?

Since jQuery is a frontend JavaScript Library, it needs to have a window with a document to work in the backend. 'jsdom' is a library that is used to parse and interact with the HTML. It is not exactly a web browser but mimics one. Use the following command to install the jsdom module. npm install jsdom.

Is node js a framework or library?

js is actually not a framework or a library, but a runtime environment, based on Chrome's V8 JavaScript engine.

What is node js used for?

It is used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services, but was originally designed with real-time, push-based architectures in mind.


2 Answers

If you want the same API, there's nothing stopping you from using jQuery itself under Node. Just npm install jquery, then:

var $ = require('jquery'); var deferred = $.Deferred(); 
like image 185
Trevor Burnham Avatar answered Sep 28 '22 11:09

Trevor Burnham


I don't think you can get any closer than jQuery deferred lib for nodeJS.

like image 41
user1200245 Avatar answered Sep 28 '22 12:09

user1200245