Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#6)
- Loading branch information
1 parent
a2644fd
commit e32811a
Showing
4 changed files
with
58 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,57 @@ | ||
/** | ||
* @returns Elapsed milliseconds. | ||
*/ | ||
export interface TimeEndFunction { | ||
(): number; | ||
declare namespace timeSpan { | ||
interface TimeEndFunction { | ||
/** | ||
@returns Elapsed milliseconds. | ||
*/ | ||
(): number; | ||
|
||
/** | ||
* @returns Elapsed milliseconds rounded. | ||
*/ | ||
rounded(): number; | ||
/** | ||
@returns Elapsed milliseconds rounded. | ||
*/ | ||
rounded(): number; | ||
|
||
/** | ||
* @returns Elapsed seconds. | ||
*/ | ||
seconds(): number; | ||
/** | ||
@returns Elapsed seconds. | ||
*/ | ||
seconds(): number; | ||
|
||
/** | ||
* @returns Elapsed nanoseconds. | ||
*/ | ||
nanoseconds(): number; | ||
/** | ||
@returns Elapsed nanoseconds. | ||
*/ | ||
nanoseconds(): number; | ||
} | ||
} | ||
|
||
/** | ||
* Simplified high resolution timing. | ||
* | ||
* @returns A function that returns the time difference. | ||
*/ | ||
export default function timeSpan(): TimeEndFunction; | ||
declare const timeSpan: { | ||
/** | ||
Simplified high resolution timing. | ||
@returns A function that returns the time difference. | ||
@example | ||
``` | ||
import timeSpan = require('time-span'); | ||
const end = timeSpan(); | ||
timeConsumingFn(); | ||
console.log(end()); | ||
//=> 1745.3186 | ||
console.log(end.rounded()); | ||
//=> 1745 | ||
console.log(end.seconds()); | ||
//=> 1.7453186 | ||
``` | ||
*/ | ||
(): timeSpan.TimeEndFunction; | ||
|
||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function timeSpan(): timeSpan.TimeEndFunction; | ||
// export = timeSpan; | ||
default: typeof timeSpan; | ||
}; | ||
|
||
export = timeSpan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters