@achil/async-run-ended 中文文档教程
当 Node.js 中的进程间通信 (IPC) 保持子进程和父进程之间的连接时,检查您的 node.js 程序是否已完成异步代码执行(异步函数、promises、setTimeout 等)。 不建议用于生产。
Installation
npm install @achil/async-run-ended
或
yarn add @achil/async-run-ended
Usage
要求代码顶部的节点模块
const asyncEnd = require('@achil/async-run-ended');
并在文件末尾或代码的特定点进行检查,方法是使用模块函数检查和时间间隔作为它的参数,例如在下面的示例中,它每 50 毫秒检查一次:
asyncEnd.check(50).then(function() {
// Run your code at the end of the async code
});
Check if your node.js program has finished the async code execution (async functions, promises, setTimeout etc), when Inter Process Communication (IPC) in Node.js keeps the connection between child and parent process, alive. It is not recommended to be used for production.
Installation
npm install @achil/async-run-ended
or
yarn add @achil/async-run-ended
Usage
Require the node module at the top of your code
const asyncEnd = require('@achil/async-run-ended');
and check at the end of your file or at a specific point of you code by using the module function check and a time interval as argument of it, for example at the following example, it checks every 50ms :
asyncEnd.check(50).then(function() {
// Run your code at the end of the async code
});