hirestime: update to 4.0 API (#39664)

This commit is contained in:
Junxiao Shi 2019-10-29 15:57:16 -04:00 committed by Jesse Trinity
parent e827c04548
commit f150fcd79b
2 changed files with 16 additions and 11 deletions

View File

@ -3,6 +3,9 @@ import hirestime = require("hirestime");
const getElapsed = hirestime();
let n: number = getElapsed();
n = getElapsed(hirestime.S);
n = getElapsed(hirestime.MS);
n = getElapsed(hirestime.NS);
n = getElapsed.s();
n = getElapsed.seconds();
n = getElapsed.ms();
n = getElapsed.milliseconds();
n = getElapsed.ns();
n = getElapsed.nanoseconds();

View File

@ -1,4 +1,4 @@
// Type definitions for hirestime 3.2
// Type definitions for hirestime 4.0
// Project: https://github.com/seriousManual/hirestime
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -6,12 +6,14 @@
export = hirestime;
declare namespace hirestime {
const S = "s";
const MS = "ms";
const NS = "ns";
interface getElapsed {
(): number;
s(): number;
seconds(): number;
ms(): number;
milliseconds(): number;
ns(): number;
nanoseconds(): number;
}
type returnedFunction = (unit?: "s"|"ms"|"ns") => number;
declare function hirestime(): returnedFunction;
declare function hirestime(): getElapsed;