当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript events.emit函数代码示例

本文整理汇总了TypeScript中events.emit函数的典型用法代码示例。如果您正苦于以下问题:TypeScript emit函数的具体用法?TypeScript emit怎么用?TypeScript emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了emit函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: default

export default (response: IncomingMessage, options: Options, emitter: EventEmitter) => {
	const downloadBodySize = Number(response.headers['content-length']) || undefined;

	const progressStream: TransformStream = downloadProgress(response, emitter, downloadBodySize);

	mimicResponse(response, progressStream);

	const newResponse = (
		options.decompress === true &&
		is.function_(decompressResponse) &&
		options.method !== 'HEAD' ? decompressResponse(progressStream as unknown as IncomingMessage) : progressStream
	) as Response;

	if (!options.decompress && ['gzip', 'deflate', 'br'].includes(response.headers['content-encoding'] || '')) {
		options.encoding = null;
	}

	emitter.emit('response', newResponse);

	emitter.emit('downloadProgress', {
		percent: 0,
		transferred: 0,
		total: downloadBodySize
	});

	response.pipe(progressStream);
};
开发者ID:sindresorhus,项目名称:got,代码行数:27,代码来源:get-response.ts

示例2:

 vscode.workspace.onDidChangeTextDocument(event => {
   if (activeEditor && event.document === activeEditor.document) {
     var contentChanges: vscode.TextDocumentContentChangeEvent[] = event.contentChanges;
     // TODO also process multiple contentChanges (multi-cursor editing)
     eventEmitter.emit('data', contentChanges[0].range.start);
   }
 }, null, context.subscriptions);
开发者ID:duog,项目名称:vscode-haskell,代码行数:7,代码来源:extension.ts

示例3: test

    test('it restores saved highlights', done => {
        const eventBus = new EventEmitter();
        const savedDecorations = [{
            pattern: {
                type: 'string',
                expression: 'PHRASE',
                ignoreCase: false,
                wholeMatch: false
            },
            color: '#F7E4B3'
        }];
        const configStore = mockType<ConfigStore>({savedHighlights: savedDecorations});
        const decorationOperator = mock(DecorationOperator);
        const decorationOperatorFactory = mock(DecorationOperatorFactory);
        when(decorationOperatorFactory.createForVisibleEditors()).thenReturn(decorationOperator);
        new SavedHighlightsRestorer(configStore, decorationOperatorFactory, matchingModeRegistry, eventBus);

        eventBus.on(Event.EXTENSION_READY, () => {
            verify(decorationOperator.addDecoration(new StringPattern({
                phrase: 'PHRASE',
                ignoreCase: false,
                wholeMatch: false
            }), '#F7E4B3'));
            done();
        });

        eventBus.emit(Event.EXTENSION_READY);
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:28,代码来源:saved-highlights-restorer.test.ts

示例4: start

  async function start() {
    events = [];
    const { url } = await inquirer.prompt<{ url: string }>([
      {
        type: 'input',
        name: 'url',
        message:
          'Enter the url you want to record, e.g https://react-redux.realworld.io: ',
      },
    ]);

    console.log(`Going to open ${url}...`);
    await record(url);
    console.log('Ready to record. You can do any interaction on the page.');

    const { shouldReplay } = await inquirer.prompt<{ shouldReplay: boolean }>([
      {
        type: 'confirm',
        name: 'shouldReplay',
        message: `Once you want to finish the recording, enter 'y' to start replay: `,
      },
    ]);

    emitter.emit('done', shouldReplay);

    const { shouldStore } = await inquirer.prompt<{ shouldStore: boolean }>([
      {
        type: 'confirm',
        name: 'shouldStore',
        message: `Persistently store these recorded events?`,
      },
    ]);

    if (shouldStore) {
      saveEvents();
    }

    const { shouldRecordAnother } = await inquirer.prompt<{
      shouldRecordAnother: boolean;
    }>([
      {
        type: 'confirm',
        name: 'shouldRecordAnother',
        message: 'Record another one?',
      },
    ]);

    if (shouldRecordAnother) {
      start();
    } else {
      process.exit();
    }
  }
开发者ID:aftabnaveed,项目名称:rrweb,代码行数:53,代码来源:repl.ts

示例5: test

    test('it updates button appearance on receving case sensitivity mode change', done => {
        const eventBus = new EventEmitter();
        const statusBarItem = mockMethods<StatusBarItem>(['show']);
        new ToggleCaseSensitivityModeButton(eventBus, statusBarItem);

        eventBus.on(Event.TOGGLED_CASE_SENSITIVITY, () => {
            assert.deepEqual(statusBarItem.text, 'Aa');
            assert.deepEqual(statusBarItem.tooltip, 'TextMarker: Case Insensitive Mode');
            verify(statusBarItem.show(), {times: 0});
            done();
        });
        eventBus.emit(Event.TOGGLED_CASE_SENSITIVITY, {ignoreCase: true});
    });
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:13,代码来源:toggle-case-sensitivity-mode.test.ts

示例6: Buffer

	router.post('/hooks/github', ctx => {
		const body = JSON.stringify(ctx.request.body);
		const hash = crypto.createHmac('sha1', secret).update(body).digest('hex');
		const sig1 = new Buffer(ctx.headers['x-hub-signature']);
		const sig2 = new Buffer(`sha1=${hash}`);

		// シグネチャ比較
		if (sig1.equals(sig2)) {
			handler.emit(ctx.headers['x-github-event'], ctx.request.body);
			ctx.status = 204;
		} else {
			ctx.status = 400;
		}
	});
开发者ID:ha-dai,项目名称:Misskey,代码行数:14,代码来源:github.ts

示例7: sendMessage

function sendMessage(node, msg, done) {
  "use strict";
    node.log = function(msg) {
      console.log(msg);
    };
    node.error = function(msg) {
      console.log(msg);
      done(msg);
    };
    node.send = function(msg) {
      console.log(msg);
      done();
    };
    nodeListener.emit("input", msg);
}
开发者ID:markrey,项目名称:node-red-contrib-oracledb,代码行数:15,代码来源:oracledb.spec.ts

示例8: setImmediate

		setImmediate( () => this.ee.emit('release') );
开发者ID:BelaPlatform,项目名称:Bela,代码行数:1,代码来源:Lock.ts


注:本文中的events.emit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。