mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
feat(nanotimer): complete definition (#42153)
* feat(nanotimer): complete definition * lint
This commit is contained in:
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
// Type definitions for nanotimer 0.3
|
||||
// Project: https://github.com/Krb686/nanotimer
|
||||
// Definitions by: Samuel Bodin <https://github.com/bodinsamuel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace NanoTimer {
|
||||
interface TimeoutResults {
|
||||
waitTime: number;
|
||||
}
|
||||
}
|
||||
|
||||
declare class NanoTimer {
|
||||
/**
|
||||
* Creates an instance of NanoTimer.
|
||||
* @param log - if true, will enable logging.
|
||||
*/
|
||||
constructor(log?: boolean);
|
||||
|
||||
/**
|
||||
* Call the task after the waiting the the timeout specified.
|
||||
*/
|
||||
setTimeout(
|
||||
task: (...args: any[]) => void,
|
||||
args: any[] | string,
|
||||
timeout: string,
|
||||
callback?: (results: NanoTimer.TimeoutResults) => void,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Clears current running timeOut.
|
||||
*/
|
||||
clearTimeout(): void;
|
||||
|
||||
/**
|
||||
* Call the task at the regular interval specified in interval.
|
||||
*/
|
||||
setInterval(
|
||||
task: (...args: any[]) => void,
|
||||
args: any[] | string,
|
||||
interval: string,
|
||||
callback?: (error: Error) => void,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Clears current running interval.
|
||||
*/
|
||||
clearInterval(): void;
|
||||
|
||||
/**
|
||||
* Calculate the time it tooks to execute the task.
|
||||
*/
|
||||
time(
|
||||
task: (cb: () => void) => void,
|
||||
args: string | any[],
|
||||
interval: string,
|
||||
callback?: (error: Error) => void,
|
||||
): number;
|
||||
|
||||
/**
|
||||
* Returns true if the timer currently has a scheduled timeout, or false otherwise
|
||||
*/
|
||||
hasTimeout(): boolean;
|
||||
}
|
||||
|
||||
export = NanoTimer;
|
||||
@@ -0,0 +1,10 @@
|
||||
import NanoTimer = require('nanotimer');
|
||||
|
||||
const timer = new NanoTimer();
|
||||
timer.setInterval(() => {}, '', '1s');
|
||||
timer.setTimeout(() => {}, [timer], '10s');
|
||||
const runtimeSeconds = timer.time(() => {}, '', 'u');
|
||||
|
||||
timer.clearInterval();
|
||||
timer.clearTimeout();
|
||||
timer.hasTimeout();
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"nanotimer-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user