@oscarpalmer/timer 0.33.0 → 0.35.0
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.
- package/dist/constants.cjs +39 -36
- package/dist/constants.js +24 -28
- package/dist/delay.cjs +12 -21
- package/dist/delay.js +12 -17
- package/dist/get.cjs +4 -9
- package/dist/get.js +3 -5
- package/dist/global.cjs +12 -22
- package/dist/global.js +12 -20
- package/dist/index.cjs +14 -21
- package/dist/index.js +7 -6
- package/dist/is.cjs +6 -10
- package/dist/is.js +6 -6
- package/dist/models.cjs +6 -11
- package/dist/models.js +6 -7
- package/dist/repeat.cjs +15 -26
- package/dist/repeat.js +15 -22
- package/dist/rolldown_runtime.cjs +21 -0
- package/dist/timer.cjs +66 -113
- package/dist/timer.full.js +88 -70
- package/dist/timer.js +65 -109
- package/dist/wait.cjs +15 -26
- package/dist/wait.js +15 -22
- package/dist/when.cjs +92 -137
- package/dist/when.js +91 -133
- package/dist/work.cjs +68 -73
- package/dist/work.js +68 -69
- package/package.json +7 -6
- package/src/constants.ts +15 -22
- package/src/get.ts +5 -3
- package/src/global.ts +14 -11
- package/src/is.ts +5 -4
- package/src/repeat.ts +2 -2
- package/src/timer.ts +13 -6
- package/src/wait.ts +2 -2
- package/src/when.ts +12 -5
- package/src/work.ts +56 -40
- package/types/constants.d.cts +9 -13
- package/types/constants.d.ts +10 -14
- package/types/get.d.cts +3 -0
- package/types/work.d.cts +1 -1
- package/types/work.d.ts +1 -1
package/dist/constants.cjs
CHANGED
|
@@ -1,50 +1,53 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
1
|
function calculate() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
requestAnimationFrame(step);
|
|
22
|
-
});
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const values = [];
|
|
4
|
+
let last;
|
|
5
|
+
function step(now) {
|
|
6
|
+
if (last != null) values.push(now - last);
|
|
7
|
+
last = now;
|
|
8
|
+
if (values.length >= 10) {
|
|
9
|
+
const median = values.sort().slice(2, -2).reduce((first, second) => first + second, 0) / (values.length - 4);
|
|
10
|
+
resolve(median);
|
|
11
|
+
} else requestAnimationFrame(step);
|
|
12
|
+
}
|
|
13
|
+
requestAnimationFrame(step);
|
|
14
|
+
});
|
|
23
15
|
}
|
|
16
|
+
const defaultTimeout = 3e4;
|
|
24
17
|
const activeTimers = /* @__PURE__ */ new Set();
|
|
25
|
-
const beginTypes = /* @__PURE__ */ new Set(["continue", "start"]);
|
|
26
18
|
const intervalBuffer = 5;
|
|
27
19
|
const destroyedMessage = "Timer has already been destroyed";
|
|
28
|
-
const endTypes = /* @__PURE__ */ new Set(["pause", "stop"]);
|
|
29
|
-
const endOrRestartTypes = /* @__PURE__ */ new Set([
|
|
30
|
-
"pause",
|
|
31
|
-
"restart",
|
|
32
|
-
"stop"
|
|
33
|
-
]);
|
|
34
20
|
const hiddenTimers = /* @__PURE__ */ new Set();
|
|
35
|
-
const pauseTypes = /* @__PURE__ */ new Set(["continue", "pause"]);
|
|
36
21
|
const startedMessage = "Timer has already been started";
|
|
37
|
-
|
|
22
|
+
const TYPE_REPEAT = "repeat";
|
|
23
|
+
const TYPE_WAIT = "wait";
|
|
24
|
+
const TYPE_WHEN = "when";
|
|
25
|
+
const WORK_CONTINUE = "continue";
|
|
26
|
+
const WORK_PAUSE = "pause";
|
|
27
|
+
const WORK_RESTART = "restart";
|
|
28
|
+
const WORK_START = "start";
|
|
29
|
+
const WORK_STOP = "stop";
|
|
30
|
+
let milliseconds = 1e3 / 60;
|
|
38
31
|
calculate().then((value) => {
|
|
39
|
-
|
|
32
|
+
milliseconds = value;
|
|
40
33
|
});
|
|
41
|
-
|
|
34
|
+
exports.TYPE_REPEAT = TYPE_REPEAT;
|
|
35
|
+
exports.TYPE_WAIT = TYPE_WAIT;
|
|
36
|
+
exports.TYPE_WHEN = TYPE_WHEN;
|
|
37
|
+
exports.WORK_CONTINUE = WORK_CONTINUE;
|
|
38
|
+
exports.WORK_PAUSE = WORK_PAUSE;
|
|
39
|
+
exports.WORK_RESTART = WORK_RESTART;
|
|
40
|
+
exports.WORK_START = WORK_START;
|
|
41
|
+
exports.WORK_STOP = WORK_STOP;
|
|
42
42
|
exports.activeTimers = activeTimers;
|
|
43
|
-
exports.
|
|
43
|
+
exports.defaultTimeout = defaultTimeout;
|
|
44
44
|
exports.destroyedMessage = destroyedMessage;
|
|
45
|
-
exports.endOrRestartTypes = endOrRestartTypes;
|
|
46
|
-
exports.endTypes = endTypes;
|
|
47
45
|
exports.hiddenTimers = hiddenTimers;
|
|
48
46
|
exports.intervalBuffer = intervalBuffer;
|
|
49
|
-
exports
|
|
47
|
+
Object.defineProperty(exports, "milliseconds", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function() {
|
|
50
|
+
return milliseconds;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
50
53
|
exports.startedMessage = startedMessage;
|
package/dist/constants.js
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
function calculate() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
requestAnimationFrame(step);
|
|
18
|
-
});
|
|
2
|
+
return new Promise((resolve) => {
|
|
3
|
+
const values = [];
|
|
4
|
+
let last;
|
|
5
|
+
function step(now) {
|
|
6
|
+
if (last != null) values.push(now - last);
|
|
7
|
+
last = now;
|
|
8
|
+
if (values.length >= 10) {
|
|
9
|
+
const median = values.sort().slice(2, -2).reduce((first, second) => first + second, 0) / (values.length - 4);
|
|
10
|
+
resolve(median);
|
|
11
|
+
} else requestAnimationFrame(step);
|
|
12
|
+
}
|
|
13
|
+
requestAnimationFrame(step);
|
|
14
|
+
});
|
|
19
15
|
}
|
|
16
|
+
const defaultTimeout = 3e4;
|
|
20
17
|
const activeTimers = /* @__PURE__ */ new Set();
|
|
21
|
-
const beginTypes = /* @__PURE__ */ new Set(["continue", "start"]);
|
|
22
18
|
const intervalBuffer = 5;
|
|
23
19
|
const destroyedMessage = "Timer has already been destroyed";
|
|
24
|
-
const endTypes = /* @__PURE__ */ new Set(["pause", "stop"]);
|
|
25
|
-
const endOrRestartTypes = /* @__PURE__ */ new Set([
|
|
26
|
-
"pause",
|
|
27
|
-
"restart",
|
|
28
|
-
"stop"
|
|
29
|
-
]);
|
|
30
20
|
const hiddenTimers = /* @__PURE__ */ new Set();
|
|
31
|
-
const pauseTypes = /* @__PURE__ */ new Set(["continue", "pause"]);
|
|
32
21
|
const startedMessage = "Timer has already been started";
|
|
22
|
+
const TYPE_REPEAT = "repeat";
|
|
23
|
+
const TYPE_WAIT = "wait";
|
|
24
|
+
const TYPE_WHEN = "when";
|
|
25
|
+
const WORK_CONTINUE = "continue";
|
|
26
|
+
const WORK_PAUSE = "pause";
|
|
27
|
+
const WORK_RESTART = "restart";
|
|
28
|
+
const WORK_START = "start";
|
|
29
|
+
const WORK_STOP = "stop";
|
|
33
30
|
let milliseconds = 1e3 / 60;
|
|
34
31
|
calculate().then((value) => {
|
|
35
|
-
|
|
32
|
+
milliseconds = value;
|
|
36
33
|
});
|
|
37
|
-
|
|
38
|
-
export { activeTimers, beginTypes, destroyedMessage, endOrRestartTypes, endTypes, hiddenTimers, intervalBuffer, milliseconds, pauseTypes, startedMessage };
|
|
34
|
+
export { TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN, WORK_CONTINUE, WORK_PAUSE, WORK_RESTART, WORK_START, WORK_STOP, activeTimers, defaultTimeout, destroyedMessage, hiddenTimers, intervalBuffer, milliseconds, startedMessage };
|
package/dist/delay.cjs
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const constants = require('./constants.cjs');
|
|
6
|
-
const get = require('./get.cjs');
|
|
7
|
-
|
|
1
|
+
const require_constants = require("./constants.cjs");
|
|
2
|
+
const require_get = require("./get.cjs");
|
|
8
3
|
function delay(time) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
requestAnimationFrame(step);
|
|
21
|
-
});
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const interval = require_get.getValidNumber(time, require_constants.milliseconds);
|
|
6
|
+
let start;
|
|
7
|
+
function step(now) {
|
|
8
|
+
start ??= now;
|
|
9
|
+
if (interval === require_constants.milliseconds || now - start >= interval - require_constants.intervalBuffer) resolve();
|
|
10
|
+
else requestAnimationFrame(step);
|
|
11
|
+
}
|
|
12
|
+
requestAnimationFrame(step);
|
|
13
|
+
});
|
|
22
14
|
}
|
|
23
|
-
|
|
24
15
|
exports.delay = delay;
|
package/dist/delay.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getValidNumber } from
|
|
3
|
-
|
|
1
|
+
import { intervalBuffer, milliseconds } from "./constants.js";
|
|
2
|
+
import { getValidNumber } from "./get.js";
|
|
4
3
|
function delay(time) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
requestAnimationFrame(step);
|
|
17
|
-
});
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const interval = getValidNumber(time, milliseconds);
|
|
6
|
+
let start;
|
|
7
|
+
function step(now) {
|
|
8
|
+
start ??= now;
|
|
9
|
+
if (interval === milliseconds || now - start >= interval - intervalBuffer) resolve();
|
|
10
|
+
else requestAnimationFrame(step);
|
|
11
|
+
}
|
|
12
|
+
requestAnimationFrame(step);
|
|
13
|
+
});
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
export { delay };
|
package/dist/get.cjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const _function = require('@oscarpalmer/atoms/function');
|
|
6
|
-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown_runtime.cjs");
|
|
2
|
+
const __oscarpalmer_atoms_function = require_rolldown_runtime.__toESM(require("@oscarpalmer/atoms/function"));
|
|
7
3
|
function getCallback(value) {
|
|
8
|
-
|
|
4
|
+
return typeof value === "function" ? value : __oscarpalmer_atoms_function.noop;
|
|
9
5
|
}
|
|
10
6
|
function getValidNumber(value, defaultValue) {
|
|
11
|
-
|
|
7
|
+
return typeof value === "number" ? value > 0 ? value : 0 : defaultValue ?? 0;
|
|
12
8
|
}
|
|
13
|
-
|
|
14
9
|
exports.getCallback = getCallback;
|
|
15
10
|
exports.getValidNumber = getValidNumber;
|
package/dist/get.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { noop } from
|
|
2
|
-
|
|
1
|
+
import { noop } from "@oscarpalmer/atoms/function";
|
|
3
2
|
function getCallback(value) {
|
|
4
|
-
|
|
3
|
+
return typeof value === "function" ? value : noop;
|
|
5
4
|
}
|
|
6
5
|
function getValidNumber(value, defaultValue) {
|
|
7
|
-
|
|
6
|
+
return typeof value === "number" ? value > 0 ? value : 0 : defaultValue ?? 0;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
export { getCallback, getValidNumber };
|
package/dist/global.cjs
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (globalThis._oscarpalmer_timers == null) {
|
|
6
|
-
Object.defineProperty(globalThis, "_oscarpalmer_timers", {
|
|
7
|
-
get() {
|
|
8
|
-
return globalThis._oscarpalmer_timer_debug ? [...constants.activeTimers] : [];
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
1
|
+
const require_constants = require("./constants.cjs");
|
|
2
|
+
if (globalThis._oscarpalmer_timers == null) Object.defineProperty(globalThis, "_oscarpalmer_timers", { get() {
|
|
3
|
+
return globalThis._oscarpalmer_timer_debug ? [...require_constants.activeTimers] : [];
|
|
4
|
+
} });
|
|
12
5
|
document.addEventListener("visibilitychange", () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
constants.hiddenTimers.clear();
|
|
23
|
-
}
|
|
6
|
+
const from = document.hidden ? require_constants.activeTimers : require_constants.hiddenTimers;
|
|
7
|
+
const method = document.hidden ? require_constants.WORK_PAUSE : require_constants.WORK_CONTINUE;
|
|
8
|
+
const to = document.hidden ? require_constants.hiddenTimers : require_constants.activeTimers;
|
|
9
|
+
for (const timer of from) {
|
|
10
|
+
timer[method]();
|
|
11
|
+
to.add(timer);
|
|
12
|
+
}
|
|
13
|
+
from.clear();
|
|
24
14
|
});
|
package/dist/global.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { activeTimers, hiddenTimers } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
get() {
|
|
6
|
-
return globalThis._oscarpalmer_timer_debug ? [...activeTimers] : [];
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
}
|
|
1
|
+
import { WORK_CONTINUE, WORK_PAUSE, activeTimers, hiddenTimers } from "./constants.js";
|
|
2
|
+
if (globalThis._oscarpalmer_timers == null) Object.defineProperty(globalThis, "_oscarpalmer_timers", { get() {
|
|
3
|
+
return globalThis._oscarpalmer_timer_debug ? [...activeTimers] : [];
|
|
4
|
+
} });
|
|
10
5
|
document.addEventListener("visibilitychange", () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
hiddenTimers.clear();
|
|
21
|
-
}
|
|
6
|
+
const from = document.hidden ? activeTimers : hiddenTimers;
|
|
7
|
+
const method = document.hidden ? WORK_PAUSE : WORK_CONTINUE;
|
|
8
|
+
const to = document.hidden ? hiddenTimers : activeTimers;
|
|
9
|
+
for (const timer of from) {
|
|
10
|
+
timer[method]();
|
|
11
|
+
to.add(timer);
|
|
12
|
+
}
|
|
13
|
+
from.clear();
|
|
22
14
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.
|
|
15
|
-
exports.isRepeated = is.isRepeated;
|
|
16
|
-
exports.isTimer = is.isTimer;
|
|
17
|
-
exports.isWaited = is.isWaited;
|
|
18
|
-
exports.isWhen = is.isWhen;
|
|
19
|
-
exports.repeat = repeat.repeat;
|
|
20
|
-
exports.wait = wait.wait;
|
|
21
|
-
exports.when = when.when;
|
|
1
|
+
require("./global.cjs");
|
|
2
|
+
const require_when = require("./when.cjs");
|
|
3
|
+
const require_wait = require("./wait.cjs");
|
|
4
|
+
const require_repeat = require("./repeat.cjs");
|
|
5
|
+
const require_is = require("./is.cjs");
|
|
6
|
+
const require_delay = require("./delay.cjs");
|
|
7
|
+
exports.delay = require_delay.delay;
|
|
8
|
+
exports.isRepeated = require_is.isRepeated;
|
|
9
|
+
exports.isTimer = require_is.isTimer;
|
|
10
|
+
exports.isWaited = require_is.isWaited;
|
|
11
|
+
exports.isWhen = require_is.isWhen;
|
|
12
|
+
exports.repeat = require_repeat.repeat;
|
|
13
|
+
exports.wait = require_wait.wait;
|
|
14
|
+
exports.when = require_when.when;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import "./global.js";
|
|
2
|
+
import { when } from "./when.js";
|
|
3
|
+
import { wait } from "./wait.js";
|
|
4
|
+
import { repeat } from "./repeat.js";
|
|
5
|
+
import { isRepeated, isTimer, isWaited, isWhen } from "./is.js";
|
|
6
|
+
import { delay } from "./delay.js";
|
|
7
|
+
export { delay, isRepeated, isTimer, isWaited, isWhen, repeat, wait, when };
|
package/dist/is.cjs
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
1
|
+
const require_constants = require("./constants.cjs");
|
|
5
2
|
function is(names, value) {
|
|
6
|
-
|
|
3
|
+
return names.includes(value?.$timer);
|
|
7
4
|
}
|
|
8
5
|
function isRepeated(value) {
|
|
9
|
-
|
|
6
|
+
return is([require_constants.TYPE_REPEAT], value);
|
|
10
7
|
}
|
|
11
8
|
function isTimer(value) {
|
|
12
|
-
|
|
9
|
+
return is([require_constants.TYPE_REPEAT, require_constants.TYPE_WAIT], value);
|
|
13
10
|
}
|
|
14
11
|
function isWaited(value) {
|
|
15
|
-
|
|
12
|
+
return is([require_constants.TYPE_WAIT], value);
|
|
16
13
|
}
|
|
17
14
|
function isWhen(value) {
|
|
18
|
-
|
|
15
|
+
return is([require_constants.TYPE_WHEN], value) && typeof value.then === "function";
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
exports.isRepeated = isRepeated;
|
|
22
18
|
exports.isTimer = isTimer;
|
|
23
19
|
exports.isWaited = isWaited;
|
package/dist/is.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import { TYPE_REPEAT, TYPE_WAIT, TYPE_WHEN } from "./constants.js";
|
|
1
2
|
function is(names, value) {
|
|
2
|
-
|
|
3
|
+
return names.includes(value?.$timer);
|
|
3
4
|
}
|
|
4
5
|
function isRepeated(value) {
|
|
5
|
-
|
|
6
|
+
return is([TYPE_REPEAT], value);
|
|
6
7
|
}
|
|
7
8
|
function isTimer(value) {
|
|
8
|
-
|
|
9
|
+
return is([TYPE_REPEAT, TYPE_WAIT], value);
|
|
9
10
|
}
|
|
10
11
|
function isWaited(value) {
|
|
11
|
-
|
|
12
|
+
return is([TYPE_WAIT], value);
|
|
12
13
|
}
|
|
13
14
|
function isWhen(value) {
|
|
14
|
-
|
|
15
|
+
return is([TYPE_WHEN], value) && typeof value.then === "function";
|
|
15
16
|
}
|
|
16
|
-
|
|
17
17
|
export { isRepeated, isTimer, isWaited, isWhen };
|
package/dist/models.cjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
super();
|
|
8
|
-
this.name = "TimerTrace";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
var TimerTrace = class extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super();
|
|
4
|
+
this.name = "TimerTrace";
|
|
5
|
+
}
|
|
6
|
+
};
|
|
12
7
|
exports.TimerTrace = TimerTrace;
|
package/dist/models.js
CHANGED
package/dist/repeat.cjs
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const get = require('./get.cjs');
|
|
7
|
-
require('./global.cjs');
|
|
8
|
-
const models = require('./models.cjs');
|
|
9
|
-
const timer = require('./timer.cjs');
|
|
10
|
-
|
|
1
|
+
const require_constants = require("./constants.cjs");
|
|
2
|
+
const require_get = require("./get.cjs");
|
|
3
|
+
require("./global.cjs");
|
|
4
|
+
const require_models = require("./models.cjs");
|
|
5
|
+
const require_timer = require("./timer.cjs");
|
|
11
6
|
function repeat(callback, options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
interval: get.getValidNumber(options?.interval, constants.milliseconds),
|
|
23
|
-
timeout: 0
|
|
24
|
-
},
|
|
25
|
-
true
|
|
26
|
-
);
|
|
7
|
+
return new require_timer.Timer(require_constants.TYPE_REPEAT, {
|
|
8
|
+
callback: require_get.getCallback(callback),
|
|
9
|
+
trace: new require_models.TimerTrace().stack
|
|
10
|
+
}, {
|
|
11
|
+
onAfter: require_get.getCallback(options?.onAfter),
|
|
12
|
+
onError: void 0,
|
|
13
|
+
count: require_get.getValidNumber(options?.count),
|
|
14
|
+
interval: require_get.getValidNumber(options?.interval, require_constants.milliseconds),
|
|
15
|
+
timeout: 0
|
|
16
|
+
}, true);
|
|
27
17
|
}
|
|
28
|
-
|
|
29
18
|
exports.repeat = repeat;
|
package/dist/repeat.js
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import { milliseconds } from
|
|
2
|
-
import { getCallback, getValidNumber } from
|
|
3
|
-
import
|
|
4
|
-
import { TimerTrace } from
|
|
5
|
-
import { Timer } from
|
|
6
|
-
|
|
1
|
+
import { TYPE_REPEAT, milliseconds } from "./constants.js";
|
|
2
|
+
import { getCallback, getValidNumber } from "./get.js";
|
|
3
|
+
import "./global.js";
|
|
4
|
+
import { TimerTrace } from "./models.js";
|
|
5
|
+
import { Timer } from "./timer.js";
|
|
7
6
|
function repeat(callback, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
interval: getValidNumber(options?.interval, milliseconds),
|
|
19
|
-
timeout: 0
|
|
20
|
-
},
|
|
21
|
-
true
|
|
22
|
-
);
|
|
7
|
+
return new Timer(TYPE_REPEAT, {
|
|
8
|
+
callback: getCallback(callback),
|
|
9
|
+
trace: new TimerTrace().stack
|
|
10
|
+
}, {
|
|
11
|
+
onAfter: getCallback(options?.onAfter),
|
|
12
|
+
onError: void 0,
|
|
13
|
+
count: getValidNumber(options?.count),
|
|
14
|
+
interval: getValidNumber(options?.interval, milliseconds),
|
|
15
|
+
timeout: 0
|
|
16
|
+
}, true);
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
export { repeat };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
+
key = keys[i];
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: ((k) => from[k]).bind(null, key),
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
value: mod,
|
|
19
|
+
enumerable: true
|
|
20
|
+
}) : target, mod));
|
|
21
|
+
exports.__toESM = __toESM;
|