當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Readable.emit方法代碼示例

本文整理匯總了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`
   );
 });
開發者ID:GoogleCloudPlatform,項目名稱:cloud-debug-nodejs,代碼行數:15,代碼來源:test-scanner.ts

示例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();
    }
  });
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:46,代碼來源:continuation-local-storage-tests.ts

示例3:

 .catch((err: Error) => {
   stream.emit('error', err);  // Pass on any errors
 });
開發者ID:implydata,項目名稱:plywood-postgres-requester,代碼行數:3,代碼來源:postgresRequester.ts

示例4: function

 q.on('error', function(err: any) {
   stream.emit('error', err);  // Pass on any errors
 });
開發者ID:implydata,項目名稱:plywood-postgres-requester,代碼行數:3,代碼來源:postgresRequester.ts

示例5: Error

 process.nextTick(() => {
   const err = new Error(SourceError[402]);
   err.stack = option.path;
   reader.emit("error", err, option);
   reader.destroy();
 });
開發者ID:node-dmr,項目名稱:dmr-source,代碼行數:6,代碼來源:source-file.ts


注:本文中的stream.Readable.emit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。