本文整理汇总了TypeScript中stream.PassThrough.end方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PassThrough.end方法的具体用法?TypeScript PassThrough.end怎么用?TypeScript PassThrough.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream.PassThrough
的用法示例。
在下文中一共展示了PassThrough.end方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _shutdown
private _shutdown() {
// End the temporary streams so the merged streams end too
if (this._fakeStream) {
this._fakeStream.end();
this._fakeStream = null;
}
}
示例2: rp
rp(options).then(response => {
const stream = require('stream');
const bufferStream = new stream.PassThrough();
bufferStream.end(Buffer.from(response.body, 'base64'));
const file = admin.storage().bucket().file('name.jpg');
bufferStream.pipe(
file.createWriteStream({
public: true
}))
.on('error', function(error) {
console.log(error);
return res.status(500).send(error);
})
.on('finish', function() {
const config: GetSignedUrlConfig = {
action: 'read',
expires: '01-01-2025'
};
file.getSignedUrl(config, function(error, url) {
console.log(url);
if (error) {
return res.status(500).send(error);
}
return res.status(500).send(url);
});
});
res.send('Success');
})
示例3: async
async () => {
const s = new PassThrough();
s.write('howdy');
s.end();
const { stdout } = await execa('stdin', { input: s });
assert(stdout === 'foobar');
};
示例4: 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]);
});
示例5: 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();
});
});
示例6: 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);
});
示例7: it
it('fails when the sink onStart fails', () => {
const str = new stream.PassThrough({highWaterMark: 1024});
const src = Source.fromInputStream(() => str);
const err = new Error('yep this is an error');
str.end(new Buffer(1024));
const promise = src.pipe<void, void>({
onStart: () => Task.throwError<void>(err),
onData: () => Task.unit(),
onEnd: () => Task.unit()
}).exec();
return chai.expect(promise).to.eventually.be.rejectedWith(err);
});