Commit 8610a80e authored by wildfirecode13's avatar wildfirecode13

1

parent d0e514e0
import EventEmitter from "./EventEmitter";
export default class Countdown extends EventEmitter<any> {
_timer: any;
_text: any;
_seconds: any;
_format: any;
_counter: any;
_delay: any;
_running: boolean;
private _timer;
private _text;
private _seconds;
private _format;
private _counter;
private _delay;
private _running;
constructor(text: any, seconds: any, format: any, delay: any);
getCountdown(): string | undefined;
getHHMMSS(): string;
getMMSS(): string;
getText(): any;
private getCountdown;
private getHHMMSS;
private getMMSS;
private getText;
start(): void;
stop(): void;
private stop;
reset($seconds: number): void;
set seconds(val: number);
get running(): boolean;
}
......@@ -70,16 +70,12 @@ var Countdown = /** @class */ (function (_super) {
this.emit("complete");
};
Countdown.prototype.reset = function ($seconds) {
this.seconds = $seconds;
this._seconds = $seconds;
};
Object.defineProperty(Countdown.prototype, "seconds", {
set: function (val) {
this._seconds = val;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Countdown.prototype, "running", {
// set seconds(val: number) {
// this._seconds = val;
// }
get: function () {
return this._running;
},
......
{
"name": "teddi",
"version": "1.0.4",
"version": "1.0.5",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
......@@ -5,13 +5,13 @@ function getNum(n: any) {
}
export default class Countdown extends EventEmitter<any> {
_timer: any;
_text: any;
_seconds: any;
_format: any;
_counter: any;
_delay: any;
_running = false;
private _timer: any;
private _text: any;
private _seconds: any;
private _format: any;
private _counter: any;
private _delay: any;
private _running = false;
constructor(text: any, seconds: any, format: any, delay: any) {
super();
console.log(this);
......@@ -22,12 +22,12 @@ export default class Countdown extends EventEmitter<any> {
this._delay = delay || 1000;
}
getCountdown() {
private getCountdown() {
if (this._format == "hhmmss") return this.getHHMMSS();
if (this._format == "mmss") return this.getMMSS();
}
getHHMMSS() {
private getHHMMSS() {
const left = this._seconds - this._counter;
const hours = Math.floor(left / 3600);
const minutes = Math.floor((left % 3600) / 60);
......@@ -35,14 +35,14 @@ export default class Countdown extends EventEmitter<any> {
return `${getNum(hours)}:${getNum(minutes)}:${getNum(seconds)}`;
}
getMMSS() {
private getMMSS() {
const left = this._seconds - this._counter;
const minutes = Math.floor(left / 60);
const seconds = left % 60;
return `${getNum(minutes)}:${getNum(seconds)}`;
}
getText() {
private getText() {
return this._text.replace("{0}", this.getCountdown());
}
......@@ -58,19 +58,19 @@ export default class Countdown extends EventEmitter<any> {
}, this._delay);
}
stop() {
private stop() {
this._running = false;
clearInterval(this._timer);
this.emit("complete");
}
reset($seconds: number) {
this.seconds = $seconds;
this._seconds = $seconds;
}
set seconds(val: number) {
this._seconds = val;
}
// set seconds(val: number) {
// this._seconds = val;
// }
get running() {
return this._running;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment