namirasoft-core 1.4.32 → 1.4.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare class SetTimeouService {
|
|
2
|
-
private
|
|
2
|
+
private last_date;
|
|
3
|
+
private last_index;
|
|
4
|
+
private onCalled;
|
|
3
5
|
setTimeoutIfNotCalledAgain(callback: () => void, milliseconds: number): void;
|
|
6
|
+
setTimeoutIfFarArrival(callback: () => void, milliseconds: number): void;
|
|
4
7
|
}
|
package/dist/SetTimeouService.js
CHANGED
|
@@ -4,14 +4,27 @@ exports.SetTimeouService = void 0;
|
|
|
4
4
|
const TimeOperation_1 = require("./TimeOperation");
|
|
5
5
|
class SetTimeouService {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.
|
|
7
|
+
this.last_date = new Date();
|
|
8
|
+
this.last_index = 0;
|
|
9
|
+
}
|
|
10
|
+
onCalled(milliseconds) {
|
|
11
|
+
this.last_index++;
|
|
12
|
+
let l = TimeOperation_1.TimeOperation.millisecondsLater(milliseconds - 1, this.last_date);
|
|
13
|
+
if (this.last_date < l)
|
|
14
|
+
this.last_date = l;
|
|
15
|
+
return this.last_index;
|
|
8
16
|
}
|
|
9
17
|
setTimeoutIfNotCalledAgain(callback, milliseconds) {
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
this.
|
|
18
|
+
let index = this.onCalled(milliseconds);
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
if (index === this.last_index)
|
|
21
|
+
callback();
|
|
22
|
+
}, milliseconds);
|
|
23
|
+
}
|
|
24
|
+
setTimeoutIfFarArrival(callback, milliseconds) {
|
|
25
|
+
this.onCalled(milliseconds);
|
|
13
26
|
setTimeout(() => {
|
|
14
|
-
if (this.
|
|
27
|
+
if (this.last_date < new Date())
|
|
15
28
|
callback();
|
|
16
29
|
}, milliseconds);
|
|
17
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetTimeouService.js","sourceRoot":"","sources":["../src/SetTimeouService.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEhD,MAAa,gBAAgB;IAA7B;QAEY,
|
|
1
|
+
{"version":3,"file":"SetTimeouService.js","sourceRoot":"","sources":["../src/SetTimeouService.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEhD,MAAa,gBAAgB;IAA7B;QAEY,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,eAAU,GAAW,CAAC,CAAC;IA2BnC,CAAC;IA1BW,QAAQ,CAAC,YAAoB;QAEjC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,6BAAa,CAAC,iBAAiB,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1E,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC;YAClB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IACD,0BAA0B,CAAC,QAAoB,EAAE,YAAoB;QAEjE,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACxC,UAAU,CAAC,GAAG,EAAE;YAEZ,IAAI,KAAK,KAAK,IAAI,CAAC,UAAU;gBACzB,QAAQ,EAAE,CAAC;QACnB,CAAC,EAAE,YAAY,CAAC,CAAC;IACrB,CAAC;IACD,sBAAsB,CAAC,QAAoB,EAAE,YAAoB;QAE7D,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC5B,UAAU,CAAC,GAAG,EAAE;YAEZ,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE;gBAC3B,QAAQ,EAAE,CAAC;QACnB,CAAC,EAAE,YAAY,CAAC,CAAC;IACrB,CAAC;CACJ;AA9BD,4CA8BC"}
|
package/package.json
CHANGED
package/src/SetTimeouService.ts
CHANGED
|
@@ -2,15 +2,31 @@ import { TimeOperation } from "./TimeOperation";
|
|
|
2
2
|
|
|
3
3
|
export class SetTimeouService
|
|
4
4
|
{
|
|
5
|
-
private
|
|
5
|
+
private last_date: Date = new Date();
|
|
6
|
+
private last_index: number = 0;
|
|
7
|
+
private onCalled(milliseconds: number)
|
|
8
|
+
{
|
|
9
|
+
this.last_index++;
|
|
10
|
+
let l = TimeOperation.millisecondsLater(milliseconds - 1, this.last_date);
|
|
11
|
+
if (this.last_date < l)
|
|
12
|
+
this.last_date = l;
|
|
13
|
+
return this.last_index;
|
|
14
|
+
}
|
|
6
15
|
setTimeoutIfNotCalledAgain(callback: () => void, milliseconds: number)
|
|
7
16
|
{
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
let index = this.onCalled(milliseconds);
|
|
18
|
+
setTimeout(() =>
|
|
19
|
+
{
|
|
20
|
+
if (index === this.last_index)
|
|
21
|
+
callback();
|
|
22
|
+
}, milliseconds);
|
|
23
|
+
}
|
|
24
|
+
setTimeoutIfFarArrival(callback: () => void, milliseconds: number)
|
|
25
|
+
{
|
|
26
|
+
this.onCalled(milliseconds);
|
|
11
27
|
setTimeout(() =>
|
|
12
28
|
{
|
|
13
|
-
if (this.
|
|
29
|
+
if (this.last_date < new Date())
|
|
14
30
|
callback();
|
|
15
31
|
}, milliseconds);
|
|
16
32
|
}
|