本文整理汇总了TypeScript中stream.Readable.emit方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Readable.emit方法的具体用法?TypeScript Readable.emit怎么用?TypeScript Readable.emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stream.Readable
的用法示例。
在下文中一共展示了Readable.emit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setImmediate
setImmediate(() => {
let found = false;
for (const mock of MOCKED_FILES) {
if (mock.filename === filename) {
found = true;
rs.emit('error', new Error(mock.error));
break;
}
}
assert.ok(
found,
`The file ${filename} should not be read ` +
`because it doesn't have a mock`
);
});
示例2: function
t.test("handler registered in context on Readable", function (t) {
var Readable = require('stream').Readable;
if (Readable) {
t.plan(12);
var n = cls.createNamespace('outOnReadable')
, re = new Readable()
;
re._read = function () {};
t.ok(n.name, "namespace has a name");
t.equal(n.name, 'outOnReadable', "namespace has a name");
n.run(function () {
n.set('value', 'hello');
n.bindEmitter(re);
t.ok(re.emit.__wrapped, "emit is wrapped");
t.ok(re.on.__wrapped, "on is wrapped");
t.ok(re.addListener.__wrapped, "addListener is wrapped");
re.on('data', function (data: any) {
t.equal(n.get('value'), 'hello', "value still set in EE");
t.equal(data, 'blah', "emit still works");
cls.destroyNamespace('outOnReadable');
});
});
t.ok(re.emit.__wrapped, "emit is still wrapped");
t.ok(re.on.__wrapped, "on is still wrapped");
t.ok(re.addListener.__wrapped, "addListener is still wrapped");
t.equal(typeof re._events.data, 'function', 'only the one data listener');
t.ok(re._events.data['cls@contexts']['context@outOnReadable'],
"context is bound to listener");
re.emit('data', 'blah');
}
else {
t.comment("this test requires node 0.10+");
t.end();
}
});
示例3:
.catch((err: Error) => {
stream.emit('error', err); // Pass on any errors
});
示例4: function
q.on('error', function(err: any) {
stream.emit('error', err); // Pass on any errors
});
示例5: Error
process.nextTick(() => {
const err = new Error(SourceError[402]);
err.stack = option.path;
reader.emit("error", err, option);
reader.destroy();
});