mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-30 01:47:21 +08:00
add declarations for sharp-timer
This commit is contained in:
52
types/sharp-timer/index.d.ts
vendored
Normal file
52
types/sharp-timer/index.d.ts
vendored
Normal 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);
|
||||
}
|
||||
11
types/sharp-timer/sharp-timer-tests.ts
Normal file
11
types/sharp-timer/sharp-timer-tests.ts
Normal 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();
|
||||
22
types/sharp-timer/tsconfig.json
Normal file
22
types/sharp-timer/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
3
types/sharp-timer/tslint.json
Normal file
3
types/sharp-timer/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user