mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

This is supposed to be a public alternative of the private APIs, `process._getActiveResources()` and `process._getActiveHandles()`. When called, it returns an array of strings containing the types of the active resources that are currently keeping the event loop alive. Signed-off-by: Darshan Sen <darshan.sen@postman.com> PR-URL: https://github.com/nodejs/node/pull/40813 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
21 lines
479 B
JavaScript
21 lines
479 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
for (let i = 0; i < 10; ++i) {
|
|
for (let j = 0; j < 10; ++j) {
|
|
setTimeout(common.mustCall(), i);
|
|
}
|
|
}
|
|
|
|
assert.strictEqual(process.getActiveResourcesInfo().filter(
|
|
(type) => type === 'Timeout').length, 100);
|
|
|
|
for (let i = 0; i < 10; ++i) {
|
|
setImmediate(common.mustCall());
|
|
}
|
|
|
|
assert.strictEqual(process.getActiveResourcesInfo().filter(
|
|
(type) => type === 'Immediate').length, 10);
|