mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 04:43:16 +00:00

With the introduction of the promises API for setTimeout(), the requirement that it have two parameters may not be sensible anymore in tests. PR-URL: https://github.com/nodejs/node/pull/41901 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
26 lines
481 B
JavaScript
26 lines
481 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const {
|
|
Duplex,
|
|
} = require('stream');
|
|
const { setTimeout } = require('timers/promises');
|
|
|
|
{
|
|
class Foo extends Duplex {
|
|
async _final(callback) {
|
|
await setTimeout(common.platformTimeout(1));
|
|
callback();
|
|
}
|
|
|
|
_read() {}
|
|
}
|
|
|
|
const foo = new Foo();
|
|
foo._write = common.mustCall((chunk, encoding, cb) => {
|
|
cb();
|
|
});
|
|
foo.end('test', common.mustCall());
|
|
foo.on('error', common.mustNotCall());
|
|
}
|