Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
teddi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
teddi
Commits
f1c68996
Commit
f1c68996
authored
Nov 13, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
9a51e95a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
1 deletion
+100
-1
Timer.d.ts
dist/time/Timer.d.ts
+12
-0
Timer.js
dist/time/Timer.js
+50
-0
package.json
package.json
+1
-1
Timer.ts
src/time/Timer.ts
+37
-0
No files found.
dist/time/Timer.d.ts
0 → 100644
View file @
f1c68996
import
EventEmitter
from
"../EventEmitter"
;
export
default
class
Timer
extends
EventEmitter
<
any
>
{
_running
:
boolean
;
repeatCount
:
any
;
delay
:
any
;
currentCount
:
any
;
_timer
:
any
;
constructor
(
repeatCount
:
any
,
delay
?:
number
);
start
():
void
;
stop
():
void
;
reset
():
void
;
}
dist/time/Timer.js
0 → 100644
View file @
f1c68996
"use strict"
;
var
__extends
=
(
this
&&
this
.
__extends
)
||
(
function
()
{
var
extendStatics
=
function
(
d
,
b
)
{
extendStatics
=
Object
.
setPrototypeOf
||
({
__proto__
:
[]
}
instanceof
Array
&&
function
(
d
,
b
)
{
d
.
__proto__
=
b
;
})
||
function
(
d
,
b
)
{
for
(
var
p
in
b
)
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
b
,
p
))
d
[
p
]
=
b
[
p
];
};
return
extendStatics
(
d
,
b
);
};
return
function
(
d
,
b
)
{
extendStatics
(
d
,
b
);
function
__
()
{
this
.
constructor
=
d
;
}
d
.
prototype
=
b
===
null
?
Object
.
create
(
b
)
:
(
__
.
prototype
=
b
.
prototype
,
new
__
());
};
})();
Object
.
defineProperty
(
exports
,
"__esModule"
,
{
value
:
true
});
var
EventEmitter_1
=
require
(
"../EventEmitter"
);
var
Timer
=
/** @class */
(
function
(
_super
)
{
__extends
(
Timer
,
_super
);
function
Timer
(
repeatCount
,
delay
)
{
if
(
delay
===
void
0
)
{
delay
=
1000
;
}
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_running
=
false
;
_this
.
repeatCount
=
repeatCount
;
_this
.
delay
=
delay
;
_this
.
currentCount
=
0
;
return
_this
;
}
Timer
.
prototype
.
start
=
function
()
{
var
_this
=
this
;
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(
function
()
{
_this
.
currentCount
++
;
if
(
_this
.
currentCount
==
_this
.
repeatCount
)
{
_this
.
stop
();
_this
.
emit
(
'complete'
);
}
},
this
.
delay
);
};
Timer
.
prototype
.
stop
=
function
()
{
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
};
Timer
.
prototype
.
reset
=
function
()
{
this
.
stop
();
this
.
currentCount
=
0
;
this
.
start
();
};
return
Timer
;
}(
EventEmitter_1
.
default
));
exports
.
default
=
Timer
;
package.json
View file @
f1c68996
{
"name"
:
"teddi"
,
"version"
:
"1.0.
8
"
,
"version"
:
"1.0.
9
"
,
"description"
:
""
,
"main"
:
"dist/index.js"
,
"types"
:
"dist/index.d.ts"
,
...
...
src/time/Timer.ts
0 → 100644
View file @
f1c68996
import
EventEmitter
from
"../EventEmitter"
;
export
default
class
Timer
extends
EventEmitter
<
any
>
{
_running
=
false
;
repeatCount
;
delay
;
currentCount
;
_timer
constructor
(
repeatCount
,
delay
=
1000
)
{
super
();
this
.
repeatCount
=
repeatCount
;
this
.
delay
=
delay
;
this
.
currentCount
=
0
;
}
start
()
{
this
.
_running
=
true
;
this
.
_timer
=
setInterval
(()
=>
{
this
.
currentCount
++
;
if
(
this
.
currentCount
==
this
.
repeatCount
)
{
this
.
stop
();
this
.
emit
(
'complete'
);
}
},
this
.
delay
);
}
stop
()
{
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
}
reset
()
{
this
.
stop
();
this
.
currentCount
=
0
;
this
.
start
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment