Merge pull request #21410 from karak/benchmarkjs

[benchmark] Fixed return types of on(), off().
This commit is contained in:
Nathan Shively-Sanders
2017-11-14 09:18:05 -08:00
committed by GitHub
2 changed files with 25 additions and 4 deletions

View File

@@ -229,6 +229,27 @@ suite.add({
'onComplete': onComplete
});
// unregister a listener for an event type
suite.off('cycle', listener) as Benchmark.Suite;
// unregister a listener for multiple event types
suite.off('start cycle', listener) as Benchmark.Suite;
// unregister all listeners for an event type
suite.off('cycle') as Benchmark.Suite;
// unregister all listeners for multiple event types
suite.off('start cycle complete') as Benchmark.Suite;
// unregister all listeners for all event types
suite.off() as Benchmark.Suite;
// register a listener for an event type
suite.on('cycle', listener) as Benchmark.Suite;
// register a listener for multiple event types
suite.on('start cycle', listener) as Benchmark.Suite;
// basic usage
suite.run();

View File

@@ -170,10 +170,10 @@ declare namespace Benchmark {
join(separator?: string): string;
listeners(type: string): Function[];
map(callback: Function): any[];
off(type?: string, callback?: Function): Benchmark;
off(types: string[]): Benchmark;
on(type?: string, callback?: Function): Benchmark;
on(types: string[]): Benchmark;
off(type?: string, callback?: Function): Suite;
off(types: string[]): Suite;
on(type?: string, callback?: Function): Suite;
on(types: string[]): Suite;
pluck(property: string): any[];
pop(): Function;
push(benchmark: Benchmark): number;