-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
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.Writable.finalの動作確認 #7
Comments
finalをどう呼べばいいのか知らないのでそれっぽいコードをnodejsで書いたけどこの時点でfinalが呼ばれていない... https://nodejs.org/api/stream.html#stream_writable_final_callback |
@ahuglajbclajep Node.js APIの使い方を教えてあげてください |
Decoding buffers in a Writable Stream を参考に書いてみました。 const { Writable } = require("stream");
class MyWritable extends Writable {
constructor() {
super();
this.data = "";
}
_write(chunk, encoding, callback) {
console.log(`_write called and written "${chunk}"`);
this.data += chunk;
callback();
}
_final(callback) {
console.log("_final called");
callback();
}
}
const w = new MyWritable();
w.write("hello, ");
w.end("world!");
console.log(w.data); |
ありがとうございます! ほぼ丸っと使わせていただいて、finalが呼ばれていることが確認できました 🙌 確認して頂いて、よさそうなら締めていただけますか?@terurou |
Haxe4から予約語として
final
が追加されたため、nativeタグなどで別名を定義する必要が発生しました。https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/stream/Writable.hx#L250
https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/stream/Writable.hx#L331
しかし、構造体の中ではnativeタグが使えません。
そのため、@terurouによって吸収するabstructが作成されました。
https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/stream/Writable.hx#L219
https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/stream/Writable.hx#L342-L355
このabstructで_finalが呼ばれるかどうかを確認する必要があります。
The text was updated successfully, but these errors were encountered: