mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 22:40:57 +00:00

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>
43 lines
819 B
JavaScript
43 lines
819 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const WrapStream = require('internal/js_stream_socket');
|
|
const Stream = require('stream');
|
|
|
|
class FakeStream extends Stream {
|
|
constructor() {
|
|
super();
|
|
this._paused = false;
|
|
}
|
|
|
|
pause() {
|
|
this._paused = true;
|
|
}
|
|
|
|
resume() {
|
|
this._paused = false;
|
|
}
|
|
|
|
isPaused() {
|
|
return this._paused;
|
|
}
|
|
}
|
|
|
|
const fakeStreamObj = new FakeStream();
|
|
const wrappedStream = new WrapStream(fakeStreamObj);
|
|
|
|
// Resume by wrapped stream upon construction
|
|
assert.strictEqual(fakeStreamObj.isPaused(), false);
|
|
|
|
fakeStreamObj.pause();
|
|
|
|
assert.strictEqual(fakeStreamObj.isPaused(), true);
|
|
|
|
fakeStreamObj.resume();
|
|
|
|
assert.strictEqual(wrappedStream.readStop(), 0);
|
|
|
|
assert.strictEqual(fakeStreamObj.isPaused(), true);
|