本文整理匯總了TypeScript中stream.PassThrough.write方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript PassThrough.write方法的具體用法?TypeScript PassThrough.write怎麽用?TypeScript PassThrough.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stream.PassThrough
的用法示例。
在下文中一共展示了PassThrough.write方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('produces multiple chunks from a fed stream', () => {
const str = new stream.PassThrough({highWaterMark: 1024});
const src = Source.fromInputStream(() => str);
const data1 = new Buffer(1024);
const data2 = new Buffer(1024);
str.write(data1);
str.write(data2);
str.end();
return chai.expect(src.toArray()).to.eventually.deep.equal([data1, data2]);
});
示例2: async
async () => {
const s = new PassThrough();
s.write('howdy');
s.end();
const { stdout } = await execa('stdin', { input: s });
assert(stdout === 'foobar');
};
示例3: it
it('DeleteLayer Test -', (done: () => void) => {
var response = new PassThrough();
response.write(JSON.stringify({'statusCode': '202'}));
response.end();
var req = new PassThrough();
this.request.callsArgWith(1,response).returns(req);
wrapper.deleteLayer('name','digest',(err)=>{
done();
});
});
示例4: it
it('should be pipeable', () => {
const msg = 'hello world!';
const wsb = new WritableStreamBuffer();
const rs = new PassThrough();
rs.pipe(wsb);
rs.write(msg);
rs.end();
const result = wsb.consume();
expect(result.toString()).toEqual(msg);
});
示例5: setInterval
const i2 = setInterval(() => { rs2.write('b') }, 150);