add declarations for sharp-timer

This commit is contained in:
afractal
2017-06-11 19:29:58 +02:00
parent 718c4df8f6
commit feff9f9c38
4 changed files with 88 additions and 0 deletions

52
types/sharp-timer/index.d.ts vendored Normal file
View File

@@ -0,0 +1,52 @@
// Type definitions for sharp-timer 0.3
// Project: https://github.com/afractal/SharpTimer
// Definitions by: Hermes Gjini - afractal <https://github.com/afractal/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type ElapsedEvent = () => void;
export type ElapsingEvent = (intervalValue: number) => void;
export class Timer {
private _enabled;
private _stopped;
private _interval;
private _intervalElapsedEvents;
private _intervalElapsingEvents;
constructor(interval: number);
readonly enabled: boolean;
readonly stopped: boolean;
interval: number;
start(): void;
pause(): void;
resume(): void;
stop(): void;
onIntervalElapsed(intervalElapsedHandler: any): void;
onIntervalElapsing(intervalElapsingHandler: any): void;
toString(): string;
private getDoubleDigit(number);
private checkForValidInterval(interval);
}
export class Stopwatch {
private _isRunning;
private _elapsedMilliseconds;
private _startedTimeInMillis;
private _intervalIds;
private static readonly millisPerSecond;
private static readonly millisPerMinute;
private static readonly millisPerHour;
constructor();
readonly elapsed: string;
readonly elapsedMilliseconds: number;
readonly elapsedSeconds: number;
readonly elapsedMinutes: number;
readonly elapsedHours: number;
readonly isRunning: boolean;
static startNew(): Stopwatch;
start(): void;
stop(): void;
reset(): void;
restart(): void;
dispose(): void;
private getDoubleDigit(num);
}

View File

@@ -0,0 +1,11 @@
import { Timer, Stopwatch } from 'sharp-timer';
let timer = new Timer(10);
timer.onIntervalElapsing(i => { });
timer.onIntervalElapsed(() => {
timer.stop();
timer = null;
});
timer.start();

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sharp-timer-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}