We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
流(Stream)是可读,可写或双工的。
可以通过require('stream')加载流的基类,其中包括四类流,
另外如果觉得上述四类基类流不能满足需求,可以编写自己的扩充类流。 像我的BearStream。
The text was updated successfully, but these errors were encountered:
SimpleProtocol.prototype = Object.create( //SimpleProtocol继承readable类 Readable.prototype, { constructor: { value: SimpleProtocol }} );
Sorry, something went wrong.
补充个板栗
自定义readable stream的实现
var Stream = require('stream'); var Read = Stream.Readable; var util = require('util'); util.inherits(MyReadStream, Read); function MyReadStream(data, opt) { Read.call(this, opt); this.data = data || []; } MyReadStream.prototype._read = function () { var _this = this; this.data.forEach(function (d) { _this.push(d); }) this.push(null); } var data = ['aa', 'bb', 'cc']; var r = new MyReadStream(data); r.on('data', function (chunk) { console.log(chunk.toString()); })
@daxiongjun 大熊去学markdown怎么用
No branches or pull requests
流(Stream)是可读,可写或双工的。
可以通过require('stream')加载流的基类,其中包括四类流,
另外如果觉得上述四类基类流不能满足需求,可以编写自己的扩充类流。
像我的BearStream。
The text was updated successfully, but these errors were encountered: