11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst { Writable } = require('stream'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci{ 61cb0ef41Sopenharmony_ci // Sync + Sync 71cb0ef41Sopenharmony_ci const writable = new Writable({ 81cb0ef41Sopenharmony_ci write: common.mustCall((buf, enc, cb) => { 91cb0ef41Sopenharmony_ci cb(); 101cb0ef41Sopenharmony_ci cb(); 111cb0ef41Sopenharmony_ci }) 121cb0ef41Sopenharmony_ci }); 131cb0ef41Sopenharmony_ci writable.write('hi'); 141cb0ef41Sopenharmony_ci writable.on('error', common.expectsError({ 151cb0ef41Sopenharmony_ci code: 'ERR_MULTIPLE_CALLBACK', 161cb0ef41Sopenharmony_ci name: 'Error' 171cb0ef41Sopenharmony_ci })); 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci{ 211cb0ef41Sopenharmony_ci // Sync + Async 221cb0ef41Sopenharmony_ci const writable = new Writable({ 231cb0ef41Sopenharmony_ci write: common.mustCall((buf, enc, cb) => { 241cb0ef41Sopenharmony_ci cb(); 251cb0ef41Sopenharmony_ci process.nextTick(() => { 261cb0ef41Sopenharmony_ci cb(); 271cb0ef41Sopenharmony_ci }); 281cb0ef41Sopenharmony_ci }) 291cb0ef41Sopenharmony_ci }); 301cb0ef41Sopenharmony_ci writable.write('hi'); 311cb0ef41Sopenharmony_ci writable.on('error', common.expectsError({ 321cb0ef41Sopenharmony_ci code: 'ERR_MULTIPLE_CALLBACK', 331cb0ef41Sopenharmony_ci name: 'Error' 341cb0ef41Sopenharmony_ci })); 351cb0ef41Sopenharmony_ci} 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci{ 381cb0ef41Sopenharmony_ci // Async + Async 391cb0ef41Sopenharmony_ci const writable = new Writable({ 401cb0ef41Sopenharmony_ci write: common.mustCall((buf, enc, cb) => { 411cb0ef41Sopenharmony_ci process.nextTick(cb); 421cb0ef41Sopenharmony_ci process.nextTick(() => { 431cb0ef41Sopenharmony_ci cb(); 441cb0ef41Sopenharmony_ci }); 451cb0ef41Sopenharmony_ci }) 461cb0ef41Sopenharmony_ci }); 471cb0ef41Sopenharmony_ci writable.write('hi'); 481cb0ef41Sopenharmony_ci writable.on('error', common.expectsError({ 491cb0ef41Sopenharmony_ci code: 'ERR_MULTIPLE_CALLBACK', 501cb0ef41Sopenharmony_ci name: 'Error' 511cb0ef41Sopenharmony_ci })); 521cb0ef41Sopenharmony_ci} 53