xref: /third_party/node/test/parallel/test-stream-write-final.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst stream = require('stream');
61cb0ef41Sopenharmony_cilet shutdown = false;
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst w = new stream.Writable({
91cb0ef41Sopenharmony_ci  final: common.mustCall(function(cb) {
101cb0ef41Sopenharmony_ci    assert.strictEqual(this, w);
111cb0ef41Sopenharmony_ci    setTimeout(function() {
121cb0ef41Sopenharmony_ci      shutdown = true;
131cb0ef41Sopenharmony_ci      cb();
141cb0ef41Sopenharmony_ci    }, 100);
151cb0ef41Sopenharmony_ci  }),
161cb0ef41Sopenharmony_ci  write: function(chunk, e, cb) {
171cb0ef41Sopenharmony_ci    process.nextTick(cb);
181cb0ef41Sopenharmony_ci  }
191cb0ef41Sopenharmony_ci});
201cb0ef41Sopenharmony_ciw.on('finish', common.mustCall(function() {
211cb0ef41Sopenharmony_ci  assert(shutdown);
221cb0ef41Sopenharmony_ci}));
231cb0ef41Sopenharmony_ciw.write(Buffer.allocUnsafe(1));
241cb0ef41Sopenharmony_ciw.end(Buffer.allocUnsafe(0));
25

Indexes created Thu Nov 07 10:32:03 CST 2024