@oscarpalmer/timer 0.24.0 → 0.25.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.
@@ -1,10 +1,10 @@
1
1
  // src/functions.ts
2
2
  import {
3
- activeTimers,
4
- beginTypes,
5
- endOrRestartTypes,
6
- endTypes,
7
- milliseconds
3
+ activeTimers,
4
+ beginTypes,
5
+ endOrRestartTypes,
6
+ endTypes,
7
+ milliseconds
8
8
  } from "./constants";
9
9
  function getOptions(options, isRepeated) {
10
10
  return {
package/dist/global.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/global.ts
2
- import {activeTimers} from "./constants";
2
+ import { activeTimers } from "./constants";
3
3
  if (globalThis._oscarpalmer_timers == null) {
4
4
  Object.defineProperty(globalThis, "_oscarpalmer_timers", {
5
5
  get() {
package/dist/index.js CHANGED
@@ -319,13 +319,13 @@ class When extends BasicTimer {
319
319
  // src/index.ts
320
320
  document.addEventListener("visibilitychange", () => {
321
321
  if (document.hidden) {
322
- for (const timer4 of activeTimers) {
323
- hiddenTimers.add(timer4);
324
- timer4.pause();
322
+ for (const timer2 of activeTimers) {
323
+ hiddenTimers.add(timer2);
324
+ timer2.pause();
325
325
  }
326
326
  } else {
327
- for (const timer4 of hiddenTimers) {
328
- timer4.continue();
327
+ for (const timer2 of hiddenTimers) {
328
+ timer2.continue();
329
329
  }
330
330
  hiddenTimers.clear();
331
331
  }
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/index.ts
2
- import {noop} from "@oscarpalmer/atoms/function";
3
- import {activeTimers, hiddenTimers} from "./constants";
2
+ import { noop } from "@oscarpalmer/atoms/function";
3
+ import { activeTimers, hiddenTimers } from "./constants";
4
4
  import"./global";
5
- import {wait} from "./timer";
5
+ import { wait } from "./timer";
6
6
  function delay(time, timeout) {
7
7
  return new Promise((resolve, reject) => {
8
8
  const delayed = wait(() => {
@@ -18,18 +18,18 @@ function delay(time, timeout) {
18
18
  });
19
19
  });
20
20
  }
21
- import {isRepeated, isTimer, isWaited, isWhen} from "./is";
22
- import {repeat, wait as wait2} from "./timer";
23
- import {when} from "./when";
21
+ import { isRepeated, isTimer, isWaited, isWhen } from "./is";
22
+ import { repeat, wait as wait2 } from "./timer";
23
+ import { when } from "./when";
24
24
  document.addEventListener("visibilitychange", () => {
25
25
  if (document.hidden) {
26
- for (const timer2 of activeTimers) {
27
- hiddenTimers.add(timer2);
28
- timer2.pause();
26
+ for (const timer of activeTimers) {
27
+ hiddenTimers.add(timer);
28
+ timer.pause();
29
29
  }
30
30
  } else {
31
- for (const timer2 of hiddenTimers) {
32
- timer2.continue();
31
+ for (const timer of hiddenTimers) {
32
+ timer.continue();
33
33
  }
34
34
  hiddenTimers.clear();
35
35
  }
package/dist/timer.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/timer.ts
2
- import {milliseconds} from "./constants";
3
- import {getOptions, work} from "./functions";
2
+ import { milliseconds } from "./constants";
3
+ import { getOptions, work } from "./functions";
4
4
  import {
5
- TimerTrace
5
+ TimerTrace
6
6
  } from "./models";
7
7
  function repeat(callback, options) {
8
8
  return timer("repeat", callback, options ?? {}, true);
package/dist/when.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  // src/when.ts
2
- import {noop} from "@oscarpalmer/atoms/function";
3
- import {BasicTimer, timer as timer2} from "./timer";
2
+ import { noop } from "@oscarpalmer/atoms/function";
3
+ import { BasicTimer, timer } from "./timer";
4
4
  function when(condition, options) {
5
5
  let result = false;
6
6
  const state = {
7
7
  started: false,
8
- timer: timer2("repeat", () => {
8
+ timer: timer("repeat", () => {
9
9
  if (condition()) {
10
10
  result = true;
11
11
  state.timer.stop();
package/package.json CHANGED
@@ -4,14 +4,14 @@
4
4
  "url": "https://oscarpalmer.se"
5
5
  },
6
6
  "dependencies": {
7
- "@oscarpalmer/atoms": "0.69.0"
7
+ "@oscarpalmer/atoms": "0.74.1"
8
8
  },
9
9
  "description": "A better solution for timeout- and interval-based timers.",
10
10
  "devDependencies": {
11
- "@biomejs/biome": "^1.9.0",
11
+ "@biomejs/biome": "^1.9.2",
12
12
  "@happy-dom/global-registrator": "^15.7.4",
13
- "@types/bun": "^1.1.9",
14
- "bun": "^1.1.27",
13
+ "@types/bun": "^1.1.10",
14
+ "bun": "^1.1.29",
15
15
  "dts-bundle-generator": "9.5.1",
16
16
  "typescript": "^5.6.2"
17
17
  },
@@ -50,5 +50,5 @@
50
50
  },
51
51
  "type": "module",
52
52
  "types": "types/index.d.cts",
53
- "version": "0.24.0"
53
+ "version": "0.25.0"
54
54
  }
package/src/global.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type {Timer} from './timer';
1
2
  import {activeTimers} from './constants';
2
3
 
3
4
  declare global {
package/types/global.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import type { Timer } from './timer';
1
2
  declare global {
2
3
  var _oscarpalmer_timer_debug: boolean | undefined;
3
4
  var _oscarpalmer_timers: Timer[] | undefined;
4
5
  }
5
- export {};