mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
00944c7cc2
Its confusing to call a js class with a handle a "Wrap", usually it's the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its derived from Socket, and makes a JS stream look like a Socket, so call it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated some time. PR-URL: https://github.com/nodejs/node/pull/25153 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
34 lines
760 B
JavaScript
34 lines
760 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const StreamWrap = require('internal/js_stream_socket');
|
|
const { Duplex } = require('stream');
|
|
const { ShutdownWrap } = internalBinding('stream_wrap');
|
|
|
|
function testShutdown(callback) {
|
|
const stream = new Duplex({
|
|
read: function() {
|
|
},
|
|
write: function() {
|
|
}
|
|
});
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
const req = new ShutdownWrap();
|
|
req.oncomplete = function(code) {
|
|
assert(code < 0);
|
|
callback();
|
|
};
|
|
req.handle = wrap._handle;
|
|
|
|
// Close the handle to simulate
|
|
wrap.destroy();
|
|
req.handle.shutdown(req);
|
|
}
|
|
|
|
testShutdown(common.mustCall());
|