本文整理匯總了TypeScript中stream.Writable.once方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Writable.once方法的具體用法?TypeScript Writable.once怎麽用?TypeScript Writable.once使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stream.Writable
的用法示例。
在下文中一共展示了Writable.once方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: done
writable._write = (input, encoding, done) => {
if (readable.push(input)) {
done();
} else {
readable.once('drain', done as (...args: any[]) => void);
}
};
readable._read = n => {
// no-op
};
// simulate the readable thing closing after a bit
writable.once('finish', () => {
setTimeout(() => {
readable.push(null);
}, 500);
});
const duplex = duplexer3(writable, readable);
const duplex2 = duplexer3({bubbleErrors: true, allowHalfOpen: true}, writable, readable);
duplex.on('data', e => {
console.log('got data', JSON.stringify(e));
});
duplex.on('finish', () => {
console.log('got finish event');
});
duplex.on('end', () => {