Fixed return types of on(), off().

The methods on, off returns this, Benchmark or Benchmark.Suite respectively.
This commit is contained in:
karak 2017-11-11 00:59:21 +09:00
parent a8e88654be
commit c3b8d5b4cf
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;