什么nodejs库最像jQuery的延迟?

时间:2021-12-02 19:32:48

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.

我已经熟练地使用了jQuery新的、令人惊叹的延迟模块,并逐渐开始使用更多的Node。js,我发现自己在我的大部分节点中都想要一个和它完全一样的东西。js编程:回调块,直到有一组承诺得到解决,随着任务在复杂度上的增长,可以*地添加到数组中,比如当一个进程处理一棵数据树时,在任务开始时不知道它的大小。

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.

但是node-纤程需要一个全新的可执行文件,Q()的接口非常混乱,而且node-step似乎只处理单任务同步。

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.

是否有人刚刚将jQuery的延迟移植到节点就绪表单中?这似乎不太可能,延迟似乎也不依赖于dom可用的特性,但我还没有找到与之对应的服务器端特性。

7 个解决方案

#1


6  

This node library looks quite similar in functionality to jQuery's Deferred:

这个节点库在功能上与jQuery的Deferred类似:

https://github.com/kriszyp/node-promise

https://github.com/kriszyp/node-promise

#2


23  

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

如果您希望使用相同的API,那么在Node下使用jQuery本身是没有任何障碍的。只需安装jquery npm,然后:

var $ = require('jquery');
var deferred = $.Deferred();

#3


7  

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

我认为对于nodeJS来说,jQuery延迟库是最接近的。

#4


3  

This wasn't around when the question was asked, but according to the readme it uses (and passes) the jquery tests. It appears to be exactly identical minus the (jQuery||$). prefix.

当被问到这个问题时,这并没有发生,但是根据readme,它使用(并通过)jquery测试。它看起来完全相同(jQuery||$)。前缀。

https://github.com/jaubourg/jquery-deferred-for-node

https://github.com/jaubourg/jquery-deferred-for-node

#5


1  

This nodejs module is CommonJS compliant.

这个node - js模块兼容CommonJS。

https://github.com/cujojs/when

https://github.com/cujojs/when

#6


0  

Googling: deferred for nodejs

google:nodejs延期

Gave me: https://github.com/felixge/node-deferred

给了我:https://github.com/felixge/node-deferred

Though not exactly what you are looking for, is moderately close. I find that the callback chaining is fairly natural, though deeply nested chains can be a bit difficult to keep up with.

虽然不完全是你想要的,但还是比较接近。我发现回调链接是相当自然的,尽管深度嵌套的链可能有点难以跟上。

Searching for: promise nodejs lead me down a path of more interesting results...

寻找:承诺nodejs引导我找到更有趣的结果……

Both of which are probably much closer to what you are looking for. :)

这两个可能都更接近于你所寻找的。:)

#7


-1  

This node library contains jquery 1.8.2 deferred class.

这个节点库包含jquery 1.8.2递延类。

https://www.npmjs.com/package/jquery-deferred

https://www.npmjs.com/package/jquery-deferred

npm install jquery-deferred

npm安装jquery-deferred

#1


6  

This node library looks quite similar in functionality to jQuery's Deferred:

这个节点库在功能上与jQuery的Deferred类似:

https://github.com/kriszyp/node-promise

https://github.com/kriszyp/node-promise

#2


23  

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

如果您希望使用相同的API,那么在Node下使用jQuery本身是没有任何障碍的。只需安装jquery npm,然后:

var $ = require('jquery');
var deferred = $.Deferred();

#3


7  

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

我认为对于nodeJS来说,jQuery延迟库是最接近的。

#4


3  

This wasn't around when the question was asked, but according to the readme it uses (and passes) the jquery tests. It appears to be exactly identical minus the (jQuery||$). prefix.

当被问到这个问题时,这并没有发生,但是根据readme,它使用(并通过)jquery测试。它看起来完全相同(jQuery||$)。前缀。

https://github.com/jaubourg/jquery-deferred-for-node

https://github.com/jaubourg/jquery-deferred-for-node

#5


1  

This nodejs module is CommonJS compliant.

这个node - js模块兼容CommonJS。

https://github.com/cujojs/when

https://github.com/cujojs/when

#6


0  

Googling: deferred for nodejs

google:nodejs延期

Gave me: https://github.com/felixge/node-deferred

给了我:https://github.com/felixge/node-deferred

Though not exactly what you are looking for, is moderately close. I find that the callback chaining is fairly natural, though deeply nested chains can be a bit difficult to keep up with.

虽然不完全是你想要的,但还是比较接近。我发现回调链接是相当自然的,尽管深度嵌套的链可能有点难以跟上。

Searching for: promise nodejs lead me down a path of more interesting results...

寻找:承诺nodejs引导我找到更有趣的结果……

Both of which are probably much closer to what you are looking for. :)

这两个可能都更接近于你所寻找的。:)

#7


-1  

This node library contains jquery 1.8.2 deferred class.

这个节点库包含jquery 1.8.2递延类。

https://www.npmjs.com/package/jquery-deferred

https://www.npmjs.com/package/jquery-deferred

npm install jquery-deferred

npm安装jquery-deferred